Changed the unit description code to no longer use SDL_GetTicks()...
...but to use get_random() the former is not MP safe and causes a lot of OOS errors.
This commit is contained in:
parent
16c093897c
commit
8cfe03e99b
3 changed files with 8 additions and 5 deletions
|
@ -5,6 +5,8 @@ Version 1.3.5+svn:
|
|||
* the random start ToD option is now properly saved and loaded (bug #9532)
|
||||
* the map in the lobby could be randomly invisible due to an unitialized
|
||||
variable (bug #9555)
|
||||
* the automatic unit description used a non-MP safe way, this has been
|
||||
fixed
|
||||
* miscellaneous and bug fixes
|
||||
* various code cleanups
|
||||
* proper handling of description autogeneration for per level [effect] on
|
||||
|
|
|
@ -15,6 +15,7 @@ Version 1.3.5+svn:
|
|||
* Multiplayer
|
||||
* The random starting time of day setting is will now be remembered.
|
||||
* Fixed a bug which could lead to the map in the lobby to become invisible.
|
||||
* Fixed an OOS which happened when a unit was recruited.
|
||||
|
||||
* Unit changes and balancing
|
||||
|
||||
|
|
10
src/unit.cpp
10
src/unit.cpp
|
@ -273,9 +273,9 @@ unit::unit(const game_data* gamedata, unit_map* unitmap, const gamemap* map,
|
|||
if(underlying_description_.empty()){
|
||||
char buf[80];
|
||||
if(!custom_unit_description_.empty()){
|
||||
snprintf(buf, sizeof(buf), "%s-%d-%s",type()->id().c_str(),(SDL_GetTicks()), custom_unit_description_.c_str());
|
||||
snprintf(buf, sizeof(buf), "%s-%d-%s",type()->id().c_str(), get_random(), custom_unit_description_.c_str());
|
||||
}else{
|
||||
snprintf(buf, sizeof(buf), "%s-%d",type()->id().c_str(),(SDL_GetTicks()));
|
||||
snprintf(buf, sizeof(buf), "%s-%d",type()->id().c_str(), get_random());
|
||||
}
|
||||
underlying_description_ = buf;
|
||||
}
|
||||
|
@ -317,9 +317,9 @@ unit::unit(const unit_type* t, int side, bool use_traits, bool dummy_unit, unit_
|
|||
if(underlying_description_.empty()){
|
||||
char buf[80];
|
||||
if(!custom_unit_description_.empty()){
|
||||
snprintf(buf, sizeof(buf), "%s-%d-%s",type()->id().c_str(),(SDL_GetTicks()), custom_unit_description_.c_str());
|
||||
snprintf(buf, sizeof(buf), "%s-%d-%s",type()->id().c_str(), get_random(), custom_unit_description_.c_str());
|
||||
}else{
|
||||
snprintf(buf, sizeof(buf), "%s-%d",type()->id().c_str(),(SDL_GetTicks()));
|
||||
snprintf(buf, sizeof(buf), "%s-%d",type()->id().c_str(), get_random());
|
||||
}
|
||||
underlying_description_ = buf;
|
||||
}
|
||||
|
@ -957,7 +957,7 @@ void unit::read(const config& cfg)
|
|||
underlying_description_ = cfg["description"];
|
||||
if(underlying_description_.empty()){
|
||||
char buf[80];
|
||||
snprintf(buf, sizeof(buf), "%s-%d",cfg["type"].c_str(),(SDL_GetTicks()%1000000));
|
||||
snprintf(buf, sizeof(buf), "%s-%d",cfg["type"].c_str(), get_random());
|
||||
underlying_description_ = buf;
|
||||
}
|
||||
if(description_.empty()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue