~widelands-dev/widelands/trunk

« back to all changes in this revision

Viewing changes to src/logic/queue_cmd_factory.cc

  • Committer: sigra
  • Date: 2010-01-04 03:32:50 UTC
  • Revision ID: git-v1:82d9f24adcbde7d19f90434aac5f96c7df58aa10
Fix bug #2924988 (crash when initialization removed between game preload and game start) reported by qcs - Qcumber-some.

Before the game is set up, the tribes are preloaded, which means that it is checked which tribes exist and which initializations each tribe has, so that each player can select a tribe and an initialization. The selected initialization is saved as an index. When the game is finally started, the tribes are fully read. Then a player is initialized with the initialization with the stored index.

But if for example a player has selected the initialization with index 1, then the tribe is edited so that there is no initialization with that index (such as only the initialization with index 0 remains), then the game i started, the tribe fully read, the player initialized with initialization 1, an assertion will fail in debug builds (and an out-of-range access will be done in release builds.

Now throw game_data_error when this happens. Of course it may still behave a bit unexpected if a player selects initialization a with index 0 and then initializaion a is removed and initialization b has index 0, but at least a crash is fixed.

Also make donkey breeding less broken.

git-svn-id: https://widelands.svn.sourceforge.net/svnroot/widelands/trunk@4870 37b2a8de-5219-0410-9f54-a31bc463ab9c

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2002-2004, 2008-2009 by the Widelands Development Team
 
2
 * Copyright (C) 2002-2004, 2008-2010 by the Widelands Development Team
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or
5
5
 * modify it under the terms of the GNU General Public License
56
56
                return *new Cmd_EnemyFlagAction      ();
57
57
        case QUEUE_CMD_SETWAREPRIORITY:
58
58
                return *new Cmd_SetWarePriority      ();
59
 
        case QUEUE_CMD_SETTARGETQUANTITY:
60
 
                return *new Cmd_SetTargetQuantity    ();
61
 
        case QUEUE_CMD_RESETTARGETQUANTITY:
62
 
                return *new Cmd_ResetTargetQuantity  ();
 
59
        case QUEUE_CMD_SETWARETARGETQUANTITY:
 
60
                return *new Cmd_SetWareTargetQuantity    ();
 
61
        case QUEUE_CMD_RESETWARETARGETQUANTITY:
 
62
                return *new Cmd_ResetWareTargetQuantity  ();
 
63
        case QUEUE_CMD_SETWORKERTARGETQUANTITY:
 
64
                return *new Cmd_SetWorkerTargetQuantity  ();
 
65
        case QUEUE_CMD_RESETWORKERTARGETQUANTITY:
 
66
                return *new Cmd_ResetWorkerTargetQuantity();
63
67
        case QUEUE_CMD_DESTROY_MAPOBJECT:
64
68
                return *new Cmd_Destroy_Map_Object   ();
65
69
        case QUEUE_CMD_ACT: