forked from github/server
Kompatibilitaets-Fix negative ids.
This commit is contained in:
parent
ddcbce5092
commit
3a5873a0f6
3 changed files with 12 additions and 6 deletions
|
@ -33,6 +33,7 @@
|
||||||
#include <util/unicode.h>
|
#include <util/unicode.h>
|
||||||
|
|
||||||
/* libc includes */
|
/* libc includes */
|
||||||
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <wctype.h>
|
#include <wctype.h>
|
||||||
|
@ -216,7 +217,7 @@ read_groups(struct storage * store, faction * f)
|
||||||
ally * a;
|
ally * a;
|
||||||
variant fid;
|
variant fid;
|
||||||
fid.i = store->r_id(store);
|
fid.i = store->r_id(store);
|
||||||
if (fid.i<0) break;
|
if (fid.i<=0) break;
|
||||||
if (store->version<STORAGE_VERSION && fid.i==0) break;
|
if (store->version<STORAGE_VERSION && fid.i==0) break;
|
||||||
a = malloc(sizeof(ally));
|
a = malloc(sizeof(ally));
|
||||||
*pa = a;
|
*pa = a;
|
||||||
|
|
|
@ -31,11 +31,15 @@ atoi36(const char * str)
|
||||||
{
|
{
|
||||||
/* cannot use strtol, becuase invalid strings will cause crash */
|
/* cannot use strtol, becuase invalid strings will cause crash */
|
||||||
const unsigned char * s = (const unsigned char *)str;
|
const unsigned char * s = (const unsigned char *)str;
|
||||||
int i = 0;
|
int i = 0, sign = 1;
|
||||||
assert(s);
|
assert(s);
|
||||||
if(!(*s)) return 0;
|
if(!(*s)) return 0;
|
||||||
|
|
||||||
while(isspace(*(unsigned char*)s)) ++s;
|
while(isspace(*(unsigned char*)s)) ++s;
|
||||||
|
if (*s == '-') {
|
||||||
|
sign = -1;
|
||||||
|
++s;
|
||||||
|
}
|
||||||
while(isalnum(*(unsigned char*)s)) {
|
while(isalnum(*(unsigned char*)s)) {
|
||||||
if (isupper(*(unsigned char*)s)) i = i*36 + (*s)-'A' + 10;
|
if (isupper(*(unsigned char*)s)) i = i*36 + (*s)-'A' + 10;
|
||||||
else if (islower(*(unsigned char*)s)) i=i*36 + (*s)-'a' + 10;
|
else if (islower(*(unsigned char*)s)) i=i*36 + (*s)-'a' + 10;
|
||||||
|
@ -45,7 +49,7 @@ atoi36(const char * str)
|
||||||
++s;
|
++s;
|
||||||
}
|
}
|
||||||
if (i<0) return 0;
|
if (i<0) return 0;
|
||||||
return i;
|
return i * sign;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char*
|
const char*
|
||||||
|
|
|
@ -12,14 +12,15 @@ end
|
||||||
test_locales()
|
test_locales()
|
||||||
|
|
||||||
local now = os.clock()
|
local now = os.clock()
|
||||||
read_game("566.dat", "binary")
|
--read_game("566.dat", "binary")
|
||||||
--read_game("566", "text")
|
read_game("566.txt", "text")
|
||||||
|
--write_game("566.txt", "text")
|
||||||
local elapsed = os.clock() - now
|
local elapsed = os.clock() - now
|
||||||
print(elapsed)
|
print(elapsed)
|
||||||
-- text: 50.574
|
-- text: 50.574
|
||||||
-- bin0: 19.547
|
-- bin0: 19.547
|
||||||
-- bin1: 18.953
|
-- bin1: 18.953
|
||||||
|
|
||||||
write_game("566.dat", "binary")
|
--write_game("566.dat", "binary")
|
||||||
|
|
||||||
io.stdin:read("*line")
|
io.stdin:read("*line")
|
||||||
|
|
Loading…
Reference in a new issue