URL:
  <http://gna.org/patch/?1046>

                 Summary: unit map improvements
                 Project: Battle for Wesnoth
            Submitted by: cjhopman
            Submitted on: Tuesday 04/08/2008 at 20:23
                Priority: 5 - Normal
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

A couple improvements to the unit map.

1. changed the location map from map<location<pair<location, unit>*> to
map<location, string> since that is all it was doing anyway, that is it keeps
the id to look up in the other map.

2. no longer allows duplicate entries. when trying to insert a duplicate
entry it will use a different id in the maps. this means that the unit is
still accessible by looking it up by location. Before we allowed duplicate
units and had to have a bunch of special condition stuff to check for it.



in unit.hpp/cpp underlying_id_ is now generated in a seperate method, rather
than repeating the code several times in different places. Also, it now uses
two random numbers rather than just one. That is, before it was made unique
by appending a random number to the id. With the range of the random number
being as small as [1, 32767] this is not sufficient to prevent id clashes.
Simple solution for now was to use 2 such numbers.



    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Tuesday 04/08/2008 at 20:23  Name:
unit_map_and_unit_id_generation.patch  Size: 10kB   By: cjhopman
unit map improvements
<http://gna.org/patch/download.php?file_id=4155>

    _______________________________________________________

Reply to this item at:

  <http://gna.org/patch/?1046>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Wesnoth-bugs mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-bugs

Reply via email to