1
0
forked from 0ad/0ad

Updated ScEd's handling of players (though in a rather nasty way, since it doesn't actually have a CGame, and so it has no CPlayers, and so there are loads of HACK comments everywhere)

This was SVN commit r1740.
This commit is contained in:
Ykkrosh 2005-01-18 12:45:56 +00:00
parent 9a2979edec
commit a410c2852c
9 changed files with 37 additions and 16 deletions

View File

@ -288,7 +288,12 @@ void CMapReader::ReadXML(const char* filename)
}
HEntity ent = g_EntityManager.create(g_EntityTemplateCollection.getTemplate(TemplateName), Position, Orientation);
ent->m_player = g_Game->GetPlayer( PlayerID );
#ifdef SCED // HACK: ScEd doesn't have a g_Game, so we can't use its CPlayers
ent->m_player = (CPlayer*)(intptr_t)PlayerID;
#else
ent->m_player = g_Game->GetPlayer( PlayerID );
#endif
}
}
else

View File

@ -279,7 +279,11 @@ void CMapWriter::WriteXML(const char* filename, CUnitManager* pUnitMan)
XML_Setting("Template", entity->m_base->m_Tag);
XML_Setting("Player", entity->m_player);
#ifdef SCED // HACK: ScEd doesn't have a g_Game, so we can't use its CPlayers
XML_Setting("Player", (int)(intptr_t)entity->m_player);
#else
XML_Setting("Player", entity->m_player);
#endif
{
CVector3D position = entity->m_position;

View File

@ -73,7 +73,7 @@ public:
{ m_pLocalPlayer=pLocalPlayer; }
inline CPlayer *GetPlayer(uint idx)
{ return m_Players[idx]; }
{ if (idx >= 0 && idx < m_NumPlayers) return m_Players[idx]; else { debug_warn("Invalid player ID"); return m_Players[0]; } }
inline std::vector<CPlayer*>* GetPlayers()
{ return( &m_Players ); }

View File

@ -20,7 +20,7 @@
#include "scripting/JSInterface_Vector3D.h"
// TODO: don't hardcode player-colours
static const float PlayerColours[8][3] = { {1,1,1}, {1,0,0}, {0,1,0}, {0,0,1}, {1,1,0}, {1,0,1}, {0,1,1}, {1,0.5,0} };
static const float PlayerColours[9][3] = { {1,1,1}, {1,0,0}, {0,1,0}, {0,0,1}, {1,1,0}, {1,0,1}, {0,1,1}, {1,0.5,0}, {1,0,0.5} };
CEntity::CEntity( CBaseEntity* base, CVector3D position, float orientation )
{
@ -71,7 +71,11 @@ CEntity::CEntity( CBaseEntity* base, CVector3D position, float orientation )
m_grouped = -1;
#ifdef SCED // HACK: ScEd doesn't have a g_Game, so we can't use its CPlayers
m_player = (CPlayer*)0;
#else
m_player = g_Game->GetPlayer( 0 );
#endif
}
CEntity::~CEntity()
@ -514,8 +518,12 @@ void CEntity::renderSelectionOutline( float alpha )
glColor4f( 1.0f, 0.5f, 0.5f, alpha );
else
{
#ifdef SCED // HACK: ScEd doesn't have a g_Game, so we can't use its CPlayers
glColor3fv(PlayerColours[ (intptr_t)m_player ]);
#else
SColour& col = m_player->m_Colour;
glColor3f( col.r, col.g, col.b );
#endif
}
glBegin( GL_LINE_LOOP );

View File

@ -42,7 +42,7 @@ void CPaintObjectCommand::Finalize()
CVector3D position = m_Unit->GetModel()->GetTransform().GetTranslation();
g_UnitMan.RemoveUnit(m_Unit);
HEntity ent = g_EntityManager.create( templateObject, position, atan2( -orient.X, -orient.Z ) );
ent->m_player = 1;
ent->m_player = (CPlayer*)1;
}
}

View File

@ -93,6 +93,7 @@ BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_COMMAND(IDR_UNIT_TOOLS, OnUnitTools)
ON_COMMAND(ID_RANDOM_MAP, OnRandomMap)
//}}AFX_MSG_MAP
ON_COMMAND(ID_PLAYER_PLAYER0, OnEntityPlayer0)
ON_COMMAND(ID_PLAYER_PLAYER1, OnEntityPlayer1)
ON_COMMAND(ID_PLAYER_PLAYER2, OnEntityPlayer2)
ON_COMMAND(ID_PLAYER_PLAYER3, OnEntityPlayer3)
@ -865,12 +866,12 @@ void CMainFrame::OnRandomMap()
}
#define P(n) void CMainFrame::OnEntityPlayer##n() { return OnEntityPlayerX(n); }
P(1) P(2) P(3) P(4) P(5) P(6) P(7) P(8)
P(0); P(1); P(2); P(3); P(4); P(5); P(6); P(7); P(8);
#undef P
void CMainFrame::OnEntityPlayerX(int x)
{
CEntity* entity = CSelectObjectTool::GetTool()->GetFirstEntity();
if (entity)
entity->m_player = x;
entity->m_player = (CPlayer*)(intptr_t)x; // HACK: ScEd doesn't have a g_Game, so we can't use its CPlayers
}

View File

@ -109,6 +109,7 @@ protected:
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnEntityPlayer0();
afx_msg void OnEntityPlayer1();
afx_msg void OnEntityPlayer2();
afx_msg void OnEntityPlayer3();

View File

@ -169,6 +169,7 @@ BEGIN
BEGIN
POPUP "&Player"
BEGIN
MENUITEM "Player &0", ID_PLAYER_PLAYER0
MENUITEM "Player &1", ID_PLAYER_PLAYER1
MENUITEM "Player &2", ID_PLAYER_PLAYER2
MENUITEM "Player &3", ID_PLAYER_PLAYER3

View File

@ -101,14 +101,15 @@
#define ID_TEST_GO 32798
#define ID_RANDOM_MAP 32799
#define ID_ENTITY_PLAYER 32800
#define ID_PLAYER_PLAYER1 32801
#define ID_PLAYER_PLAYER2 32802
#define ID_PLAYER_PLAYER3 32803
#define ID_PLAYER_PLAYER4 32804
#define ID_PLAYER_PLAYER5 32805
#define ID_PLAYER_PLAYER6 32806
#define ID_PLAYER_PLAYER7 32807
#define ID_PLAYER_PLAYER8 32808
#define ID_PLAYER_PLAYER0 32801
#define ID_PLAYER_PLAYER1 32802
#define ID_PLAYER_PLAYER2 32803
#define ID_PLAYER_PLAYER3 32804
#define ID_PLAYER_PLAYER4 32805
#define ID_PLAYER_PLAYER5 32806
#define ID_PLAYER_PLAYER6 32807
#define ID_PLAYER_PLAYER7 32808
#define ID_PLAYER_PLAYER8 32809
// Next default values for new objects
//
@ -116,7 +117,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 156
#define _APS_NEXT_COMMAND_VALUE 32809
#define _APS_NEXT_COMMAND_VALUE 32810
#define _APS_NEXT_CONTROL_VALUE 1044
#define _APS_NEXT_SYMED_VALUE 101
#endif