Skip to content

Commit

Permalink
Addonpart: Fixed beacons not working
Browse files Browse the repository at this point in the history
  • Loading branch information
ohlidalp committed Aug 1, 2024
1 parent cbb7225 commit e280850
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
35 changes: 35 additions & 0 deletions source/main/resources/addonpart_fileformat/AddonPartFileFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,41 @@ void AddonPartUtility::ProcessProp()
def.rotation.z = m_context->getTokFloat(8);

def.mesh_name = m_context->getTokString(9);
def.special = RigDef::Parser::IdentifySpecialProp(def.mesh_name);

switch (def.special)
{
case SpecialProp::BEACON:
if (n >= 14)
{
def.special_prop_beacon.flare_material_name = m_context->getTokString(10);
Ogre::StringUtil::trim(def.special_prop_beacon.flare_material_name);

def.special_prop_beacon.color = Ogre::ColourValue(
m_context->getTokFloat(11), m_context->getTokFloat(12), m_context->getTokFloat(13));
}
break;

case SpecialProp::DASHBOARD_LEFT:
case SpecialProp::DASHBOARD_RIGHT:
if (n > 10)
{
def.special_prop_dashboard.mesh_name = m_context->getTokString(10);
}
if (n > 13)
{
def.special_prop_dashboard.offset = Ogre::Vector3(m_context->getTokFloat(11), m_context->getTokFloat(12), m_context->getTokFloat(13));
def.special_prop_dashboard._offset_is_set = true;
}
if (n > 14)
{
def.special_prop_dashboard.rotation_angle = m_context->getTokFloat(14);
}
break;

default:
break;
}

m_module->props.push_back(def);
}
Expand Down
7 changes: 2 additions & 5 deletions source/main/resources/rig_def_fileformat/RigDef_Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2227,9 +2227,8 @@ void Parser::ParseProps()
prop.rotation.x = this->GetArgFloat (6);
prop.rotation.y = this->GetArgFloat (7);
prop.rotation.z = this->GetArgFloat (8);
// Attention - arg 9 evaluated twice!
prop.mesh_name = this->GetArgStr(9);
prop.special = this->GetArgSpecialProp(9);
prop.special = Parser::IdentifySpecialProp(prop.mesh_name);

if ((prop.special == SpecialProp::BEACON) && (m_num_args >= 14))
{
Expand Down Expand Up @@ -3287,10 +3286,8 @@ BitMask_t Parser::GetArgNodeOptions(int index)
return ret;
}

SpecialProp Parser::GetArgSpecialProp(int index)
SpecialProp Parser::IdentifySpecialProp(const std::string& str)
{
std::string str = this->GetArgStr(index);

if (str.find("leftmirror" ) != std::string::npos) { return SpecialProp::MIRROR_LEFT; }
if (str.find("rightmirror" ) != std::string::npos) { return SpecialProp::MIRROR_RIGHT; }
if (str.find("dashboard-rh") != std::string::npos) { return SpecialProp::DASHBOARD_RIGHT; }
Expand Down
2 changes: 1 addition & 1 deletion source/main/resources/rig_def_fileformat/RigDef_Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class Parser
// Common for truckfiles and addonparts:
static void ProcessForsetLine(RigDef::Flexbody& def, const std::string& line, int line_number = -1);
static Keyword IdentifyKeyword(const std::string& line);
static SpecialProp IdentifySpecialProp(const std::string& str);

private:

Expand Down Expand Up @@ -226,7 +227,6 @@ class Parser
BitMask_t GetArgShock2Options(int index);
BitMask_t GetArgShock3Options(int index);
BitMask_t GetArgNodeOptions (int index);
SpecialProp GetArgSpecialProp (int index);
EngineType GetArgEngineType (int index);
ManagedMaterialType GetArgManagedMatType(int index);

Expand Down

0 comments on commit e280850

Please sign in to comment.