diff --git a/source/graphics/Terrain.cpp b/source/graphics/Terrain.cpp index 9263583aca..225acb4f0c 100644 --- a/source/graphics/Terrain.cpp +++ b/source/graphics/Terrain.cpp @@ -79,14 +79,20 @@ bool CTerrain::Initialize(u32 size,const u16* data) /////////////////////////////////////////////////////////////////////////////// +float CTerrain::getExactGroundLevel(const CVector2D& v) const +{ + return getExactGroundLevel(v.x, v.y); +} + bool CTerrain::isOnMap(const CVector2D& v) const { return isOnMap(v.x, v.y); } -float CTerrain::getExactGroundLevel(const CVector2D& v) const +bool CTerrain::isPassable(const CVector2D &tileSpaceLoc) const { - return getExactGroundLevel(v.x, v.y); + // TODO: Take into account the terrain type at this location + return true; } /////////////////////////////////////////////////////////////////////////////// diff --git a/source/graphics/Terrain.h b/source/graphics/Terrain.h index 3d0c088561..5f3bec46ca 100644 --- a/source/graphics/Terrain.h +++ b/source/graphics/Terrain.h @@ -54,8 +54,11 @@ public: return ((x >= 0.0f) && (x < (float)((m_MapSize-1) * CELL_SIZE)) && (z >= 0.0f) && (z < (float)((m_MapSize-1) * CELL_SIZE))); } + bool isOnMap(const CVector2D& v) const; + bool isPassable(const CVector2D& tileSpaceLoc) const; + void clampCoordToMap(int& index) const { if(index < 0) diff --git a/source/ps/GameAttributes.cpp b/source/ps/GameAttributes.cpp index b5d08d93b6..5a3c02c779 100644 --- a/source/ps/GameAttributes.cpp +++ b/source/ps/GameAttributes.cpp @@ -185,7 +185,9 @@ CGameAttributes::CGameAttributes(): m_MapFile("test01.pmp"), m_ResourceLevel("default"), m_StartingPhase("default"), - m_LOSSetting(2), + m_LOSSetting(0), + m_FogOfWar(true), + m_ScreenshotMode(false), m_NumSlots(8), m_UpdateCB(NULL), m_PlayerUpdateCB(NULL), @@ -204,6 +206,8 @@ CGameAttributes::CGameAttributes(): AddSynchedProperty(L"startingPhase", &m_StartingPhase); AddSynchedProperty(L"numSlots", &m_NumSlots, &CGameAttributes::OnNumSlotsUpdate); AddSynchedProperty(L"losSetting", &m_LOSSetting); + AddSynchedProperty(L"fogOfWar", &m_FogOfWar); + AddSynchedProperty(L"screenshotMode", &m_ScreenshotMode); CXeromyces XeroFile; if (XeroFile.Load("temp/players.xml") != PSRETURN_OK) diff --git a/source/ps/GameAttributes.h b/source/ps/GameAttributes.h index 09dac88ee2..acbac89c47 100644 --- a/source/ps/GameAttributes.h +++ b/source/ps/GameAttributes.h @@ -119,6 +119,8 @@ public: CStrW m_ResourceLevel; CStrW m_StartingPhase; uint m_LOSSetting; + bool m_FogOfWar; + bool m_ScreenshotMode; // Note: we must use the un-internationalized name of the resource level and starting phase diff --git a/source/ps/Interact.cpp b/source/ps/Interact.cpp index 50d32d4aa5..775e8e7495 100644 --- a/source/ps/Interact.cpp +++ b/source/ps/Interact.cpp @@ -863,7 +863,10 @@ void CMouseoverEntities::renderSelectionOutlines() std::vector::iterator it; for( it = m_mouseover.begin(); it < m_mouseover.end(); it++ ) - it->entity->renderSelectionOutline( it->fade ); + { + if( !g_Selection.isSelected(it->entity) ) + it->entity->renderSelectionOutline( it->fade ); + } glDisable( GL_BLEND ); } @@ -874,13 +877,19 @@ void CMouseoverEntities::renderAuras() glEnable(GL_BLEND); for ( it = m_mouseover.begin(); it != m_mouseover.end(); ++it ) - it->entity->renderAuras(); + { + if( !g_Selection.isSelected(it->entity) ) + it->entity->renderAuras(); + } } void CMouseoverEntities::renderBars() { std::vector::iterator it; for( it = m_mouseover.begin(); it < m_mouseover.end(); it++ ) - it->entity->renderBars(); + { + if( !g_Selection.isSelected(it->entity) ) + it->entity->renderBars(); + } } void CMouseoverEntities::renderHealthBars() diff --git a/source/scripting/ScriptGlue.cpp b/source/scripting/ScriptGlue.cpp index 549f2cf40a..a67a845bfb 100644 --- a/source/scripting/ScriptGlue.cpp +++ b/source/scripting/ScriptGlue.cpp @@ -264,7 +264,7 @@ JSBool issueCommand( JSContext* cx, JSObject*, uint argc, jsval* argv, jsval* rv for ( std::vector::iterator it=messages.begin(); it != messages.end(); it++ ) { - g_Console->InsertMessage(L"issueCommand: %hs", (*it)->GetString().c_str()); + //g_Console->InsertMessage(L"issueCommand: %hs", (*it)->GetString().c_str()); g_Game->GetSimulation()->QueueLocalCommand(*it); *rval = g_ScriptingHost.UCStringToValue((*it)->GetString()); } diff --git a/source/scripting/SynchedJSObject.cpp b/source/scripting/SynchedJSObject.cpp index ce9ddf1c86..a838bdfc98 100644 --- a/source/scripting/SynchedJSObject.cpp +++ b/source/scripting/SynchedJSObject.cpp @@ -28,12 +28,28 @@ void SetFromNetString(int &val, const CStrW& string) val=string.ToInt(); } +template <> +CStrW ToNetString(const bool &val) +{ + return val ? CStrW("true") : CStrW("false"); +} + +template <> +void SetFromNetString(bool &val, const CStrW& string) +{ + val = (string == CStrW("true")); +} + template <> CStrW ToNetString(const CStrW& data) -{ return data; } +{ + return data; +} template <> void SetFromNetString(CStrW& data, const CStrW& string) -{ data=string; } +{ + data=string; +} template <> CStrW ToNetString(const SColour &data) diff --git a/source/simulation/AStarEngine.cpp b/source/simulation/AStarEngine.cpp index 0907f580c4..483fff7323 100644 --- a/source/simulation/AStarEngine.cpp +++ b/source/simulation/AStarEngine.cpp @@ -366,11 +366,10 @@ bool AStarGoalLowLevel::isPassable( const CVector2D &loc, CPlayer* player ) return false; } - CVector2D wloc = TilespaceToWorldspace(loc); - float slope = pTerrain->getSlope(wloc.x, wloc.y); - if ( slope < MAXSLOPE ) + if ( pTerrain->isPassable(loc) ) { // If no entity blocking, return true + CVector2D wloc = TilespaceToWorldspace(loc); CBoundingBox bounds(wloc.x, wloc.y, 0, CELL_SIZE, CELL_SIZE, 3); if ( getCollisionObject(&bounds, player) == NULL ) { diff --git a/source/simulation/Entity.cpp b/source/simulation/Entity.cpp index 795f6a008e..e5cb994637 100644 --- a/source/simulation/Entity.cpp +++ b/source/simulation/Entity.cpp @@ -206,12 +206,12 @@ void CEntity::initAuraData() size_t i=0; for ( AuraTable::iterator it=m_auras.begin(); it!=m_auras.end(); ++it, ++i ) { - m_unsnappedPoints[i].resize(SELECTION_CIRCLE_POINTS); + m_unsnappedPoints[i].resize(AURA_CIRCLE_POINTS); float radius = it->second->m_radius; - for ( int j=0; jentf_get(ENTF_DESTROYED); } public: - + bool m_screenshotMode; + CEntityManager(); ~CEntityManager(); diff --git a/source/simulation/EntityRendering.cpp b/source/simulation/EntityRendering.cpp index 0c098b371c..f1b81ec785 100644 --- a/source/simulation/EntityRendering.cpp +++ b/source/simulation/EntityRendering.cpp @@ -225,13 +225,11 @@ void CEntity::renderAuras() if( !(m_bounds && m_visible && !m_auras.empty()) ) return; - const SPlayerColour& col = m_player->GetColour(); + const SPlayerColour& playerCol = m_player->GetColour(); glPushMatrix(); glTranslatef(m_graphics_position.X, m_graphics_position.Y, m_graphics_position.Z); - glBegin(GL_TRIANGLE_FAN); - glVertex3f(0.0f, getAnchorLevel(m_graphics_position.X, - m_graphics_position.Z)-m_graphics_position.Y+.5f, 0.0f); + size_t i=0; for ( AuraTable::iterator it=m_auras.begin(); it!=m_auras.end(); ++it, ++i ) @@ -243,7 +241,10 @@ void CEntity::renderAuras() //This starts to break when the radius is bigger if ( it->second->m_radius < 15.0f ) { - for ( int j=0; jsecond->m_radius < 15.0f ) { diff --git a/source/simulation/LOSManager.cpp b/source/simulation/LOSManager.cpp index 8eaca78510..012b67f165 100644 --- a/source/simulation/LOSManager.cpp +++ b/source/simulation/LOSManager.cpp @@ -15,7 +15,7 @@ #include "lib/timer.h" -CLOSManager::CLOSManager() : m_LOSSetting(0) +CLOSManager::CLOSManager() : m_LOSSetting(0), m_FogOfWar(true) { #ifdef _2_los m_Explored = 0; @@ -38,10 +38,11 @@ CLOSManager::~CLOSManager() #endif } -void CLOSManager::Initialize(uint losSetting) +void CLOSManager::Initialize(uint losSetting, bool fogOfWar) { // Set special LOS setting m_LOSSetting = losSetting; + m_FogOfWar = fogOfWar; CTerrain* terrain = g_Game->GetWorld()->GetTerrain(); m_TilesPerSide = terrain->GetVerticesPerSide() - 1; @@ -68,7 +69,7 @@ void CLOSManager::Initialize(uint losSetting) u16 vis_value = 0; if(m_LOSSetting == EXPLORED || m_LOSSetting == ALL_VISIBLE) for(int i = 0; i < 8; i++) vis_value |= LOS_EXPLORED << (i*2); - if(m_LOSSetting == ALL_VISIBLE) + if(m_LOSSetting == ALL_VISIBLE || (m_LOSSetting == EXPLORED && !m_FogOfWar) ) for(int i = 0; i < 8; i++) vis_value |= LOS_VISIBLE << (i*2); #endif for(uint x=0; xm_ScreenshotMode; g_EntityManager.InitializeAll(); // [2006-06-26: 61ms] - m_pWorld->GetLOSManager()->Initialize(pAttribs->m_LOSSetting); + m_pWorld->GetLOSManager()->Initialize(pAttribs->m_LOSSetting, pAttribs->m_FogOfWar); m_pWorld->GetTerritoryManager()->Initialize(); diff --git a/source/simulation/Stance.cpp b/source/simulation/Stance.cpp index d0047c2a85..c3fb44d56d 100644 --- a/source/simulation/Stance.cpp +++ b/source/simulation/Stance.cpp @@ -20,7 +20,8 @@ void CAggressStance::onIdle() void CAggressStance::onDamaged(CEntity *source) { - if( source && m_Entity->m_orderQueue.empty() ) + if( source && m_Entity->m_orderQueue.empty() + && m_Entity->GetPlayer()->GetDiplomaticStance(source->GetPlayer()) != DIPLOMACY_ALLIED ) CStanceUtils::attack( m_Entity, source ); } @@ -33,6 +34,13 @@ void CStandStance::onIdle() CStanceUtils::attack( m_Entity, target ); } +void CStandStance::onDamaged(CEntity *source) +{ + if( source && m_Entity->m_orderQueue.empty() + && m_Entity->GetPlayer()->GetDiplomaticStance(source->GetPlayer()) != DIPLOMACY_ALLIED ) + CStanceUtils::attack( m_Entity, source ); +} + // DefendStance ///////////////////////////////////////////////////// void CDefendStance::onIdle() @@ -46,7 +54,8 @@ void CDefendStance::onIdle() void CDefendStance::onDamaged(CEntity *source) { - if( source && m_Entity->m_orderQueue.empty() ) + if( source && m_Entity->m_orderQueue.empty() + && m_Entity->GetPlayer()->GetDiplomaticStance(source->GetPlayer()) != DIPLOMACY_ALLIED ) { // Retaliate only if we can reach the enemy unit without walking farther than our LOS // radius away from idlePos. diff --git a/source/simulation/Stance.h b/source/simulation/Stance.h index 2ac79b640b..c0a7409ba4 100644 --- a/source/simulation/Stance.h +++ b/source/simulation/Stance.h @@ -72,7 +72,7 @@ public: CStandStance(CEntity* ent): CStance(ent) {}; virtual ~CStandStance() {}; virtual void onIdle(); - virtual void onDamaged(CEntity* UNUSED(source)) {}; // Empty because onIdle will ensure we're attacking stuff in LOS + virtual void onDamaged(CEntity* source); virtual bool allowsMovement() { return false; }; virtual bool checkMovement(CVector2D UNUSED(proposedPos)) { return false; } }; diff --git a/source/tools/atlas/GameInterface/Handlers/MapHandlers.cpp b/source/tools/atlas/GameInterface/Handlers/MapHandlers.cpp index 8b259fe362..dc61dd0e47 100644 --- a/source/tools/atlas/GameInterface/Handlers/MapHandlers.cpp +++ b/source/tools/atlas/GameInterface/Handlers/MapHandlers.cpp @@ -32,6 +32,10 @@ static void InitGame(std::wstring map) // Make the whole world visible g_GameAttributes.m_LOSSetting = 2; + g_GameAttributes.m_FogOfWar = false; + + // Disable unit AI (and other things that may interfere with making things look nice) + g_GameAttributes.m_ScreenshotMode = true; // Initialise the game: g_Game = new CGame();