[iortcw] 77/152: All: Fix QVM sscanf to parse floats that begin with decimal point

Simon McVittie smcv at debian.org
Fri Sep 8 10:40:05 UTC 2017


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to annotated tag 1.5a
in repository iortcw.

commit 7ed7428e296ab638898479b5d137faa541fe2230
Author: Zack Middleton <zturtleman at gmail.com>
Date:   Tue Jul 5 06:05:34 2016 -0500

    All: Fix QVM sscanf to parse floats that begin with decimal point
    
    The props_skyportal's fogcolor in mp_castle (".2 .2 .2") was parsed
    as 0.0 0.0 0.0 by QVMs but 0.2 0.2 0.2 by native libs.
    
    Make QVM sscanf parse floats that begin with a decimal point so
    they behave more like the original native libs.
---
 MP/code/game/bg_lib.c | 7 ++++++-
 SP/code/game/bg_lib.c | 7 ++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/MP/code/game/bg_lib.c b/MP/code/game/bg_lib.c
index d08a235..635c14b 100644
--- a/MP/code/game/bg_lib.c
+++ b/MP/code/game/bg_lib.c
@@ -937,7 +937,12 @@ double _atof( const char **stringPtr ) {
 
 	// read digits
 	value = 0;
-	if ( string[0] != '.' ) {
+	if ( string[0] == '.' ) {
+		// read decimal point if followed by a digit
+		if ( string[1] >= '0' && string[1] <= '9' ) {
+			c = *string++;
+		}
+	} else {
 		do {
 			c = *string++;
 			if ( c < '0' || c > '9' ) {
diff --git a/SP/code/game/bg_lib.c b/SP/code/game/bg_lib.c
index 53c0561..e8c2299 100644
--- a/SP/code/game/bg_lib.c
+++ b/SP/code/game/bg_lib.c
@@ -808,7 +808,12 @@ double _atof( const char **stringPtr ) {
 
 	// read digits
 	value = 0;
-	if ( string[0] != '.' ) {
+	if ( string[0] == '.' ) {
+		// read decimal point if followed by a digit
+		if ( string[1] >= '0' && string[1] <= '9' ) {
+			c = *string++;
+		}
+	} else {
 		do {
 			c = *string++;
 			if ( c < '0' || c > '9' ) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/iortcw.git



More information about the Pkg-games-commits mailing list