1 // Emacs style mode select -*- C++ -*-
2 //-----------------------------------------------------------------------------
4 // Copyright(C) 2005 Simon Howard
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 //-----------------------------------------------------------------------------
23 // Parses "Thing" sections in dehacked files
25 //-----------------------------------------------------------------------------
34 #include "deh_mapping.h"
38 DEH_BEGIN_MAPPING(thing_mapping
, mobjinfo_t
)
39 DEH_MAPPING("ID #", doomednum
)
40 DEH_MAPPING("Initial frame", spawnstate
)
41 DEH_MAPPING("Hit points", spawnhealth
)
42 DEH_MAPPING("First moving frame", seestate
)
43 DEH_MAPPING("Alert sound", seesound
)
44 DEH_MAPPING("Reaction time", reactiontime
)
45 DEH_MAPPING("Attack sound", attacksound
)
46 DEH_MAPPING("Injury frame", painstate
)
47 DEH_MAPPING("Pain chance", painchance
)
48 DEH_MAPPING("Pain sound", painsound
)
49 DEH_MAPPING("Close attack frame", meleestate
)
50 DEH_MAPPING("Far attack frame", missilestate
)
51 DEH_MAPPING("Death frame", deathstate
)
52 DEH_MAPPING("Exploding frame", xdeathstate
)
53 DEH_MAPPING("Death sound", deathsound
)
54 DEH_MAPPING("Speed", speed
)
55 DEH_MAPPING("Width", radius
)
56 DEH_MAPPING("Height", height
)
57 DEH_MAPPING("Mass", mass
)
58 DEH_MAPPING("Missile damage", damage
)
59 DEH_MAPPING("Action sound", activesound
)
60 DEH_MAPPING("Bits", flags
)
61 DEH_MAPPING("Respawn frame", raisestate
)
64 static void *DEH_ThingStart(deh_context_t
*context
, char *line
)
69 if (sscanf(line
, "Thing %i", &thing_number
) != 1)
71 DEH_Warning(context
, "Parse error on section start");
75 // dehacked files are indexed from 1
78 if (thing_number
< 0 || thing_number
>= NUMMOBJTYPES
)
80 DEH_Warning(context
, "Invalid thing number: %i", thing_number
);
84 mobj
= &mobjinfo
[thing_number
];
89 static void DEH_ThingParseLine(deh_context_t
*context
, char *line
, void *tag
)
92 char *variable_name
, *value
;
98 mobj
= (mobjinfo_t
*) tag
;
100 // Parse the assignment
102 if (!DEH_ParseAssignment(line
, &variable_name
, &value
))
106 DEH_Warning(context
, "Failed to parse assignment");
110 // printf("Set %s to %s for mobj\n", variable_name, value);
112 // all values are integers
114 ivalue
= atoi(value
);
116 // Set the field value
118 DEH_SetMapping(context
, &thing_mapping
, mobj
, variable_name
, ivalue
);
121 static void DEH_ThingMD5Sum(md5_context_t
*context
)
125 for (i
=0; i
<NUMMOBJTYPES
; ++i
)
127 DEH_StructMD5Sum(context
, &thing_mapping
, &mobjinfo
[i
]);
131 deh_section_t deh_section_thing
=