Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions GeneralsMD/Code/GameEngine/Include/Common/INI.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,12 @@ class INI
static void parseObjectReskinDefinition( INI *ini );
static void parseObjectExtendDefinition( INI* ini );
static void parseWeaponTemplateDefinition( INI *ini );
static void parseWeaponExtendTemplateDefinition(INI* ini);
static void parseScienceDefinition( INI *ini );
static void parseRankDefinition( INI *ini );
static void parseCrateTemplateDefinition( INI *ini );
static void parseLocomotorTemplateDefinition( INI *ini );
static void parseLocomotorExtendTemplateDefinition( INI *ini );
static void parseLanguageDefinition( INI *ini );
static void parsePlayerTemplateDefinition( INI *ini );
static void parseGameDataDefinition( INI *ini );
Expand Down
1 change: 1 addition & 0 deletions GeneralsMD/Code/GameEngine/Include/GameLogic/Locomotor.h
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ class LocomotorStore : public SubsystemInterface


static void parseLocomotorTemplateDefinition(INI* ini);
static void parseLocomotorExtendTemplateDefinition(INI* ini);

protected:

Expand Down
3 changes: 3 additions & 0 deletions GeneralsMD/Code/GameEngine/Include/GameLogic/Weapon.h
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,8 @@ class WeaponTemplate : public MemoryPoolObject
/// field table for loading the values from an INI
const FieldParse* getFieldParse() const { return TheWeaponTemplateFieldParseTable; }

void copy_from(const WeaponTemplate& other);

/**
fire the weapon. return the logic-frame in which the damage will be dealt.

Expand Down Expand Up @@ -973,6 +975,7 @@ class WeaponStore : public SubsystemInterface
void handleProjectileDetonation( const WeaponTemplate* w, const Object *source, const Coord3D* pos, WeaponBonusConditionFlags extraBonusFlags, Bool inflictDamage = TRUE );

static void parseWeaponTemplateDefinition(INI* ini);
static void parseWeaponExtendTemplateDefinition(INI* ini);

protected:

Expand Down
6 changes: 4 additions & 2 deletions GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ static const BlockParse theTypeTable[] =
{ "GameData", INI::parseGameDataDefinition },
{ "InGameUI", INI::parseInGameUIDefinition },
{ "Locomotor", INI::parseLocomotorTemplateDefinition },
{ "LocomotorExtend", INI::parseLocomotorExtendTemplateDefinition },
{ "Language", INI::parseLanguageDefinition },
{ "MapCache", INI::parseMapCacheDefinition },
{ "MapData", INI::parseMapDataDefinition },
Expand Down Expand Up @@ -134,9 +135,10 @@ static const BlockParse theTypeTable[] =
{ "Upgrade", INI::parseUpgradeDefinition },
{ "Video", INI::parseVideoDefinition },
{ "WaterSet", INI::parseWaterSettingDefinition },
{ "WaterTransparency", INI::parseWaterTransparencyDefinition},
{ "Weather", INI::parseWeatherDefinition},
{ "WaterTransparency", INI::parseWaterTransparencyDefinition },
{ "Weather", INI::parseWeatherDefinition },
{ "Weapon", INI::parseWeaponTemplateDefinition },
{ "WeaponExtend", INI::parseWeaponExtendTemplateDefinition },
{ "WebpageURL", INI::parseWebpageURLDefinition },
{ "HeaderTemplate", INI::parseHeaderTemplateDefinition },
{ "StaticGameLOD", INI::parseStaticGameLODDefinition },
Expand Down
5 changes: 5 additions & 0 deletions GeneralsMD/Code/GameEngine/Source/Common/INI/INIWeapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,9 @@ void INI::parseWeaponTemplateDefinition( INI* ini )
WeaponStore::parseWeaponTemplateDefinition(ini);
}

void INI::parseWeaponExtendTemplateDefinition(INI* ini)
{
WeaponStore::parseWeaponExtendTemplateDefinition(ini);
}


50 changes: 50 additions & 0 deletions GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Locomotor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,12 +641,62 @@ LocomotorTemplate *LocomotorStore::newOverride( LocomotorTemplate *locoTemplate
TheLocomotorStore->m_locomotorTemplates[namekey] = loco;
}

void LocomotorStore::parseLocomotorExtendTemplateDefinition(INI* ini)
{
if (!TheLocomotorStore)
throw INI_INVALID_DATA;

Bool isOverride = false;
// read the Locomotor name
const char* token = ini->getNextToken();
NameKeyType namekey = NAMEKEY(token);

const char* token2 = ini->getNextToken();
NameKeyType parentKey = NAMEKEY(token2);

LocomotorTemplate* locoParent = TheLocomotorStore->findLocomotorTemplate(parentKey);
if (locoParent) {

LocomotorTemplate* loco = TheLocomotorStore->findLocomotorTemplate(namekey);
if (loco) {
if (ini->getLoadType() == INI_LOAD_CREATE_OVERRIDES) {
loco = TheLocomotorStore->newOverride((LocomotorTemplate*)loco->friend_getFinalOverride());
}
isOverride = true;
}
else {
loco = newInstance(LocomotorTemplate);
if (ini->getLoadType() == INI_LOAD_CREATE_OVERRIDES) {
loco->markAsOverride();
}
}
// copy all parent values
*loco = *locoParent;
loco->friend_setName(token);
ini->initFromINI(loco, loco->getFieldParse());
loco->validate();

// if this is an override, then we want the pointer on the existing named locomotor to point us
// to the override, so don't add it to the map.
if (!isOverride)
TheLocomotorStore->m_locomotorTemplates[namekey] = loco;
}
else {
DEBUG_CRASH(("LocomotorExtend '%s': parent '%s' does not exist", token, token2));
}
}

//-------------------------------------------------------------------------------------------------
/*static*/ void INI::parseLocomotorTemplateDefinition( INI* ini )
{
LocomotorStore::parseLocomotorTemplateDefinition(ini);
}

