Add key bindings for pause, message refresh.
[chocolate-doom.git] / src / deh_thing.c
blob4823dc76c698d768a5ef973412f94694fd240028
1 // Emacs style mode select -*- C++ -*-
2 //-----------------------------------------------------------------------------
3 //
4 // Copyright(C) 2005 Simon Howard
5 //
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
19 // 02111-1307, USA.
21 //-----------------------------------------------------------------------------
23 // Parses "Thing" sections in dehacked files
25 //-----------------------------------------------------------------------------
27 #include <stdlib.h>
29 #include "doomdef.h"
30 #include "doomtype.h"
32 #include "deh_defs.h"
33 #include "deh_main.h"
34 #include "deh_mapping.h"
36 #include "info.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)
62 DEH_END_MAPPING
64 static void *DEH_ThingStart(deh_context_t *context, char *line)
66 int thing_number = 0;
67 mobjinfo_t *mobj;
69 if (sscanf(line, "Thing %i", &thing_number) != 1)
71 DEH_Warning(context, "Parse error on section start");
72 return NULL;
75 // dehacked files are indexed from 1
76 --thing_number;
78 if (thing_number < 0 || thing_number >= NUMMOBJTYPES)
80 DEH_Warning(context, "Invalid thing number: %i", thing_number);
81 return NULL;
84 mobj = &mobjinfo[thing_number];
86 return mobj;
89 static void DEH_ThingParseLine(deh_context_t *context, char *line, void *tag)
91 mobjinfo_t *mobj;
92 char *variable_name, *value;
93 int ivalue;
95 if (tag == NULL)
96 return;
98 mobj = (mobjinfo_t *) tag;
100 // Parse the assignment
102 if (!DEH_ParseAssignment(line, &variable_name, &value))
104 // Failed to parse
106 DEH_Warning(context, "Failed to parse assignment");
107 return;
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)
123 int i;
125 for (i=0; i<NUMMOBJTYPES; ++i)
127 DEH_StructMD5Sum(context, &thing_mapping, &mobjinfo[i]);
131 deh_section_t deh_section_thing =
133 "Thing",
134 NULL,
135 DEH_ThingStart,
136 DEH_ThingParseLine,
137 NULL,
138 DEH_ThingMD5Sum,