summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Howard2011-09-25 19:58:41 +0000
committerSimon Howard2011-09-25 19:58:41 +0000
commit75f59299d005221304de2064558af2027eced6d7 (patch)
tree5487a38fb0dcebb0bdf523594ef7512e5f5b0542 /src
parent4fcf93139150e085c4d465e7c30e7895b759e19a (diff)
downloadchocolate-doom-75f59299d005221304de2064558af2027eced6d7.tar.gz
chocolate-doom-75f59299d005221304de2064558af2027eced6d7.tar.bz2
chocolate-doom-75f59299d005221304de2064558af2027eced6d7.zip
Handle WAD merging correctly when the sprites list contains lumps with
incorrectly formatted names - fixes merging for Heretic. Subversion-branch: /branches/v2-branch Subversion-revision: 2405
Diffstat (limited to 'src')
-rw-r--r--src/w_merge.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/w_merge.c b/src/w_merge.c
index 150f075c..027c6c2c 100644
--- a/src/w_merge.c
+++ b/src/w_merge.c
@@ -29,6 +29,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
#include "doomtype.h"
#include "i_system.h"
@@ -158,6 +159,31 @@ static void InitSpriteList(void)
num_sprite_frames = 0;
}
+static boolean ValidSpriteLumpName(char *name)
+{
+ if (name[0] == '\0' || name[1] == '\0'
+ || name[2] == '\0' || name[3] == '\0')
+ {
+ return false;
+ }
+
+ // First frame:
+
+ if (name[4] == '\0' || !isdigit(name[5]))
+ {
+ return false;
+ }
+
+ // Second frame (optional):
+
+ if (name[6] != '\0' && !isdigit(name[7]))
+ {
+ return false;
+ }
+
+ return true;
+}
+
// Find a sprite frame
static sprite_frame_t *FindSpriteFrame(char *name, int frame)
@@ -216,6 +242,11 @@ static boolean SpriteLumpNeeded(lumpinfo_t *lump)
int angle_num;
int i;
+ if (!ValidSpriteLumpName(lump->name))
+ {
+ return true;
+ }
+
// check the first frame
sprite = FindSpriteFrame(lump->name, lump->name[4]);
@@ -274,6 +305,11 @@ static void AddSpriteLump(lumpinfo_t *lump)
sprite_frame_t *sprite;
int angle_num;
int i;
+
+ if (!ValidSpriteLumpName(lump->name))
+ {
+ return;
+ }
// first angle