summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Howard2005-10-03 13:21:11 +0000
committerSimon Howard2005-10-03 13:21:11 +0000
commit91d265dfdf7c358d4917c1bc8b5050183848bba3 (patch)
tree5b5903ee4577b464bd3615a7253d975e9b9bf38a /src
parent27901a5b8a8536ff0c236c96f24970a09821fc31 (diff)
downloadchocolate-doom-91d265dfdf7c358d4917c1bc8b5050183848bba3.tar.gz
chocolate-doom-91d265dfdf7c358d4917c1bc8b5050183848bba3.tar.bz2
chocolate-doom-91d265dfdf7c358d4917c1bc8b5050183848bba3.zip
Weapons mapping code
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 158
Diffstat (limited to 'src')
-rw-r--r--src/deh_weapon.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/deh_weapon.c b/src/deh_weapon.c
index d1db4ba6..62ea61fe 100644
--- a/src/deh_weapon.c
+++ b/src/deh_weapon.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: deh_weapon.c 157 2005-10-03 11:08:16Z fraggle $
+// $Id: deh_weapon.c 158 2005-10-03 13:21:11Z fraggle $
//
// Copyright(C) 2005 Simon Howard
//
@@ -21,6 +21,9 @@
// 02111-1307, USA.
//
// $Log$
+// Revision 1.4 2005/10/03 13:21:11 fraggle
+// Weapons mapping code
+//
// Revision 1.3 2005/10/03 11:08:16 fraggle
// Replace end of section functions with NULLs as they arent currently being
// used for anything.
@@ -38,12 +41,16 @@
//
//-----------------------------------------------------------------------------
+#include <stdlib.h>
+#include <string.h>
+
#include "doomdef.h"
#include "doomtype.h"
#include "d_items.h"
#include "deh_defs.h"
+#include "deh_main.h"
#include "deh_mapping.h"
DEH_BEGIN_MAPPING(weapon_mapping, weaponinfo_t)
@@ -57,11 +64,37 @@ DEH_END_MAPPING
static void *DEH_WeaponStart(deh_context_t *context, char *line)
{
- return NULL;
+ int weapon_number = 0;
+
+ sscanf(line, "Weapon %i", &weapon_number);
+
+ if (weapon_number < 0 || weapon_number >= NUMWEAPONS)
+ return NULL;
+
+ return &weaponinfo[weapon_number];
}
static void DEH_WeaponParseLine(deh_context_t *context, char *line, void *tag)
{
+ char *variable_name, *value;
+ weaponinfo_t *weapon;
+ int ivalue;
+
+ if (tag == NULL)
+ return;
+
+ weapon = (weaponinfo_t *) tag;
+
+ if (!DEH_ParseAssignment(line, &variable_name, &value))
+ {
+ // Failed to parse
+
+ return;
+ }
+
+ ivalue = atoi(value);
+
+ DEH_SetMapping(&weapon_mapping, weapon, variable_name, ivalue);
}
deh_section_t deh_section_weapon =