Skip to content

Commit

Permalink
ALife hit-stuff const-correctness. Moved bloating function g_tfString…
Browse files Browse the repository at this point in the history
…2HitType() to source file.
  • Loading branch information
tamlin-mike authored and Xottab-DUTY committed Aug 5, 2017
1 parent 2fc32b2 commit bd31055
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 43 deletions.
53 changes: 48 additions & 5 deletions src/xrServerEntities/alife_space.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,53 @@

namespace ALife
{
xr_token hit_types_token[] = {{"burn", eHitTypeBurn}, {"shock", eHitTypeShock}, {"strike", eHitTypeStrike},
{"wound", eHitTypeWound}, {"radiation", eHitTypeRadiation}, {"telepatic", eHitTypeTelepatic},
{"fire_wound", eHitTypeFireWound}, {"chemical_burn", eHitTypeChemicalBurn}, {"explosion", eHitTypeExplosion},
const xr_token hit_types_token[] =
{
{"burn", eHitTypeBurn},
{"shock", eHitTypeShock},
{"strike", eHitTypeStrike},
{"wound", eHitTypeWound},
{"radiation", eHitTypeRadiation},
{"telepatic", eHitTypeTelepatic},
{"fire_wound", eHitTypeFireWound},
{"chemical_burn", eHitTypeChemicalBurn},
{"explosion", eHitTypeExplosion},
{"wound_2", eHitTypeWound_2},
// { "physic_strike", eHitTypePhysicStrike },
{"light_burn", eHitTypeLightBurn}, {0, 0}};
//{"physic_strike", eHitTypePhysicStrike},
{"light_burn", eHitTypeLightBurn},
{0, 0}
};

EHitType g_tfString2HitType(LPCSTR caHitType)
{
if (!_stricmp(caHitType, "burn"))
return eHitTypeBurn;
if (!_stricmp(caHitType, "light_burn"))
return eHitTypeLightBurn;
if (!_stricmp(caHitType, "shock"))
return eHitTypeShock;
if (!_stricmp(caHitType, "strike"))
return eHitTypeStrike;
if (!_stricmp(caHitType, "wound"))
return eHitTypeWound;
if (!_stricmp(caHitType, "radiation"))
return eHitTypeRadiation;
if (!_stricmp(caHitType, "telepatic"))
return eHitTypeTelepatic;
if (!_stricmp(caHitType, "fire_wound"))
return eHitTypeFireWound;
if (!_stricmp(caHitType, "chemical_burn"))
return eHitTypeChemicalBurn;
if (!_stricmp(caHitType, "explosion"))
return eHitTypeExplosion;
if (!_stricmp(caHitType, "wound_2"))
return eHitTypeWound_2;

FATAL("Unsupported hit type!");
NODEFAULT;
#ifdef DEBUG
return eHitTypeMax;
#endif
}

} // namespace ALife
47 changes: 9 additions & 38 deletions src/xrServerEntities/alife_space.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
////////////////////////////////////////////////////////////////////////////
// Module : alife_space.h
// Created : 08.01.2002
// Modified : 08.01.2003
// Author : Dmitriy Iassenev
// Description : ALife space
// Module : alife_space.h
// Created : 08.01.2002
// Modified : 08.01.2003
// Author : Dmitriy Iassenev
// Description : ALife space
////////////////////////////////////////////////////////////////////////////

#ifndef XRAY_ALIFE_SPACE
Expand Down Expand Up @@ -100,7 +100,7 @@ enum EHitType
eHitTypeStrike,
eHitTypeExplosion,
eHitTypeWound_2, // knife's alternative fire
// eHitTypePhysicStrike,
// eHitTypePhysicStrike,
eHitTypeLightBurn,
eHitTypeMax,
};
Expand Down Expand Up @@ -157,39 +157,10 @@ enum EWeaponAddonStatus
eAddonAttachable = 2
};

IC EHitType g_tfString2HitType(LPCSTR caHitType)
{
if (!stricmp(caHitType, "burn"))
return (eHitTypeBurn);
else if (!stricmp(caHitType, "light_burn"))
return (eHitTypeLightBurn);
else if (!stricmp(caHitType, "shock"))
return (eHitTypeShock);
else if (!stricmp(caHitType, "strike"))
return (eHitTypeStrike);
else if (!stricmp(caHitType, "wound"))
return (eHitTypeWound);
else if (!stricmp(caHitType, "radiation"))
return (eHitTypeRadiation);
else if (!stricmp(caHitType, "telepatic"))
return (eHitTypeTelepatic);
else if (!stricmp(caHitType, "fire_wound"))
return (eHitTypeFireWound);
else if (!stricmp(caHitType, "chemical_burn"))
return (eHitTypeChemicalBurn);
else if (!stricmp(caHitType, "explosion"))
return (eHitTypeExplosion);
else if (!stricmp(caHitType, "wound_2"))
return (eHitTypeWound_2);
else
FATAL("Unsupported hit type!");
NODEFAULT;
#ifdef DEBUG
return (eHitTypeMax);
#endif
}
EHitType g_tfString2HitType(LPCSTR caHitType);

#ifndef _EDITOR
extern xr_token hit_types_token[];
extern const xr_token hit_types_token[];

IC LPCSTR g_cafHitType2String(EHitType tHitType) { return get_token_name(hit_types_token, tHitType); }
#endif
Expand Down

0 comments on commit bd31055

Please sign in to comment.