diff --git a/source/lib/sysdep/win/assert_dlg.rc b/source/lib/sysdep/win/assert_dlg.rc index 7cb777476e..46d70654ba 100755 --- a/source/lib/sysdep/win/assert_dlg.rc +++ b/source/lib/sysdep/win/assert_dlg.rc @@ -44,8 +44,8 @@ CAPTION "Program Error" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN PUSHBUTTON "&Continue",IDC_CONTINUE,7,239,50,14 - EDITTEXT IDC_EDIT1,7,7,314,204,ES_MULTILINE | ES_AUTOHSCROLL | - ES_READONLY | ES_WANTRETURN | WS_VSCROLL + EDITTEXT IDC_EDIT1,7,7,314,204,ES_MULTILINE | ES_READONLY | + ES_WANTRETURN | WS_VSCROLL PUSHBUTTON "Copy",IDC_COPY,271,212,50,14 PUSHBUTTON "&Suppress",IDC_SUPPRESS,59,239,50,14 PUSHBUTTON "&Break",IDC_BREAK,111,239,50,14 diff --git a/source/ps/Game.cpp b/source/ps/Game.cpp index 76dbd2e6e0..980e8a2fff 100755 --- a/source/ps/Game.cpp +++ b/source/ps/Game.cpp @@ -260,3 +260,31 @@ void CGame::Update(double deltaTime) // TODO Detect game over and bring up the summary screen or something } + + +CPlayer *CGame::GetPlayer(uint idx) +{ + if (idx > m_NumPlayers) + { + debug_warn("Invalid player ID"); + LOG(ERROR, "", "Invalid player ID %d (outside 0..%d)", idx, m_NumPlayers); + return m_Players[0]; + } + // Be a bit more paranoid - maybe m_Players hasn't been set large enough + else if (idx >= m_Players.size()) + { + debug_warn("Invalid player ID"); + LOG(ERROR, "", "Invalid player ID %d (not <=%d - internal error?)", idx, m_Players.size()); + + if (m_Players.size() == 0) + { + // Hmm. This is a bit of a problem. + assert2(! "### ### ### ### ERROR: Tried to access the players list when there aren't any players. That really isn't going to work, so I'll give up. ### ###"); + abort(); + } + else + return m_Players[0]; + } + else + return m_Players[idx]; +} diff --git a/source/ps/Game.h b/source/ps/Game.h index 0670e108eb..778c821035 100755 --- a/source/ps/Game.h +++ b/source/ps/Game.h @@ -99,6 +99,7 @@ public: inline void SetLocalPlayer(CPlayer *pLocalPlayer) { m_pLocalPlayer=pLocalPlayer; } +/* inline CPlayer *GetPlayer(uint idx) { if (idx >= 0 && idx <= m_NumPlayers) @@ -109,6 +110,11 @@ public: return m_Players[0]; } } +*/ + // PT: No longer inline, because it does too much error checking. When + // everything stops trying to access players before they're loaded, feel + // free to put the inline version back. + CPlayer *GetPlayer(uint idx); inline std::vector* GetPlayers() { return( &m_Players ); }