Skip to content

Commit

Permalink
[11963] Add additional check for game_events, invalid occurence
Browse files Browse the repository at this point in the history
Signed-off-by: Schmoozerd <[email protected]>
  • Loading branch information
Schmoozerd committed Apr 15, 2012
1 parent b71a244 commit 641e7ce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions src/game/GameEventMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,23 @@ void GameEventMgr::LoadFromDB()
pGameEvent.holiday_id = HolidayIds(fields[5].GetUInt32());


if(pGameEvent.length==0) // length>0 is validity check
if (pGameEvent.length == 0) // length>0 is validity check
{
sLog.outErrorDb("`game_event` game event id (%i) have length 0 and can't be used.",event_id);
sLog.outErrorDb("`game_event` game event id (%i) have length 0 and can't be used.", event_id);
continue;
}

if(pGameEvent.holiday_id != HOLIDAY_NONE)
if (pGameEvent.occurence < pGameEvent.length) // occurence < length is useless. This also asserts that occurence > 0!
{
if(!sHolidaysStore.LookupEntry(pGameEvent.holiday_id))
sLog.outErrorDb("`game_event` game event id (%i) has occurence %u < length %u and can't be used.", event_id, pGameEvent.occurence, pGameEvent.length);
continue;
}

if (pGameEvent.holiday_id != HOLIDAY_NONE)
{
if (!sHolidaysStore.LookupEntry(pGameEvent.holiday_id))
{
sLog.outErrorDb("`game_event` game event id (%i) have nonexistent holiday id %u.",event_id,pGameEvent.holiday_id);
sLog.outErrorDb("`game_event` game event id (%i) have nonexistent holiday id %u.", event_id, pGameEvent.holiday_id);
pGameEvent.holiday_id = HOLIDAY_NONE;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "11962"
#define REVISION_NR "11963"
#endif // __REVISION_NR_H__

0 comments on commit 641e7ce

Please sign in to comment.