diff --git a/src/game/object/C4Def.cpp b/src/game/object/C4Def.cpp index 6ff0c4bc3..b66d2ebfc 100644 --- a/src/game/object/C4Def.cpp +++ b/src/game/object/C4Def.cpp @@ -47,7 +47,6 @@ void C4Def::DefaultDefCore() { rC4XVer[0]=rC4XVer[1]=rC4XVer[2]=rC4XVer[3]=0; RequireDef.Clear(); - Physical.Default(); Shape.Default(); Entrance.Default(); Collection.Default(); @@ -349,9 +348,6 @@ void C4Def::CompileFunc(StdCompiler *pComp) pComp->Value(mkNamingAdapt(mkBitfieldAdapt(AllowPictureStack, AllowPictureStackModes), "AllowPictureStack", 0 )); - - pComp->FollowName("Physical"); - pComp->Value(Physical); } //-------------------------------- C4Def ------------------------------------------------------- diff --git a/src/game/object/C4Def.h b/src/game/object/C4Def.h index 6e3183c0d..a12864281 100644 --- a/src/game/object/C4Def.h +++ b/src/game/object/C4Def.h @@ -124,7 +124,6 @@ public: C4ID id; int32_t rC4XVer[4]; C4IDList RequireDef; - C4PhysicalInfo Physical; C4Shape Shape; C4Rect Entrance; C4Rect Collection; diff --git a/src/game/object/C4InfoCore.cpp b/src/game/object/C4InfoCore.cpp index 24a423809..16844ca71 100644 --- a/src/game/object/C4InfoCore.cpp +++ b/src/game/object/C4InfoCore.cpp @@ -164,117 +164,6 @@ void C4PlayerInfoCore::CompileFunc(StdCompiler *pComp) } -//------------------------------- Physical Info ---------------------------------------- - -struct C4PhysInfoNameMap_t { const char *szName; C4PhysicalInfo::Offset off; } C4PhysInfoNameMap[] = -{ - { NULL, NULL } -}; - -C4PhysicalInfo::C4PhysicalInfo() -{ - Default(); -} - -void C4PhysicalInfo::Default() -{ - ZeroMem(this,sizeof(C4PhysicalInfo)); -} - -bool C4PhysicalInfo::GetOffsetByName(const char *szPhysicalName, Offset *pmpiOut) -{ - // query map - for (C4PhysInfoNameMap_t *entry = C4PhysInfoNameMap; entry->szName; ++entry) - if (SEqual(entry->szName, szPhysicalName)) - { - *pmpiOut = entry->off; - return true; - } - return false; -} - -const char *C4PhysicalInfo::GetNameByOffset(Offset mpiOff) -{ - // query map - for (C4PhysInfoNameMap_t *entry = C4PhysInfoNameMap; entry->szName; ++entry) - if (entry->off == mpiOff) - return entry->szName; - return NULL; -} - -const char *C4PhysicalInfo::GetNameByIndex(int32_t iIdx, Offset *pmpiOut) -{ - // query map - if (!Inside(iIdx, 0, int32_t(sizeof(C4PhysInfoNameMap)/sizeof(C4PhysInfoNameMap_t)))) return NULL; - if (pmpiOut) *pmpiOut = C4PhysInfoNameMap[iIdx].off; - return C4PhysInfoNameMap[iIdx].szName; -} - -void C4PhysicalInfo::CompileFunc(StdCompiler *pComp) -{ - for (C4PhysInfoNameMap_t *entry = C4PhysInfoNameMap; entry->szName; ++entry) - pComp->Value(mkNamingAdapt((this->*(entry->off)), entry->szName, 0)); -} - -bool C4PhysicalInfo::operator ==(const C4PhysicalInfo &cmp) const -{ - // all fields must be equal - for (C4PhysInfoNameMap_t *entry = C4PhysInfoNameMap; entry->szName; ++entry) - if (this->*(entry->off) != cmp.*(entry->off)) - return false; - return true; -} - -void C4TempPhysicalInfo::CompileFunc(StdCompiler *pComp) -{ - C4PhysicalInfo::CompileFunc(pComp); - pComp->Value(mkNamingAdapt( mkSTLContainerAdapt(Changes), "Changes", std::vector())); -} - -bool C4TempPhysicalInfo::HasChanges(C4PhysicalInfo *pRefPhysical) -{ - // always return true if there are temp changes - if (!Changes.empty()) return true; - // also return true if any value deviates from the reference - if (pRefPhysical) - { - if (!(*pRefPhysical == *this)) return true; - } - // no change known - return false; -} - -void C4TempPhysicalInfo::RegisterChange(C4PhysicalInfo::Offset mpiOffset) -{ - // append physical change to list - Changes.push_back(C4PhysicalChange(this->*mpiOffset, mpiOffset)); -} - -bool C4TempPhysicalInfo::ResetPhysical(C4PhysicalInfo::Offset mpiOffset) -{ - // search last matching physical check (should always be last if well scripted) - for (std::vector::reverse_iterator i = Changes.rbegin(); i != Changes.rend(); ++i) - if ((*i).mpiOffset == mpiOffset) - { - this->*mpiOffset = (*i).PrevVal; - Changes.erase((i+1).base()); - return true; - } - return false; -} - -void C4PhysicalChange::CompileFunc(StdCompiler *pComp) -{ - // name=oldval - char phyn[C4MaxName+1]; - const char *szPhyn = C4PhysicalInfo::GetNameByOffset(mpiOffset); - if (szPhyn) SCopy(szPhyn, phyn, C4MaxName); else *phyn='\0'; - pComp->Value(mkStringAdapt(phyn, C4MaxName, StdCompiler::RCT_Idtf)); - if (!C4PhysicalInfo::GetOffsetByName(phyn, &mpiOffset)) pComp->excNotFound("Physical change name \"%s\" not found."); - pComp->Separator(StdCompiler::SEP_SET); - pComp->Value(PrevVal); -} - //------------------------------- Object Info ---------------------------------------- C4ObjectInfoCore::C4ObjectInfoCore() @@ -323,9 +212,6 @@ void C4ObjectInfoCore::Default(C4ID n_id, } if (pDefs) UpdateCustomRanks(pDefs); - - // Physical - OldPhysical.Default(); } void C4ObjectInfoCore::Promote(int32_t iRank, C4RankSystem &rRanks, bool fForceRankName) @@ -433,9 +319,6 @@ void C4ObjectInfoCore::CompileFunc(StdCompiler *pComp) pComp->Value(mkNamingAdapt(TotalPlayingTime, "TotalPlayingTime", 0)); pComp->Value(mkNamingAdapt(Age, "Age", 0)); pComp->Value(mkNamingAdapt(ExtraData, "ExtraData", C4ValueMapData())); - - pComp->FollowName("Physical"); - pComp->Value(OldPhysical); } bool C4ObjectInfoCore::Compile(const char *szSource) diff --git a/src/game/object/C4InfoCore.h b/src/game/object/C4InfoCore.h index 7569d4fe2..8f3d2c489 100644 --- a/src/game/object/C4InfoCore.h +++ b/src/game/object/C4InfoCore.h @@ -30,68 +30,6 @@ const int32_t C4MaxPhysical = 100000, C4MaxDeathMsg = 75; -class C4PhysicalInfo -{ -public: - C4PhysicalInfo(); - - typedef int32_t C4PhysicalInfo::* Offset; - -public: - void Default(); - void PromotionUpdate(int32_t iRank, bool fUpdateTrainablePhysicals=false, class C4Def *pTrainDef=NULL); - void CompileFunc(StdCompiler *pComp); - - // conversion of physical names to member pointers and vice versa - static bool GetOffsetByName(const char *szPhysicalName, Offset *pmpiOut); - static const char *GetNameByOffset(Offset mpiOff); - const char *GetNameByIndex(int32_t iIdx, Offset *pmpiOut=NULL); - - // comparison - bool operator ==(const C4PhysicalInfo &cmp) const; -}; - -class C4PhysicalChange -{ -public: - int32_t PrevVal; - C4PhysicalInfo::Offset mpiOffset; - - C4PhysicalChange() : PrevVal(0), mpiOffset(NULL) {} - C4PhysicalChange(int32_t iPrevVal, C4PhysicalInfo::Offset mpiOffset) - : PrevVal(iPrevVal), mpiOffset(mpiOffset) {} - C4PhysicalChange(const C4PhysicalChange &rCpy) : PrevVal(rCpy.PrevVal), mpiOffset(rCpy.mpiOffset) {} - bool operator ==(const C4PhysicalChange &rCmp) const - { return PrevVal==rCmp.PrevVal && mpiOffset == rCmp.mpiOffset; } - C4PhysicalChange&operator =(const C4PhysicalChange &rSet) - { PrevVal=rSet.PrevVal; mpiOffset=rSet.mpiOffset; return *this; } - - void CompileFunc(StdCompiler *pComp); -}; - -class C4TempPhysicalInfo : public C4PhysicalInfo -{ -private: - // changes done to the original physicals; used for backtracing - std::vector Changes; - -public: - void Clear() - { - Changes.clear(); - } - void Default() { Clear(); C4PhysicalInfo::Default(); } // clears - void CompileFunc(StdCompiler *pComp); - - void RegisterChange(C4PhysicalInfo::Offset mpiOffset); // append physical change to list - bool ResetPhysical(C4PhysicalInfo::Offset mpiOffset); // undo given physical change - - bool HasChanges(C4PhysicalInfo *pRefPhysical); // return true if changes list is not empty - - C4PhysicalInfo &operator =(const C4PhysicalInfo &rSet) - { Clear(); static_cast(*this) = rSet; return *this; } -}; - class C4ObjectInfoCore { public: @@ -111,7 +49,6 @@ public: int32_t Age; char DeathMessage[C4MaxDeathMsg+1]; char PortraitFile[C4MaxName+2+4+1]; // used portrait - C4PhysicalInfo OldPhysical; C4ValueMapData ExtraData; bool NoSave; // set for _XYZ-CrewMembers public: @@ -185,9 +122,4 @@ public: void CompileFunc(StdCompiler *pComp); }; -inline C4Real ValByPhysical(int32_t iPercent, int32_t iPhysical) // get percentage of max physical value -{ - return itofix(iPhysical * (iPercent / 5),C4MaxPhysical * 20); -} - #endif diff --git a/src/game/object/C4Object.cpp b/src/game/object/C4Object.cpp index 74ea4a020..46513c69e 100644 --- a/src/game/object/C4Object.cpp +++ b/src/game/object/C4Object.cpp @@ -204,8 +204,6 @@ void C4Object::Default() Contained=NULL; TopFace.Default(); Menu=NULL; - PhysicalTemporary=false; - TemporaryPhysical.Default(); MaterialContents=NULL; Marker=0; ColorMod=0xffffffff; @@ -2093,14 +2091,6 @@ int32_t C4Object::GetValue(C4Object *pInBase, int32_t iForPlayer) return iValue; } -C4PhysicalInfo* C4Object::GetPhysical(bool fPermanent) -{ - // Temporary physical - if (PhysicalTemporary && !fPermanent) return &TemporaryPhysical; - // Definition physical - return &(Def->Physical); -} - bool C4Object::Promote(int32_t torank, bool exception, bool fForceRankName) { if (!Info) return false; @@ -2113,7 +2103,6 @@ bool C4Object::Promote(int32_t torank, bool exception, bool fForceRankName) pRankSys = &::DefaultRanks; // always promote info Info->Promote(torank,*pRankSys, fForceRankName); - Call(PSF_PhysicalChange,&C4AulParSet(C4VNull, C4VNull)); // silent update? if (!pRankSys->GetRankName(torank,false)) return false; GameMsgObject(FormatString(LoadResStr("IDS_OBJ_PROMOTION"),GetName (),Info->sRankName.getData()).getData(),this); @@ -2657,7 +2646,6 @@ void C4Object::CompileFunc(StdCompiler *pComp) pComp->Value(mkNamingAdapt( OnFire, "OnFire", false )); pComp->Value(mkNamingAdapt( InLiquid, "InLiquid", false )); pComp->Value(mkNamingAdapt( EntranceStatus, "EntranceStatus", false )); - pComp->Value(mkNamingAdapt( PhysicalTemporary, "PhysicalTemporary", false )); pComp->Value(mkNamingAdapt( NeedEnergy, "NeedEnergy", false )); pComp->Value(mkNamingAdapt( OCF, "OCF", 0u )); pComp->Value(Action); @@ -2694,12 +2682,6 @@ void C4Object::CompileFunc(StdCompiler *pComp) pComp->excCorrupt("Mesh graphics without mesh instance");*/ } - if (PhysicalTemporary) - { - pComp->FollowName("Physical"); - pComp->Value(TemporaryPhysical); - } - // TODO: Animations / attached meshes // Commands @@ -3488,7 +3470,6 @@ void C4Object::ContactAction() C4Real last_xdir; int32_t iDir; - C4PhysicalInfo *pPhysical=GetPhysical(); // Determine Procedure C4PropList* pActionDef = GetAction(); @@ -3854,9 +3835,6 @@ void C4Object::ExecAction() if (!(OCF & OCF_FullCon) && !Def->IncompleteActivity) { SetAction(0); return; } - // Determine ActDef & Physical Info - //C4PropList * pAction = Action.pActionDef; - C4PhysicalInfo *pPhysical=GetPhysical(); C4Real fWalk,fMove; int32_t smpx,smpy; diff --git a/src/game/object/C4Object.h b/src/game/object/C4Object.h index 274349fae..4b07ded56 100644 --- a/src/game/object/C4Object.h +++ b/src/game/object/C4Object.h @@ -186,9 +186,6 @@ public: C4Effect *pEffects; // linked list of effects C4ParticleList FrontParticles, BackParticles; // lists of object local particles - bool PhysicalTemporary; // physical temporary counter - C4TempPhysicalInfo TemporaryPhysical; - uint32_t ColorMod; // color by which the object-drawing is modulated uint32_t BlitMode; // extra blitting flags (like additive, ClrMod2, etc.) bool CrewDisabled; // CrewMember-functionality currently disabled @@ -335,7 +332,6 @@ public: BYTE GetEntranceArea(int32_t &aX, int32_t &aY, int32_t &aWdt, int32_t &aHgt); BYTE GetMomentum(C4Real &rxdir, C4Real &rydir); C4Real GetSpeed(); - C4PhysicalInfo *GetPhysical(bool fPermanent=false); void SetName (const char *NewName = 0); int32_t GetValue(C4Object *pInBase, int32_t iForPlayer); bool SetOwner(int32_t iOwner); diff --git a/src/game/object/C4ObjectCom.cpp b/src/game/object/C4ObjectCom.cpp index 30880cee5..2550994e9 100644 --- a/src/game/object/C4ObjectCom.cpp +++ b/src/game/object/C4ObjectCom.cpp @@ -301,7 +301,6 @@ bool ObjectComJump(C4Object *cObj) // by ObjectComUp, ExecCMDFMoveTo, FnJump if (cObj->GetProcedure()!=DFA_WALK) return false; // Calculate direction & forces C4Real TXDir=Fix0; - C4PhysicalInfo *pPhysical=cObj->GetPhysical(); C4Real iPhysicalWalk = itofix(0);//FIXME: ValByPhysical(280, pPhysical->Walk) * itofix(cObj->GetCon(), FullCon); C4Real iPhysicalJump = itofix(0);//FIXME: ValByPhysical(1000, pPhysical->Jump) * itofix(cObj->GetCon(), FullCon); @@ -368,7 +367,6 @@ bool ObjectComUp(C4Object *cObj) // by DFA_WALK or DFA_SWIM bool ObjectComDig(C4Object *cObj) // by DFA_WALK { - C4PhysicalInfo *phys=cObj->GetPhysical(); if (!ObjectActionDig(cObj)) { GameMsgObjectError(FormatString(LoadResStr("IDS_OBJ_NODIG"),cObj->GetName()).getData(),cObj); @@ -542,7 +540,6 @@ void ObjectComDigDouble(C4Object *cObj) // "Activation" by DFA_WALK, DFA_DIG, DF { C4Object *pTarget; DWORD ocf; - C4PhysicalInfo *phys=cObj->GetPhysical(); // Contents activation (first contents object only) if (cObj->Contents.GetObject()) diff --git a/src/game/script/C4Script.cpp b/src/game/script/C4Script.cpp index c44d77c6a..4ebf1b72f 100644 --- a/src/game/script/C4Script.cpp +++ b/src/game/script/C4Script.cpp @@ -510,129 +510,6 @@ static C4Void FnDoDamage(C4AulObjectContext *cthr, long iChange, Nillable return C4VNull; } -enum PhysicalMode -{ - PHYS_Current = 0, - PHYS_Temporary = 2, - PHYS_StackTemporary = 3 -}; - -static bool FnSetPhysical(C4AulObjectContext *cthr, C4String *szPhysical, long iValue, long iMode) -{ - // Get physical offset - C4PhysicalInfo::Offset off; - if (!C4PhysicalInfo::GetOffsetByName(FnStringPar(szPhysical), &off)) return false; - long iChange = 0; - // Set by mode - switch (static_cast(iMode)) // Cast so compiler may warn when new modes are added but not handled - { - // Currently active physical - case PHYS_Current: - // Info objects or temporary mode only - if (!cthr->Obj->PhysicalTemporary) if (!cthr->Obj->Info) return false; - // Set physical - iChange = iValue - cthr->Obj->GetPhysical()->*off; - cthr->Obj->GetPhysical()->*off = iValue; - // call to object - cthr->Obj->Call(PSF_PhysicalChange,&C4AulParSet(C4VString(szPhysical), C4VInt(iChange))); - return true; - // Temporary physical - case PHYS_Temporary: - case PHYS_StackTemporary: - // Automatically switch to temporary mode - if (!cthr->Obj->PhysicalTemporary) - { - cthr->Obj->TemporaryPhysical = *(cthr->Obj->GetPhysical()); - cthr->Obj->PhysicalTemporary = true; - } - // if old value is to be remembered, register the change - if (iMode == PHYS_StackTemporary) - cthr->Obj->TemporaryPhysical.RegisterChange(off); - // Set physical - iChange = iValue - cthr->Obj->TemporaryPhysical.*off; - cthr->Obj->TemporaryPhysical.*off = iValue; - // call to object - cthr->Obj->Call(PSF_PhysicalChange,&C4AulParSet(C4VString(szPhysical), C4VInt(iChange))); - return true; - } - // Invalid mode - throw new C4AulExecError(cthr->Obj, FormatString("SetPhysical: invalid physical mode %ld", iMode).getData()); -} - -static bool FnResetPhysical(C4AulObjectContext *cthr, C4String *sPhysical) -{ - const char *szPhysical = FnStringPar(sPhysical); - bool called = false; - - // Reset to permanent physical - if (!cthr->Obj->PhysicalTemporary) return false; - - // reset specified physical only? - if (szPhysical && *szPhysical) - { - C4PhysicalInfo::Offset off; - if (!C4PhysicalInfo::GetOffsetByName(szPhysical, &off)) return false; - if (!cthr->Obj->TemporaryPhysical.ResetPhysical(off)) return false; - - // call to object - cthr->Obj->Call(PSF_PhysicalChange,&C4AulParSet(C4VString(szPhysical), C4VNull)); - called = true; - - // if other physical changes remain, do not reset complete physicals - if (cthr->Obj->TemporaryPhysical.HasChanges(cthr->Obj->GetPhysical(true))) return true; - } - - // actual reset of temp physicals - cthr->Obj->PhysicalTemporary = false; - cthr->Obj->TemporaryPhysical.Default(); - // call to object - if (!called) cthr->Obj->Call(PSF_PhysicalChange,&C4AulParSet(C4VNull, C4VNull)); - - return true; -} - -static Nillable FnGetPhysical(C4AulContext *cthr, C4String *szPhysical, long iMode) -{ - // Get physical offset - C4PhysicalInfo::Offset off; - if (!C4PhysicalInfo::GetOffsetByName(FnStringPar(szPhysical), &off)) return C4VNull; - // no object context? - if (!cthr->Obj) - { - // def given? - if (cthr->Def) - { - // get def - // return physical value - return cthr->Def->Physical.*off; - } - return C4VNull; - } - - assert(cthr->Obj); - // Get by mode - switch (static_cast(iMode)) - { - // Currently active physical - case PHYS_Current: - // Get physical - return cthr->Obj->GetPhysical()->*off; - // Temporary physical - case PHYS_Temporary: - // Info objects only - if (!cthr->Obj->Info) return C4VNull; - // Only if in temporary mode - if (!cthr->Obj->PhysicalTemporary) return C4VNull; - // Get physical - return cthr->Obj->TemporaryPhysical.*off; - case PHYS_StackTemporary: - // TODO - break; - } - // Invalid mode - throw new C4AulExecError(cthr->Obj, FormatString("GetPhysical: invalid physical mode %ld", iMode).getData()); -} - static C4Void FnSetEntrance(C4AulObjectContext *cthr, bool e_status) { cthr->Obj->EntranceStatus = e_status; @@ -6061,9 +5938,6 @@ void InitFunctionMap(C4AulScriptEngine *pEngine) AddFunc(pEngine, "DoHomebaseMaterial", FnDoHomebaseMaterial); AddFunc(pEngine, "DoHomebaseProduction", FnDoHomebaseProduction); AddFunc(pEngine, "GainMissionAccess", FnGainMissionAccess); - AddFunc(pEngine, "SetPhysical", FnSetPhysical); - AddFunc(pEngine, "GetPhysical", FnGetPhysical); - AddFunc(pEngine, "ResetPhysical", FnResetPhysical); AddFunc(pEngine, "SetTransferZone", FnSetTransferZone); AddFunc(pEngine, "IsNetwork", FnIsNetwork); AddFunc(pEngine, "GetLeague", FnGetLeague); @@ -6496,10 +6370,6 @@ C4ScriptConstDef C4ScriptConstMap[]= { "C4SO_Value" ,C4V_Int, C4SO_Value }, { "C4SO_Func" ,C4V_Int, C4SO_Func }, - { "PHYS_Current" ,C4V_Int, PHYS_Current }, - { "PHYS_Temporary" ,C4V_Int, PHYS_Temporary }, - { "PHYS_StackTemporary" ,C4V_Int, PHYS_StackTemporary }, - { "C4CMD_Base" ,C4V_Int, C4CMD_Mode_Base }, { "C4CMD_SilentBase" ,C4V_Int, C4CMD_Mode_SilentBase }, { "C4CMD_Sub" ,C4V_Int, C4CMD_Mode_Sub }, diff --git a/src/game/script/C4Script.h b/src/game/script/C4Script.h index 8fa682f1f..137756430 100644 --- a/src/game/script/C4Script.h +++ b/src/game/script/C4Script.h @@ -180,7 +180,6 @@ bool C4ValueToMatrix(const C4ValueArray& array, StdMeshMatrix* matrix); #define PSF_OnTeamSwitch "~OnTeamSwitch" // int iPlr1, int idNewTeam, int idOldTeam #define PSF_OnOwnerRemoved "~OnOwnerRemoved" #define PSF_Promotion "~OnPromotion" -#define PSF_PhysicalChange "~OnPhysicalChange" // C4String *Physical, int iChange, int iMode #define PSF_CrewEnabled "~OnCrewEnabled" #define PSF_CrewDisabled "~OnCrewDisabled" #define PSF_NameChange "~OnNameChanged" // bool inInfoSection