ref: 91d265dfdf7c358d4917c1bc8b5050183848bba3
parent: 27901a5b8a8536ff0c236c96f24970a09821fc31
author: Simon Howard <fraggle@gmail.com>
date: Mon Oct 3 09:21:11 EDT 2005
Weapons mapping code Subversion-branch: /trunk/chocolate-doom Subversion-revision: 158
--- 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,6 +41,9 @@
//
//-----------------------------------------------------------------------------
+#include <stdlib.h>
+#include <string.h>
+
#include "doomdef.h"
#include "doomtype.h"
@@ -44,6 +50,7 @@
#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 @@
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 =