Added LOS setting to GameAttributes. Also fixed a small bug with LOS rendering (the patch's render data wasn't updated for LOS until the second frame after it became visible, displaying it in black for 1 frame).
This was SVN commit r2887.
This commit is contained in:
parent
e294e30c51
commit
faa6a78304
@ -195,6 +195,7 @@ CGameAttributes::CGameAttributes():
|
||||
|
||||
AddSynchedProperty(L"mapFile", &m_MapFile);
|
||||
AddSynchedProperty(L"numSlots", &m_NumSlots, &CGameAttributes::OnNumSlotsUpdate);
|
||||
AddSynchedProperty(L"losSetting", &m_LOSSetting);
|
||||
|
||||
m_Players.resize(9);
|
||||
for (int i=0;i<9;i++)
|
||||
|
@ -117,6 +117,8 @@ public:
|
||||
|
||||
CStrW m_MapFile;
|
||||
|
||||
uint m_LOSSetting;
|
||||
|
||||
private:
|
||||
friend JSBool PlayerSlotArray_JS::GetProperty( JSContext* cx, JSObject* obj, jsval id, jsval* vp );
|
||||
|
||||
|
@ -844,9 +844,8 @@ void CPatchRData::Submit(CPatch* patch)
|
||||
// no renderdata for patch, create it now
|
||||
data=new CPatchRData(patch);
|
||||
patch->SetRenderData(data);
|
||||
} else {
|
||||
data->Update();
|
||||
}
|
||||
data->Update();
|
||||
|
||||
m_Patches.push_back(patch);
|
||||
}
|
||||
|
@ -870,19 +870,19 @@ JSBool revealMap( JSContext* cx, JSObject* UNUSED(globalObject), uint argc, jsva
|
||||
REQUIRE_MIN_PARAMS( 0, revealMap );
|
||||
REQUIRE_MAX_PARAMS( 1, revealMap );
|
||||
|
||||
bool newValue;
|
||||
uint newValue;
|
||||
if(argc == 0)
|
||||
{
|
||||
newValue = true;
|
||||
newValue = 2;
|
||||
}
|
||||
else if(!ToPrimitive( g_ScriptingHost.GetContext(), argv[0], newValue ))
|
||||
else if(!ToPrimitive( g_ScriptingHost.GetContext(), argv[0], newValue ) || newValue > 2 || newValue < 0)
|
||||
{
|
||||
JS_ReportError( cx, "Invalid boolean argument" );
|
||||
JS_ReportError( cx, "Invalid argument (should be 0, 1 or 2)" );
|
||||
*rval = JSVAL_VOID;
|
||||
return( JS_FALSE );
|
||||
}
|
||||
|
||||
g_Game->GetWorld()->GetLOSManager()->m_MapRevealed = newValue;
|
||||
g_Game->GetWorld()->GetLOSManager()->m_LOSSetting = newValue;
|
||||
*rval = JSVAL_VOID;
|
||||
return( JS_TRUE );
|
||||
}
|
||||
|
@ -13,16 +13,15 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
CLOSManager::CLOSManager()
|
||||
CLOSManager::CLOSManager() : m_LOSSetting(0), m_Explored(0), m_Visible(0)
|
||||
{
|
||||
m_MapRevealed = false;
|
||||
}
|
||||
|
||||
CLOSManager::~CLOSManager()
|
||||
{
|
||||
}
|
||||
|
||||
void CLOSManager::Initialize()
|
||||
void CLOSManager::Initialize(uint losSetting)
|
||||
{
|
||||
CTerrain* terrain = g_Game->GetWorld()->GetTerrain();
|
||||
int tilesPerSide = terrain->GetVerticesPerSide() - 1;
|
||||
@ -54,6 +53,9 @@ void CLOSManager::Initialize()
|
||||
// NOTE: this will have to be changed if we decide to use incremental LOS
|
||||
|
||||
Update();
|
||||
|
||||
// Set special LOS setting
|
||||
m_LOSSetting = losSetting;
|
||||
}
|
||||
|
||||
// NOTE: this will have to be changed if we decide to use incremental LOS
|
||||
@ -107,26 +109,20 @@ void CLOSManager::Update()
|
||||
|
||||
ELOSStatus CLOSManager::GetStatus(int tx, int tz, CPlayer* player)
|
||||
{
|
||||
// TODO: Make the mask depend on the player's diplomacy (just OR all his allies' masks)
|
||||
int mask = (1 << player->GetPlayerID());
|
||||
|
||||
if(m_MapRevealed)
|
||||
if((m_Visible[tx][tz] & mask) || m_LOSSetting == ALL_VISIBLE)
|
||||
{
|
||||
return LOS_VISIBLE;
|
||||
}
|
||||
else if((m_Explored[tx][tz] & mask) || m_LOSSetting == EXPLORED)
|
||||
{
|
||||
return LOS_EXPLORED;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_Visible[tx][tz] & mask)
|
||||
{
|
||||
return LOS_VISIBLE;
|
||||
}
|
||||
else if(m_Explored[tx][tz] & mask)
|
||||
{
|
||||
return LOS_EXPLORED;
|
||||
}
|
||||
else
|
||||
{
|
||||
return LOS_UNEXPLORED;
|
||||
}
|
||||
return LOS_UNEXPLORED;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,12 +47,16 @@ class CLOSManager : public Singleton<CLOSManager>
|
||||
// of a certain player that can see a certain tile if we want to use incremental LOS.
|
||||
|
||||
public:
|
||||
bool m_MapRevealed; // Set to true to ignore LOS
|
||||
static const int NORMAL = 0;
|
||||
static const int EXPLORED = 1;
|
||||
static const int ALL_VISIBLE = 2;
|
||||
|
||||
int m_LOSSetting;
|
||||
|
||||
CLOSManager();
|
||||
~CLOSManager();
|
||||
|
||||
void Initialize();
|
||||
void Initialize(uint losSetting); // 0 = normal, 1 = explored, 2 = all visible
|
||||
void Update();
|
||||
|
||||
// Get LOS status for a tile (in tile coordinates)
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "LOSManager.h"
|
||||
#include "Loader.h"
|
||||
#include "LoaderThunks.h"
|
||||
#include "GameAttributes.h"
|
||||
|
||||
#include "gui/CGUI.h"
|
||||
|
||||
@ -39,13 +40,13 @@ CSimulation::~CSimulation()
|
||||
g_SinglePlayerTurnManager=NULL;
|
||||
}
|
||||
|
||||
int CSimulation::Initialize(CGameAttributes* UNUSED(pAttribs))
|
||||
int CSimulation::Initialize(CGameAttributes* pAttribs)
|
||||
{
|
||||
m_pTurnManager->Initialize(m_pGame->GetNumPlayers());
|
||||
|
||||
g_EntityManager.InitializeAll();
|
||||
|
||||
m_pWorld->GetLOSManager()->Initialize();
|
||||
m_pWorld->GetLOSManager()->Initialize(pAttribs->m_LOSSetting);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -24,10 +24,11 @@ static void InitGame(std::wstring map)
|
||||
for (int i=1; i<8; ++i)
|
||||
g_GameAttributes.GetSlot(i)->AssignLocal();
|
||||
|
||||
// Make the whole world visible
|
||||
g_GameAttributes.m_LOSSetting = 2;
|
||||
|
||||
// Initialise the game:
|
||||
g_Game = new CGame();
|
||||
// Make the whole world visible
|
||||
g_Game->GetWorld()->GetLOSManager()->m_MapRevealed = true;
|
||||
}
|
||||
|
||||
static void StartGame()
|
||||
|
Loading…
Reference in New Issue
Block a user