diff --git a/build/premake/premake.lua b/build/premake/premake.lua index 78e570ddbd..7f18951315 100755 --- a/build/premake/premake.lua +++ b/build/premake/premake.lua @@ -72,15 +72,15 @@ function setuppackage (projectname) "terrain", "sound", "scripting", - "i18n", - - "tools/atlas/GameInterface", - "tools/atlas/GameInterface/Handlers" + "i18n" } if (projectname ~= "sced") then tconcat(source_dirs, { "gui", - "gui/scripting" + "gui/scripting", + + "tools/atlas/GameInterface", + "tools/atlas/GameInterface/Handlers" }) end if (projectname == "sced") then tconcat(source_dirs, { diff --git a/source/ps/GameSetup/Config.cpp b/source/ps/GameSetup/Config.cpp index 83d63635b5..59ef72e3dc 100644 --- a/source/ps/GameSetup/Config.cpp +++ b/source/ps/GameSetup/Config.cpp @@ -111,11 +111,12 @@ static void ParseCommandLineArgs(int argc, char* argv[]) } break; case 'e': - g_EntGraph = true; + if(strncmp(name, "entgraph", 8) == 0) + g_EntGraph = true; break; case 'f': if(strncmp(name, "fixedframe", 10) == 0) - g_FixedFrameTiming=true; + g_FixedFrameTiming = true; break; case 'g': if(strncmp(name, "g=", 2) == 0) diff --git a/source/tools/atlas/Atlas.sln b/source/tools/atlas/Atlas.sln index a33276e939..4c3aa3b12e 100644 --- a/source/tools/atlas/Atlas.sln +++ b/source/tools/atlas/Atlas.sln @@ -70,6 +70,7 @@ Global {CDA14ADB-57CA-DB49-A474-E7605D7922BD}.Debug.ActiveCfg = Debug|Win32 {CDA14ADB-57CA-DB49-A474-E7605D7922BD}.Debug.Build.0 = Debug|Win32 {CDA14ADB-57CA-DB49-A474-E7605D7922BD}.Release.ActiveCfg = Release|Win32 + {CDA14ADB-57CA-DB49-A474-E7605D7922BD}.Release.Build.0 = Release|Win32 {CDA14ADB-57CA-DB49-A474-E7605D7922BD}.Testing.ActiveCfg = Testing|Win32 {CDA14ADB-57CA-DB49-A474-E7605D7922BD}.Testing.Build.0 = Testing|Win32 {8C9BF4E2-AE5A-4404-AD8A-0418508A737C}.Debug.ActiveCfg = Debug|Win32 diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp index a5a5920374..2634ef7c2f 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp @@ -247,6 +247,8 @@ ScenarioEditor::ScenarioEditor(wxWindow* parent) canvas->InitSize(); + ADD_COMMAND(GenerateMap(9)); + ADD_COMMAND(CommandString("render_enable")); #endif diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp index 7f1205c38c..5d644621d9 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp @@ -3,9 +3,23 @@ #include "Map.h" #include "ActionButton.h" +#include "Datafile.h" #include "GameInterface/Messages.h" +static void LoadMap() +{ + wxFileDialog dlg (NULL, wxFileSelectorPromptStr, Datafile::GetDataDirectory()+_T("/mods/official/maps/scenarios"), + _T(""), _T("PMP files (*.pmp)|*.pmp|All files (*.*)|*.*"), wxOPEN); + if (dlg.ShowModal() == wxID_OK) + { + std::wstring map = dlg.GetFilename().c_str(); + ADD_COMMAND(LoadMap(map)); + } + + // TODO: Make this a non-undoable command +} + static void GenerateMap() { ADD_COMMAND(GenerateMap(9)); @@ -14,5 +28,6 @@ static void GenerateMap() MapSidebar::MapSidebar(wxWindow* parent) : Sidebar(parent) { - m_MainSizer->Add(new ActionButton(this, _T("Generate Map"), &GenerateMap)); + m_MainSizer->Add(new ActionButton(this, _T("Load existing map"), &LoadMap)); + m_MainSizer->Add(new ActionButton(this, _T("Generate empty map"), &GenerateMap)); } diff --git a/source/tools/atlas/GameInterface/CommandProc.h b/source/tools/atlas/GameInterface/CommandProc.h index e54819a578..bdd4927d0d 100644 --- a/source/tools/atlas/GameInterface/CommandProc.h +++ b/source/tools/atlas/GameInterface/CommandProc.h @@ -58,9 +58,11 @@ struct DataCommand : public Command // so commands can optionally override (De|C #define END_COMMAND(t) \ }; \ - namespace CAT2(t, __LINE__) { struct init { init() { \ - bool notAlreadyRegisted = GetCmdHandlers().insert(std::pair("c"#t, &c##t ::Create)).second; \ - assert(notAlreadyRegisted); \ - } } init; }; + namespace register_command_##t { \ + struct init { init() { \ + bool notAlreadyRegisted = GetCmdHandlers().insert(std::pair("c"#t, &c##t ::Create)).second; \ + debug_assert(notAlreadyRegisted); \ + } } init; \ + }; } diff --git a/source/tools/atlas/GameInterface/Handlers/CameraCtrl.cpp b/source/tools/atlas/GameInterface/Handlers/CameraCtrl.cpp index 84794a2bc5..7321fab32b 100644 --- a/source/tools/atlas/GameInterface/Handlers/CameraCtrl.cpp +++ b/source/tools/atlas/GameInterface/Handlers/CameraCtrl.cpp @@ -8,19 +8,16 @@ namespace AtlasMessage { -void fScrollConstant(IMessage* msg) +MESSAGEHANDLER(ScrollConstant) { - mScrollConstant* cmd = static_cast(msg); - - if (cmd->dir < 0 || cmd->dir > 3) + if (msg->dir < 0 || msg->dir > 3) { debug_warn("ScrollConstant: invalid direction"); } else { - g_GameLoop->input.scrollSpeed[cmd->dir] = cmd->speed; + g_GameLoop->input.scrollSpeed[msg->dir] = msg->speed; } } -REGISTER(ScrollConstant); } diff --git a/source/tools/atlas/GameInterface/Handlers/Command.cpp b/source/tools/atlas/GameInterface/Handlers/Command.cpp index 635e3ed4b3..927c3277dd 100644 --- a/source/tools/atlas/GameInterface/Handlers/Command.cpp +++ b/source/tools/atlas/GameInterface/Handlers/Command.cpp @@ -7,15 +7,13 @@ namespace AtlasMessage { -void fDoCommand(IMessage* msg) +MESSAGEHANDLER(DoCommand) { - mDoCommand* cmd = static_cast(msg); - Command* c = NULL; - cmdHandlers::const_iterator it = GetCmdHandlers().find("c" + cmd->name); + cmdHandlers::const_iterator it = GetCmdHandlers().find("c" + msg->name); if (it != GetCmdHandlers().end()) { - c = (it->second)(cmd->data); + c = (it->second)(msg->data); } else { @@ -25,27 +23,24 @@ void fDoCommand(IMessage* msg) GetCommandProc().Submit(c); } -REGISTER(DoCommand); - -void fUndoCommand(IMessage*) +MESSAGEHANDLER(UndoCommand) { + UNUSED2(msg); GetCommandProc().Undo(); } -REGISTER(UndoCommand); - -void fRedoCommand(IMessage*) +MESSAGEHANDLER(RedoCommand) { + UNUSED2(msg); GetCommandProc().Redo(); } -REGISTER(RedoCommand); -void fMergeCommand(IMessage*) +MESSAGEHANDLER(MergeCommand) { + UNUSED2(msg); GetCommandProc().Merge(); } -REGISTER(MergeCommand); } diff --git a/source/tools/atlas/GameInterface/Handlers/GraphicsSetup.cpp b/source/tools/atlas/GameInterface/Handlers/GraphicsSetup.cpp index 8025b4a11e..d7dc4ef333 100644 --- a/source/tools/atlas/GameInterface/Handlers/GraphicsSetup.cpp +++ b/source/tools/atlas/GameInterface/Handlers/GraphicsSetup.cpp @@ -5,9 +5,6 @@ #include "renderer/Renderer.h" #include "gui/GUI.h" -#include "ps/Game.h" -#include "ps/GameAttributes.h" -#include "ps/Loader.h" #include "ps/CConsole.h" extern int g_xres, g_yres; @@ -19,7 +16,7 @@ extern void Shutdown_(); namespace AtlasMessage { -void fCommandString_init(IMessage*) +MESSAGEHANDLER_STR(init) { oglInit(); Init_(g_GameLoop->argc, g_GameLoop->argv, false); @@ -30,69 +27,46 @@ void fCommandString_init(IMessage*) if(oglHaveExtension("WGL_EXT_swap_control")) wglSwapIntervalEXT(1); #endif - - // Set attributes for the game: - // Start without a map - g_GameAttributes.m_MapFile = L""; - // Make all players locally controlled - for (int i=1; i<8; ++i) - g_GameAttributes.GetSlot(i)->AssignLocal(); - - // Start the game: - g_Game = new CGame(); - PSRETURN ret = g_Game->StartGame(&g_GameAttributes); - assert(ret == PSRETURN_OK); - LDR_NonprogressiveLoad(); - ret = g_Game->ReallyStartGame(); - assert(ret == PSRETURN_OK); } -REGISTER(CommandString_init); -void fCommandString_shutdown(IMessage*) +MESSAGEHANDLER_STR(shutdown) { Shutdown_(); g_GameLoop->rendering = false; } -REGISTER(CommandString_shutdown); -void fCommandString_exit(IMessage*) +MESSAGEHANDLER_STR(exit) { g_GameLoop->running = false; } -REGISTER(CommandString_exit); -void fCommandString_render_enable(IMessage*) +MESSAGEHANDLER_STR(render_enable) { g_GameLoop->rendering = true; } -REGISTER(CommandString_render_enable); -void fCommandString_render_disable(IMessage*) +MESSAGEHANDLER_STR(render_disable) { g_GameLoop->rendering = false; } -REGISTER(CommandString_render_disable); ////////////////////////////////////////////////////////////////////////// -void fSetContext(IMessage* msg) +MESSAGEHANDLER(SetContext) { - mSetContext* cmd = static_cast(msg); - g_GameLoop->glContext = cmd->context; + g_GameLoop->glContext = msg->context; Atlas_GLSetCurrent((void*)g_GameLoop->glContext); } -REGISTER(SetContext); -void fResizeScreen(IMessage* msg) +MESSAGEHANDLER(ResizeScreen) { - mResizeScreen* cmd = static_cast(msg); - g_xres = cmd->width; - g_yres = cmd->height; + g_xres = msg->width; + g_yres = msg->height; if (g_xres <= 2) g_xres = 2; // avoid GL errors caused by invalid sizes if (g_yres <= 2) g_yres = 2; // SViewPort vp; @@ -104,17 +78,13 @@ void fResizeScreen(IMessage* msg) g_GUI.UpdateResolution(); g_Console->UpdateScreenSize(g_xres, g_yres); } -REGISTER(ResizeScreen); ////////////////////////////////////////////////////////////////////////// -void fRenderStyle(IMessage* msg) +MESSAGEHANDLER(RenderStyle) { - mRenderStyle* cmd = static_cast(msg); - - g_Renderer.SetTerrainRenderMode(cmd->wireframe ? EDGED_FACES : SOLID); - g_Renderer.SetModelRenderMode(cmd->wireframe ? EDGED_FACES : SOLID); + g_Renderer.SetTerrainRenderMode(msg->wireframe ? EDGED_FACES : SOLID); + g_Renderer.SetModelRenderMode(msg->wireframe ? EDGED_FACES : SOLID); } -REGISTER(RenderStyle); } diff --git a/source/tools/atlas/GameInterface/Handlers/Map.cpp b/source/tools/atlas/GameInterface/Handlers/Map.cpp index 46b87562c3..82e325470b 100644 --- a/source/tools/atlas/GameInterface/Handlers/Map.cpp +++ b/source/tools/atlas/GameInterface/Handlers/Map.cpp @@ -6,26 +6,52 @@ #include "graphics/TextureManager.h" #include "graphics/TextureEntry.h" #include "ps/Game.h" +#include "ps/GameAttributes.h" +#include "ps/Loader.h" namespace AtlasMessage { - -void fGenerateMap(IMessage* msg) +static void InitGame(std::wstring map) { - mGenerateMap* cmd = static_cast(msg); + if (g_Game) + delete g_Game; + + // Set attributes for the game: + // Start without a map + g_GameAttributes.m_MapFile = map; + // Make all players locally controlled + for (int i=1; i<8; ++i) + g_GameAttributes.GetSlot(i)->AssignLocal(); + + // Start the game: + g_Game = new CGame(); + PSRETURN ret = g_Game->StartGame(&g_GameAttributes); + debug_assert(ret == PSRETURN_OK); + LDR_NonprogressiveLoad(); + ret = g_Game->ReallyStartGame(); + debug_assert(ret == PSRETURN_OK); + + // Make sure entities get rendered in the correct location + g_Game->GetSimulation()->Update(0.0); +} + +MESSAGEHANDLER(GenerateMap) +{ + InitGame(L""); // Convert size in patches to number of vertices - int vertices = cmd->size * PATCH_SIZE + 1; + int vertices = msg->size * PATCH_SIZE + 1; // Generate flat heightmap u16* heightmap = new u16[vertices*vertices]; for (int z = 0; z < vertices; ++z) for (int x = 0; x < vertices; ++x) - heightmap[x + z*vertices] = 32768 +(int)(2048.f*(rand()/(float)RAND_MAX-0.5f)); +// heightmap[x + z*vertices] = 32768 +(int)(2048.f*(rand()/(float)RAND_MAX-0.5f)); + heightmap[x + z*vertices] = 32768; // Initialise terrain using the heightmap CTerrain* terrain = g_Game->GetWorld()->GetTerrain(); - terrain->Initialize(cmd->size, heightmap); + terrain->Initialize(msg->size, heightmap); delete[] heightmap; @@ -47,6 +73,10 @@ void fGenerateMap(IMessage* msg) } } -REGISTER(GenerateMap); + +MESSAGEHANDLER(LoadMap) +{ + InitGame(msg->filename); +} } diff --git a/source/tools/atlas/GameInterface/Handlers/MessageHandler.h b/source/tools/atlas/GameInterface/Handlers/MessageHandler.h index e3fcaddcb8..05e23b8ce3 100644 --- a/source/tools/atlas/GameInterface/Handlers/MessageHandler.h +++ b/source/tools/atlas/GameInterface/Handlers/MessageHandler.h @@ -12,13 +12,30 @@ typedef void (*msgHandler)(IMessage*); typedef std::map msgHandlers; extern msgHandlers& GetMsgHandlers(); -#define CAT1(a,b) a##b -#define CAT2(a,b) CAT1(a,b) +#define MESSAGEHANDLER(t) \ + void f##t(m##t*); \ + namespace register_handler_##t { \ + void wrapper(IMessage* msg) { \ + f##t (static_cast(msg)); \ + } \ + struct init { init() { \ + bool notAlreadyRegisted = GetMsgHandlers().insert(std::pair(#t, &wrapper)).second; \ + debug_assert(notAlreadyRegisted); \ + } } init; \ + }; \ + void f##t(m##t* msg) -// TODO quite urgently: Fix this, because it's broken and not very helpful anyway -#define REGISTER(t) namespace CAT2(hndlr_, __LINE__) { struct init { init() { \ - bool notAlreadyRegisted = GetMsgHandlers().insert(std::pair(#t, &f##t)).second; \ - assert(notAlreadyRegisted); \ - } } init; }; +#define MESSAGEHANDLER_STR(t) \ + void fCommandString_##t(); \ + namespace register_handler_##t { \ + void wrapper(IMessage*) { \ + fCommandString_##t (); \ + } \ + struct init { init() { \ + bool notAlreadyRegisted = GetMsgHandlers().insert(std::pair("CommandString_"#t, &wrapper)).second; \ + debug_assert(notAlreadyRegisted); \ + } } init; \ + }; \ + void fCommandString_##t() } diff --git a/source/tools/atlas/GameInterface/Messages.h b/source/tools/atlas/GameInterface/Messages.h index 4dd55c9dad..3083041c1f 100644 --- a/source/tools/atlas/GameInterface/Messages.h +++ b/source/tools/atlas/GameInterface/Messages.h @@ -106,6 +106,11 @@ COMMAND(GenerateMap) const int size; // size in number of patches }; +COMMAND(LoadMap) + mLoadMap(std::wstring filename_) : filename(filename_) {} + const std::wstring filename; +}; + ////////////////////////////////////////////////////////////////////////// COMMAND(RenderStyle) diff --git a/source/tools/autobuild/buildd.pl b/source/tools/autobuild/buildd.pl index 700ab1ebc6..b6f8bde711 100644 --- a/source/tools/autobuild/buildd.pl +++ b/source/tools/autobuild/buildd.pl @@ -15,7 +15,7 @@ use HTTP::Response; use Win32::Process; my $build_process; # stores Win32::Process handle -my $build_required = 0; # set by commits, cleared by builds +my $build_required = 0; # set by commits, cleared by builds; 1 for normal build, 2 for forced build (even if no source was changed) my $commit_required = 0; # stores the time when it should happen, or 0 if never my $build_start_time; # time that the most recent build started my $last_exit_code; # exit code of the most recent completed build @@ -60,6 +60,13 @@ POE::Component::Server::TCP->new( $response->push_header('Content-type', 'text/plain'); $response->content("Build initiated."); } + elsif ($url eq '/force_build.html') + { + $build_required = 2; + abort_build(); + $response->push_header('Content-type', 'text/plain'); + $response->content("Forced build initiated."); + } elsif ($url eq '/commit_latest.html') { $commit_required = time(); @@ -212,7 +219,7 @@ POE::Session->create( if ($build_required and not $build_active) { - start_build(); + start_build(force => ($build_required == 2)); } elsif ($commit_required and time() >= $commit_required) { @@ -263,7 +270,7 @@ sub start_build Win32::Process::Create( $build_process, "c:\\perl\\bin\\perl.exe", - "perl build.pl" . ($params{commit} ? ' --commitlatest' : ''), + "perl build.pl" . ($params{commit} ? ' --commitlatest' : '') . ($params{force} ? ' --force' : ''), 0, CREATE_NO_WINDOW, "c:\\0ad\\autobuild") or die "Error spawning build script: ".Win32::FormatMessage(Win32::GetLastError());