From 3a6d66e230a0d6ee6e88cc129d868002ba346b6e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 15 Sep 2009 05:59:55 +0000 Subject: [PATCH] - fixed: The Dehacked flags parser fix from May 31 (r1624) was undone by yesterday's additions. Changed it so that the parser first checks for the presence of a '-' sign before deciding whether to use strtol or strtoul to convert the string into a number. SVN r1831 (trunk) --- docs/rh-log.txt | 6 ++++++ src/d_dehacked.cpp | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 5a2ac72e2..ca6d0f3cd 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,9 @@ +September 15, 2009 (Changes by Graf Zahl) +- fixed: The Dehacked flags parser fix from May 31 (r1624) was undone by + yesterday's additions. Changed it so that the parser first checks for + the presence of a '-' sign before deciding whether to use strtol or + strtoul to convert the string into a number. + September 14, 2009 (Changes by Graf Zahl) - Added PinkSilver's A_LookEx fix. - added resources needed for MBF support. diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index 8c1b36fc3..6be9b8538 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -958,7 +958,11 @@ static int PatchThing (int thingy) { if (IsNum (strval)) { - value[0] |= (unsigned long)strtol(strval, NULL, 10); + // I have no idea why everyone insists on using strtol here even though it fails + // dismally if a value is parsed where the highest bit it set. Do people really + // use negative values here? Let's better be safe and check both. + if (strchr(strval, '-')) value[0] |= (unsigned long)strtol(strval, NULL, 10); + else value[0] |= (unsigned long)strtoul(strval, NULL, 10); vchanged[0] = true; } else