/*static*/ void INI::parseLocomotorExtendTemplateDefinition(INI* ini)
{
LocomotorStore::parseLocomotorExtendTemplateDefinition(ini);
}

//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
Expand Down
77 changes: 77 additions & 0 deletions GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,20 @@ void WeaponTemplate::reset( void )
m_historicDamage.clear();
}

void WeaponTemplate::copy_from(const WeaponTemplate& other) {
//Backup nextTemplate, name and namekey
WeaponTemplate* nextTempl = this->m_nextTemplate;
AsciiString name = this->m_name;
NameKeyType nameKey = this->m_nameKey;

// take all values from other
*this = other;

this->m_nextTemplate = nextTempl;
this->m_name = name;
this->m_nameKey = nameKey;
}

//-------------------------------------------------------------------------------------------------
/*static*/ void WeaponTemplate::parseWeaponBonusSet( INI* ini, void *instance, void * /*store*/, const void* /*userData*/ )
{
Expand Down Expand Up @@ -1936,6 +1950,69 @@ void WeaponStore::postProcessLoad()

}


//-------------------------------------------------------------------------------------------------
/*static*/ void WeaponStore::parseWeaponExtendTemplateDefinition(INI* ini)
{
AsciiString name;
AsciiString parent;

// read the weapon name
const char* c = ini->getNextToken();
name.set(c);

// read the parent name
const char* c2 = ini->getNextToken();
parent.set(c2);

// find parent if present
WeaponTemplate* parentWeapon = TheWeaponStore->findWeaponTemplatePrivate(TheNameKeyGenerator->nameToKey(parent));
if (parentWeapon)
{

// find existing item if present
WeaponTemplate* weapon = TheWeaponStore->findWeaponTemplatePrivate(TheNameKeyGenerator->nameToKey(name));
if (weapon)
{
if (ini->getLoadType() == INI_LOAD_CREATE_OVERRIDES)
weapon = TheWeaponStore->newOverride(weapon);
else
{
DEBUG_CRASH(("Weapon '%s' already exists, but OVERRIDE not specified", c));
return;
}

}
else
{
// no item is present, create a new one
weapon = TheWeaponStore->newWeaponTemplate(name);
}

//copy from parent
weapon->copy_from(*parentWeapon);

// parse the ini weapon definition
ini->initFromINI(weapon, weapon->getFieldParse());

if (weapon->m_projectileName.isNone())
weapon->m_projectileName.clear();

#if defined(RTS_DEBUG)
if (!weapon->getFireSound().getEventName().isEmpty() && weapon->getFireSound().getEventName().compareNoCase("NoSound") != 0)
{
DEBUG_ASSERTCRASH(TheAudio->isValidAudioEvent(&weapon->getFireSound()), ("Invalid FireSound %s in Weapon '%s'.", weapon->getFireSound().getEventName().str(), weapon->getName().str()));
}
#endif

}
else
{
DEBUG_CRASH(("Weapon '%s' cannot extend parrent '%s' as it not exists", c, c2));
}

}

//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ void W3DProjectedShadowManager::queueDecal(W3DProjectedShadow *shadow)
hmapVertex.X=(float)(i-borderSize)*MAP_XY_FACTOR;
hmapVertex.Z=__max((float)hmap->getHeight(i,j)*MAP_HEIGHT_SCALE,layerHeight);

if (TheGlobalData->m_heightAboveTerrainIncludesWater) {
if (TheGlobalData->m_heightAboveTerrainIncludesWater && TheTerrainLogic != nullptr) {
if (Real waterZ = 0; TheTerrainLogic->isUnderwater(hmapVertex.X, hmapVertex.Y, &waterZ)) {
if (waterZ > hmapVertex.Z) hmapVertex.Z = waterZ;
}
Expand All @@ -1066,7 +1066,7 @@ void W3DProjectedShadowManager::queueDecal(W3DProjectedShadow *shadow)
hmapVertex.X=(float)(i-borderSize)*MAP_XY_FACTOR;
hmapVertex.Z=(float)hmap->getHeight(i,j)*MAP_HEIGHT_SCALE+0.01f * MAP_XY_FACTOR;

if (TheGlobalData->m_heightAboveTerrainIncludesWater) {
if (TheGlobalData->m_heightAboveTerrainIncludesWater && TheTerrainLogic != nullptr) {
if (Real waterZ = 0; TheTerrainLogic->isUnderwater(hmapVertex.X, hmapVertex.Y, &waterZ)) {
if (waterZ > hmapVertex.Z) hmapVertex.Z = waterZ;
}
Expand Down