patch to compile and run stratagus using VC2008 - ID: 2895148

Issue 2. unit.h: undefine NOUSER for VC2008
Fixes compiler error under VC2008.
Changes the code to undefine macro NOUSER in unit.h before including windows.h, otherwise clipboard related functions and structures will be undefined. Also removes duplicated and confusing windows.h includes in util.cpp.

Issue 4. unit_draw.cpp: memset caused access violation
Fixes acess violation when loading Wargus scripts at startup with stratagus RELEASE build.
Function DecorationCclRegister() in unit_draw.cpp use memset to re-initialize C++ object, which breaks internal data structures of STL vector. However, this access violation will only occur when compiled with VC2008 RELEASE profile.
Using vector's clear() method to re-initialize DecoSprite, replacing memset,

Issue 5. minimap.cpp: fix minimap
Fixes minimap showing wrong terrain when playing a game in Wargus.
Two different semantic are used inconsistently to calculate minimap index in minimap.cpp, One is mx + my, the onther is mx + my * Map.Info.MapWidth. This inconsistency causes cause minimap to show wrong terrain.
Changes the code in minimap.cpp to use the first semantic consistently.

Issue 7. loadcamp.cpp: Cleaning Order
Fixes access violation on exiting the game or close the game window directly in DEBUG build.  
Because stratagus.exe try to do a clean exit when compiled with DEBUG profile, which frees a bunch of allocated resources in loadcamp.cpp CleanModules(). But the order seems problematic, causing memory access violation when exits.
It seems that CleanUnitTypes() and CleanPlayers() must be called after CleanUnits(), since UnitType and Players structures are used when cleaning units.
    
Issue 8. mainloop.cpp: Parallel drawing     
Fixes keyboard and mouse issue in a Wargus game: user can't issue any command with keyboard or mouse after the game is started.      
Parallel drawing seems not working under Windows. When run stratagus under a dual-core processor, keyboard and mouse click event cannot be received by GameLogicLoop.       
Changes the code in mainloop.cpp to use only 1 cpu under WIN32.
This commit is contained in:
Pali Rohár 2010-08-03 16:51:57 +02:00
parent 6c82dc4874
commit 7b945d6c66
5 changed files with 10 additions and 8 deletions

View file

@ -89,12 +89,12 @@ void CleanModules(void)
CleanFonts();
CleanTriggers();
FreeAi();
CleanPlayers();
CleanRaces();
CleanConstructions();
CleanDecorations();
CleanUnitTypes();
CleanUnits();
CleanUnitTypes();
CleanPlayers();
CleanSelections();
CleanGroups();
CleanUpgrades();

View file

@ -38,6 +38,7 @@
----------------------------------------------------------------------------*/
#ifndef __unix
#undef NOUSER
#include <winsock2.h>
#include <windows.h>
#elif defined(__hpux)

View file

@ -87,7 +87,11 @@ int MouseScrollState = ScrollNone;
EventCallback GameCallbacks; /// Game callbacks
EventCallback EditorCallbacks; /// Editor callbacks
#ifdef USE_WIN32
const int CPU_NUM = 1;
#else
const int CPU_NUM = get_cpu_count();
#endif
static CMutex DisplayUpdateLocker;

View file

@ -37,11 +37,7 @@
#include "stratagus.h"
#include "util.h"
#ifdef USE_WIN32
#define WIN32_LEAN_AND_MEAN
#undef NOUSER
#include <windows.h>
#elif defined(HAVE_X)
#ifdef HAVE_X
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#endif

View file

@ -371,7 +371,8 @@ static int CclDefineSprites(lua_State *l)
*/
void DecorationCclRegister(void)
{
memset(&DecoSprite, 0, sizeof(DecoSprite));
DecoSprite.Name.clear();
DecoSprite.SpriteArray.clear();
lua_register(Lua, "DefineSprites", CclDefineSprites);
}