Skip to content

Commit bd31055

Browse files
tamlin-mikeXottab-DUTY
authored andcommitted
ALife hit-stuff const-correctness. Moved bloating function g_tfString2HitType() to source file.
1 parent 2fc32b2 commit bd31055

File tree

2 files changed

+57
-43
lines changed

2 files changed

+57
-43
lines changed

src/xrServerEntities/alife_space.cpp

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,53 @@
33

44
namespace ALife
55
{
6-
xr_token hit_types_token[] = {{"burn", eHitTypeBurn}, {"shock", eHitTypeShock}, {"strike", eHitTypeStrike},
7-
{"wound", eHitTypeWound}, {"radiation", eHitTypeRadiation}, {"telepatic", eHitTypeTelepatic},
8-
{"fire_wound", eHitTypeFireWound}, {"chemical_burn", eHitTypeChemicalBurn}, {"explosion", eHitTypeExplosion},
6+
const xr_token hit_types_token[] =
7+
{
8+
{"burn", eHitTypeBurn},
9+
{"shock", eHitTypeShock},
10+
{"strike", eHitTypeStrike},
11+
{"wound", eHitTypeWound},
12+
{"radiation", eHitTypeRadiation},
13+
{"telepatic", eHitTypeTelepatic},
14+
{"fire_wound", eHitTypeFireWound},
15+
{"chemical_burn", eHitTypeChemicalBurn},
16+
{"explosion", eHitTypeExplosion},
917
{"wound_2", eHitTypeWound_2},
10-
// { "physic_strike", eHitTypePhysicStrike },
11-
{"light_burn", eHitTypeLightBurn}, {0, 0}};
18+
//{"physic_strike", eHitTypePhysicStrike},
19+
{"light_burn", eHitTypeLightBurn},
20+
{0, 0}
1221
};
22+
23+
EHitType g_tfString2HitType(LPCSTR caHitType)
24+
{
25+
if (!_stricmp(caHitType, "burn"))
26+
return eHitTypeBurn;
27+
if (!_stricmp(caHitType, "light_burn"))
28+
return eHitTypeLightBurn;
29+
if (!_stricmp(caHitType, "shock"))
30+
return eHitTypeShock;
31+
if (!_stricmp(caHitType, "strike"))
32+
return eHitTypeStrike;
33+
if (!_stricmp(caHitType, "wound"))
34+
return eHitTypeWound;
35+
if (!_stricmp(caHitType, "radiation"))
36+
return eHitTypeRadiation;
37+
if (!_stricmp(caHitType, "telepatic"))
38+
return eHitTypeTelepatic;
39+
if (!_stricmp(caHitType, "fire_wound"))
40+
return eHitTypeFireWound;
41+
if (!_stricmp(caHitType, "chemical_burn"))
42+
return eHitTypeChemicalBurn;
43+
if (!_stricmp(caHitType, "explosion"))
44+
return eHitTypeExplosion;
45+
if (!_stricmp(caHitType, "wound_2"))
46+
return eHitTypeWound_2;
47+
48+
FATAL("Unsupported hit type!");
49+
NODEFAULT;
50+
#ifdef DEBUG
51+
return eHitTypeMax;
52+
#endif
53+
}
54+
55+
} // namespace ALife

src/xrServerEntities/alife_space.h

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
////////////////////////////////////////////////////////////////////////////
2-
// Module : alife_space.h
3-
// Created : 08.01.2002
4-
// Modified : 08.01.2003
5-
// Author : Dmitriy Iassenev
6-
// Description : ALife space
2+
// Module : alife_space.h
3+
// Created : 08.01.2002
4+
// Modified : 08.01.2003
5+
// Author : Dmitriy Iassenev
6+
// Description : ALife space
77
////////////////////////////////////////////////////////////////////////////
88

99
#ifndef XRAY_ALIFE_SPACE
@@ -100,7 +100,7 @@ enum EHitType
100100
eHitTypeStrike,
101101
eHitTypeExplosion,
102102
eHitTypeWound_2, // knife's alternative fire
103-
// eHitTypePhysicStrike,
103+
// eHitTypePhysicStrike,
104104
eHitTypeLightBurn,
105105
eHitTypeMax,
106106
};
@@ -157,39 +157,10 @@ enum EWeaponAddonStatus
157157
eAddonAttachable = 2
158158
};
159159

160-
IC EHitType g_tfString2HitType(LPCSTR caHitType)
161-
{
162-
if (!stricmp(caHitType, "burn"))
163-
return (eHitTypeBurn);
164-
else if (!stricmp(caHitType, "light_burn"))
165-
return (eHitTypeLightBurn);
166-
else if (!stricmp(caHitType, "shock"))
167-
return (eHitTypeShock);
168-
else if (!stricmp(caHitType, "strike"))
169-
return (eHitTypeStrike);
170-
else if (!stricmp(caHitType, "wound"))
171-
return (eHitTypeWound);
172-
else if (!stricmp(caHitType, "radiation"))
173-
return (eHitTypeRadiation);
174-
else if (!stricmp(caHitType, "telepatic"))
175-
return (eHitTypeTelepatic);
176-
else if (!stricmp(caHitType, "fire_wound"))
177-
return (eHitTypeFireWound);
178-
else if (!stricmp(caHitType, "chemical_burn"))
179-
return (eHitTypeChemicalBurn);
180-
else if (!stricmp(caHitType, "explosion"))
181-
return (eHitTypeExplosion);
182-
else if (!stricmp(caHitType, "wound_2"))
183-
return (eHitTypeWound_2);
184-
else
185-
FATAL("Unsupported hit type!");
186-
NODEFAULT;
187-
#ifdef DEBUG
188-
return (eHitTypeMax);
189-
#endif
190-
}
160+
EHitType g_tfString2HitType(LPCSTR caHitType);
161+
191162
#ifndef _EDITOR
192-
extern xr_token hit_types_token[];
163+
extern const xr_token hit_types_token[];
193164

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

0 commit comments

Comments
 (0)