From 5e28c4bebf6e1fa14f131792bd8d5945b3a27d8d Mon Sep 17 00:00:00 2001 From: Matei Date: Sun, 17 Sep 2006 02:49:29 +0000 Subject: [PATCH] - Fixed a bug with aura rendering that was causing a crash when rendering auras that were added to a unit after its creation (initAuraData was not called on subsequent AddAura calls). This caused objects like Settlements, Mills, Farmsteads and Temples to crash when you mouseover them since they do not gain the aura until construction is complete. - When the map contains no territories, ignore territory-related building placement rules. Fixes #149. This was SVN commit r4349. --- source/ps/Interact.cpp | 8 +++++--- source/simulation/Entity.cpp | 1 - source/simulation/EntityScriptInterface.cpp | 5 +++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/source/ps/Interact.cpp b/source/ps/Interact.cpp index 444823e373..122a2463ee 100644 --- a/source/ps/Interact.cpp +++ b/source/ps/Interact.cpp @@ -1499,10 +1499,12 @@ void CBuildingPlacer::update( float timeStep ) if( pTerrain->isOnMap( pos.X, pos.Z ) ) { // Check that we are being placed in a valid territory; currently, m_territoryRestriction - // can be either "Allied" for placing in allied territories, or nothing. Since there's no - // diplomacy yet, "allied" just means "owned by us" for now. + // can be either "Allied" for placing in allied territories, or nothing. + // Special case: If the territory has no centre unit, that means the map contains no + // Settlements; for testing purposes, let us build anywhere. CTerritory* territory = g_Game->GetWorld()->GetTerritoryManager()->GetTerritory( pos.X, pos.Z ); - if( m_template->m_territoryRestriction == L"Allied" && territory->owner != g_Game->GetLocalPlayer() ) + if( m_template->m_territoryRestriction == L"Allied" && territory->centre + && territory->owner != g_Game->GetLocalPlayer() ) { m_valid = false; } diff --git a/source/simulation/Entity.cpp b/source/simulation/Entity.cpp index 8057a0aa9e..68597d4117 100644 --- a/source/simulation/Entity.cpp +++ b/source/simulation/Entity.cpp @@ -680,7 +680,6 @@ bool CEntity::Initialize() kill(); return false; } - initAuraData(); return true; } diff --git a/source/simulation/EntityScriptInterface.cpp b/source/simulation/EntityScriptInterface.cpp index 9921a80a13..7d0f07ec20 100644 --- a/source/simulation/EntityScriptInterface.cpp +++ b/source/simulation/EntityScriptInterface.cpp @@ -559,6 +559,8 @@ jsval CEntity::AddAura( JSContext* cx, uintN argc, jsval* argv ) } m_auras[name] = new CAura( cx, this, name, radius, tickRate, color, handler ); + initAuraData(); + return JSVAL_VOID; } @@ -571,6 +573,9 @@ jsval CEntity::RemoveAura( JSContext* UNUSED(cx), uintN argc, jsval* argv ) delete m_auras[name]; m_auras.erase(name); } + + initAuraData(); + return JSVAL_VOID; }