Minimap: refactor if() spanning 200 lines into if(!) return

cause of minimap click no longer working has been found:
GlobalInputHandler isn't getting called due to incorrect order of
registration. fix is pending.

game: add code from ScEd that fixes lack of player color (by setting up
local players)
thanks to Simon for finding the cause (I want that crystal ball :D)

This was SVN commit r2967.
This commit is contained in:
janwas 2005-10-19 06:11:21 +00:00
parent 5213ca6f56
commit 02341916dc
6 changed files with 237 additions and 232 deletions

View File

@ -61,8 +61,9 @@ void CMiniMap::Draw()
{
// The terrain isn't actually initialized until the map is loaded, which
// happens when the game is started
if(GetGUI() && g_Game && g_Game->IsGameStarted())
{
if(!(GetGUI() && g_Game && g_Game->IsGameStarted()))
return;
// Set our globals in case they hadn't been set before
m_Terrain = g_Game->GetWorld()->GetTerrain();
m_UnitManager = g_Game->GetWorld()->GetUnitManager();
@ -180,13 +181,13 @@ void CMiniMap::Draw()
CCamera &g_Camera=*g_Game->GetView()->GetCamera();
//Check for a click
if(g_mouse_buttons[0]==true)
if(g_mouse_buttons[SDL_BUTTON_LEFT]==true)
{
HasClicked=true;
}
//Check to see if left button is false (meaning it's been lifted)
if (g_mouse_buttons[0]==false && HasClicked==true)
if (g_mouse_buttons[SDL_BUTTON_LEFT]==false && HasClicked==true)
{
@ -232,7 +233,7 @@ void CMiniMap::Draw()
HasClicked=false;
}
//END OF INTERACTIVE MINIMAP
//====================================================================
//====================================================================
// render view rect : John M. Mena
// This sets up and draws the rectangle on the mini-map
@ -291,7 +292,6 @@ void CMiniMap::Draw()
glEnable(GL_TEXTURE_2D);
glDisable(GL_POINT_SMOOTH);
glEnable(GL_DEPTH_TEST);
}
}
void CMiniMap::CreateTextures()

View File

@ -248,15 +248,16 @@ static void Frame()
static void MainControllerInit()
{
// add additional input handlers only needed by this controller.
// add additional input handlers only needed by this controller:
// gui_handler needs to be after (i.e. called before!) the hotkey handler
// so that input boxes can be typed in without setting off hotkeys.
// gui_handler needs to be registered after (i.e. called before!) the
// hotkey handler so that input boxes can be typed in without
// setting off hotkeys.
#ifndef NO_GUI
in_add_handler(gui_handler);
#endif
// must be after gui_handler. Should mayhap even be last.
// must be registered after gui_handler. Should mayhap even be last.
in_add_handler(MainInputHandler);
}
@ -286,7 +287,6 @@ int main(int argc, char* argv[])
ATLAS_RunIfOnCmdLine(argc, argv);
// ELSE
Init(argc, argv, true, true);
MainControllerInit();

View File

@ -95,6 +95,11 @@ PSRETURN CGame::StartGame(CGameAttributes *pAttribs)
{
try
{
// JW: this loop is taken from ScEd and fixes lack of player color.
// TODO: determine proper number of players.
for (int i=1; i<8; ++i)
pAttribs->GetSlot(i)->AssignLocal();
pAttribs->FinalizeSlots();
m_NumPlayers=pAttribs->GetSlotCount();

View File

@ -39,7 +39,7 @@ int GlobalsInputHandler(const SDL_Event* ev)
{
// don't complain: this happens when the hotkey system
// spoofs keys (it assigns values starting from SDLK_LAST)
//debug_warn("MainInputHandler: invalid key");
//debug_warn(__func__": invalid key");
}
return EV_PASS;
@ -49,7 +49,7 @@ int GlobalsInputHandler(const SDL_Event* ev)
if(c < ARRAY_SIZE(g_mouse_buttons))
g_mouse_buttons[c] = (ev->type == SDL_MOUSEBUTTONDOWN);
else
debug_warn("MainInputHandler: invalid mouse button");
debug_warn(__func__": invalid mouse button");
return EV_PASS;
default:

View File

@ -108,7 +108,7 @@ int LDR_Register(LoadFunc func, void* param, const wchar_t* description,
{
if(state != REGISTERING)
{
debug_warn("LDR_Register: not called between LDR_(Begin|End)Register - why?!");
debug_warn(__func__": not called between LDR_(Begin|End)Register - why?!");
// warn here instead of relying on the caller to CHECK_ERR because
// there will be lots of call sites spread around.
return -1;
@ -128,7 +128,7 @@ int LDR_EndRegistering()
return -1;
if(load_requests.empty())
debug_warn("LDR_EndRegistering: no LoadRequests queued");
debug_warn(__func__": no LoadRequests queued");
state = FIRST_LOAD;
estimated_duration_tally = 0.0;
@ -317,7 +317,7 @@ int LDR_NonprogressiveLoad()
switch(ret)
{
case 0:
debug_warn("LDR_NonprogressiveLoad: No load in progress");
debug_warn(__func__": No load in progress");
return 0; // success
case LDR_ALL_FINISHED:
return 0; // success

View File

@ -95,7 +95,7 @@ int VFSUtil::EnumDirEnts(const CStr start_path, int flags, const char* user_filt
Handle hdir = vfs_dir_open(path);
if(hdir <= 0)
{
debug_warn("EnumFiles: vfs_open_dir failed");
debug_warn(__func__": vfs_open_dir failed");
continue;
}