Formatting changes to jmact

git-svn-id: https://svn.eduke32.com/eduke32@809 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2008-06-29 10:41:01 +00:00
parent 2fa3153a84
commit 3c51265878
8 changed files with 1322 additions and 1185 deletions

View file

@ -146,7 +146,8 @@ dump:
do
{
*dstP++ = *srcP++;
} while (--cnt);
}
while (--cnt);
goto nextOp;
run:
wordCnt = (byte)*srcP++; /* 8-bit unsigned count */
@ -154,7 +155,8 @@ run:
do
{
*dstP++ = pixel;
} while (--wordCnt);
}
while (--wordCnt);
goto nextOp;
longOp:
@ -178,7 +180,8 @@ notLongSkip:
do
{
*dstP++ = *srcP++;
} while (--wordCnt);
}
while (--wordCnt);
goto nextOp;
longRun:
@ -187,7 +190,8 @@ longRun:
do
{
*dstP++ = pixel;
} while (--wordCnt);
}
while (--wordCnt);
goto nextOp;
stop: /* all done */
@ -259,7 +263,8 @@ void ANIM_LoadAnim (char * buffer)
uint16 i;
int32 size;
if (!Anim_Started) {
if (!Anim_Started)
{
anim = SafeMalloc(sizeof(anim_t));
Anim_Started = true;
}

View file

@ -139,12 +139,18 @@ void CONTROL_SetFlag(int32 which, boolean active)
{
if (CONTROL_CheckRange(which)) return;
if (CONTROL_Flags[which].toggle == INSTANT_ONOFF) {
if (CONTROL_Flags[which].toggle == INSTANT_ONOFF)
{
CONTROL_Flags[which].active = active;
} else {
if (active) {
}
else
{
if (active)
{
CONTROL_Flags[which].buttonheld = false;
} else if (CONTROL_Flags[which].buttonheld == false) {
}
else if (CONTROL_Flags[which].buttonheld == false)
{
CONTROL_Flags[which].buttonheld = true;
CONTROL_Flags[which].active = (CONTROL_Flags[which].active ? false : true);
}
@ -211,7 +217,8 @@ void CONTROL_PrintKeyMap(void)
{
int32 i;
for (i=0;i<CONTROL_NUM_FLAGS;i++) {
for (i=0;i<CONTROL_NUM_FLAGS;i++)
{
initprintf("function %2ld key1=%3x key2=%3x\n",
i, CONTROL_KeyMapping[i].key1, CONTROL_KeyMapping[i].key2);
}
@ -230,14 +237,16 @@ void CONTROL_PrintAxes(void)
int32 i;
initprintf("nummouseaxes=%d\n", CONTROL_NumMouseAxes);
for (i=0;i<CONTROL_NumMouseAxes;i++) {
for (i=0;i<CONTROL_NumMouseAxes;i++)
{
initprintf("axis=%d analog=%d digital1=%d digital2=%d\n",
i, CONTROL_MouseAxesMap[i].analogmap,
CONTROL_MouseAxesMap[i].minmap, CONTROL_MouseAxesMap[i].maxmap);
}
initprintf("numjoyaxes=%d\n", CONTROL_NumJoyAxes);
for (i=0;i<CONTROL_NumJoyAxes;i++) {
for (i=0;i<CONTROL_NumJoyAxes;i++)
{
initprintf("axis=%d analog=%d digital1=%d digital2=%d\n",
i, CONTROL_JoyAxesMap[i].analogmap,
CONTROL_JoyAxesMap[i].minmap, CONTROL_JoyAxesMap[i].maxmap);
@ -250,9 +259,11 @@ void CONTROL_MapButton( int32 whichfunction, int32 whichbutton, boolean doublecl
if (CONTROL_CheckRange(whichfunction)) whichfunction = BUTTONUNDEFINED;
switch (device) {
switch (device)
{
case controldevice_mouse:
if ((uint32)whichbutton >= (uint32)MAXMOUSEBUTTONS) {
if ((uint32)whichbutton >= (uint32)MAXMOUSEBUTTONS)
{
//Error("CONTROL_MapButton: button %d out of valid range for %d mouse buttons.",
// whichbutton, CONTROL_NumMouseButtons);
return;
@ -261,7 +272,8 @@ void CONTROL_MapButton( int32 whichfunction, int32 whichbutton, boolean doublecl
break;
case controldevice_joystick:
if ((uint32)whichbutton >= (uint32)MAXJOYBUTTONS) {
if ((uint32)whichbutton >= (uint32)MAXJOYBUTTONS)
{
//Error("CONTROL_MapButton: button %d out of valid range for %d joystick buttons.",
// whichbutton, CONTROL_NumJoyButtons);
return;
@ -284,15 +296,18 @@ void CONTROL_MapAnalogAxis( int32 whichaxis, int32 whichanalog, controldevice de
{
controlaxismaptype *set;
if ((uint32)whichanalog >= (uint32)analog_maxtype) {
if ((uint32)whichanalog >= (uint32)analog_maxtype)
{
//Error("CONTROL_MapAnalogAxis: analog function %d out of valid range for %d analog functions.",
// whichanalog, analog_maxtype);
return;
}
switch (device) {
switch (device)
{
case controldevice_mouse:
if ((uint32)whichaxis >= (uint32)MAXMOUSEAXES) {
if ((uint32)whichaxis >= (uint32)MAXMOUSEAXES)
{
//Error("CONTROL_MapAnalogAxis: axis %d out of valid range for %d mouse axes.",
// whichaxis, MAXMOUSEAXES);
return;
@ -302,7 +317,8 @@ void CONTROL_MapAnalogAxis( int32 whichaxis, int32 whichanalog, controldevice de
break;
case controldevice_joystick:
if ((uint32)whichaxis >= (uint32)MAXJOYAXES) {
if ((uint32)whichaxis >= (uint32)MAXJOYAXES)
{
//Error("CONTROL_MapAnalogAxis: axis %d out of valid range for %d joystick axes.",
// whichaxis, MAXJOYAXES);
return;
@ -323,9 +339,11 @@ void CONTROL_SetAnalogAxisScale( int32 whichaxis, int32 axisscale, controldevice
{
int32 *set;
switch (device) {
switch (device)
{
case controldevice_mouse:
if ((uint32)whichaxis >= (uint32)MAXMOUSEAXES) {
if ((uint32)whichaxis >= (uint32)MAXMOUSEAXES)
{
//Error("CONTROL_SetAnalogAxisScale: axis %d out of valid range for %d mouse axes.",
// whichaxis, MAXMOUSEAXES);
return;
@ -335,7 +353,8 @@ void CONTROL_SetAnalogAxisScale( int32 whichaxis, int32 axisscale, controldevice
break;
case controldevice_joystick:
if ((uint32)whichaxis >= (uint32)MAXJOYAXES) {
if ((uint32)whichaxis >= (uint32)MAXJOYAXES)
{
//Error("CONTROL_SetAnalogAxisScale: axis %d out of valid range for %d joystick axes.",
// whichaxis, MAXJOYAXES);
return;
@ -358,9 +377,11 @@ void CONTROL_MapDigitalAxis( int32 whichaxis, int32 whichfunction, int32 directi
if (CONTROL_CheckRange(whichfunction)) whichfunction = AXISUNDEFINED;
switch (device) {
switch (device)
{
case controldevice_mouse:
if ((uint32)whichaxis >= (uint32)MAXMOUSEAXES) {
if ((uint32)whichaxis >= (uint32)MAXMOUSEAXES)
{
//Error("CONTROL_MapDigitalAxis: axis %d out of valid range for %d mouse axes.",
// whichaxis, MAXMOUSEAXES);
return;
@ -370,7 +391,8 @@ void CONTROL_MapDigitalAxis( int32 whichaxis, int32 whichfunction, int32 directi
break;
case controldevice_joystick:
if ((uint32)whichaxis >= (uint32)MAXJOYAXES) {
if ((uint32)whichaxis >= (uint32)MAXJOYAXES)
{
//Error("CONTROL_MapDigitalAxis: axis %d out of valid range for %d joystick axes.",
// whichaxis, MAXJOYAXES);
return;
@ -384,7 +406,8 @@ void CONTROL_MapDigitalAxis( int32 whichaxis, int32 whichfunction, int32 directi
return;
}
switch (direction) { // JBF: this is all very much a guess. The ASM puzzles me.
switch (direction) // JBF: this is all very much a guess. The ASM puzzles me.
{
case axis_up:
case axis_left:
set[whichaxis].minmap = whichfunction;
@ -433,33 +456,42 @@ static void DoGetDeviceButtons(
boolean *ButtonClickedState,
boolean *ButtonClicked,
byte *ButtonClickedCount
) {
)
{
int32 i, bs;
for (i=0;i<NumButtons;i++) {
for (i=0;i<NumButtons;i++)
{
bs = (buttons >> i) & 1;
DeviceButtonState[i] = bs;
ButtonClickedState[i] = false;
if (bs) {
if (ButtonClicked[i] == false) {
if (bs)
{
if (ButtonClicked[i] == false)
{
ButtonClicked[i] = true;
if (ButtonClickedCount[i] == 0 || tm > ButtonClickedTime[i]) {
if (ButtonClickedCount[i] == 0 || tm > ButtonClickedTime[i])
{
ButtonClickedTime[i] = tm + CONTROL_DoubleClickSpeed;
ButtonClickedCount[i] = 1;
}
else if (tm < ButtonClickedTime[i]) {
else if (tm < ButtonClickedTime[i])
{
ButtonClickedState[i] = true;
ButtonClickedTime[i] = 0;
ButtonClickedCount[i] = 2;
}
}
else if (ButtonClickedCount[i] == 2) {
else if (ButtonClickedCount[i] == 2)
{
ButtonClickedState[i] = true;
}
} else {
}
else
{
if (ButtonClickedCount[i] == 2)
ButtonClickedCount[i] = 0;
@ -474,7 +506,8 @@ void CONTROL_GetDeviceButtons(void)
t = GetTime();
if (CONTROL_MouseEnabled) {
if (CONTROL_MouseEnabled)
{
DoGetDeviceButtons(
MOUSE_GetButtons(), t,
CONTROL_NumMouseButtons,
@ -486,9 +519,11 @@ void CONTROL_GetDeviceButtons(void)
);
}
if (CONTROL_JoystickEnabled) {
if (CONTROL_JoystickEnabled)
{
int32 buttons = joyb;
if (joynumhats > 0 && joyhat[0] != -1) {
if (joynumhats > 0 && joyhat[0] != -1)
{
static int32 hatstate[] = { 1, 1|2, 2, 2|4, 4, 4|8, 8, 8|1 };
int val;
@ -513,7 +548,8 @@ void CONTROL_DigitizeAxis(int32 axis, controldevice device)
{
controlaxistype *set, *lastset;
switch (device) {
switch (device)
{
case controldevice_mouse:
set = CONTROL_MouseAxes;
lastset = CONTROL_LastMouseAxes;
@ -527,20 +563,31 @@ void CONTROL_DigitizeAxis(int32 axis, controldevice device)
default: return;
}
if (set[axis].analog > 0) {
if (set[axis].analog > THRESHOLD) { // if very much in one direction,
if (set[axis].analog > 0)
{
if (set[axis].analog > THRESHOLD) // if very much in one direction,
{
set[axis].digital = 1; // set affirmative
} else {
if (set[axis].analog > MINTHRESHOLD) { // if hanging in limbo,
}
else
{
if (set[axis].analog > MINTHRESHOLD) // if hanging in limbo,
{
if (lastset[axis].digital == 1) // set if in same direction as last time
set[axis].digital = 1;
}
}
} else {
if (set[axis].analog < -THRESHOLD) {
}
else
{
if (set[axis].analog < -THRESHOLD)
{
set[axis].digital = -1;
} else {
if (set[axis].analog < -MINTHRESHOLD) {
}
else
{
if (set[axis].analog < -MINTHRESHOLD)
{
if (lastset[axis].digital == -1)
set[axis].digital = -1;
}
@ -553,7 +600,8 @@ void CONTROL_ScaleAxis(int32 axis, controldevice device)
controlaxistype *set;
int32 *scale;
switch (device) {
switch (device)
{
case controldevice_mouse:
set = CONTROL_MouseAxes;
scale = CONTROL_MouseAxesScale;
@ -575,7 +623,8 @@ void CONTROL_ApplyAxis(int32 axis, ControlInfo *info, controldevice device)
controlaxistype *set;
controlaxismaptype *map;
switch (device) {
switch (device)
{
case controldevice_mouse:
set = CONTROL_MouseAxes;
map = CONTROL_MouseAxesMap;
@ -589,7 +638,8 @@ void CONTROL_ApplyAxis(int32 axis, ControlInfo *info, controldevice device)
default: return;
}
switch (map[axis].analogmap) {
switch (map[axis].analogmap)
{
case analog_turning: info->dyaw += set[axis].analog; break;
case analog_strafing: info->dx += set[axis].analog; break;
case analog_lookingupanddown: info->dpitch += set[axis].analog; break;
@ -611,24 +661,28 @@ void CONTROL_PollDevices(ControlInfo *info)
memset(CONTROL_JoyAxes, 0, sizeof(CONTROL_JoyAxes));
memset(info, 0, sizeof(ControlInfo));
if (CONTROL_MouseEnabled) {
if (CONTROL_MouseEnabled)
{
CONTROL_GetMouseDelta();
for (i=0; i<MAXMOUSEAXES; i++) {
for (i=0; i<MAXMOUSEAXES; i++)
{
CONTROL_DigitizeAxis(i, controldevice_mouse);
CONTROL_ScaleAxis(i, controldevice_mouse);
LIMITCONTROL(&CONTROL_MouseAxes[i].analog);
CONTROL_ApplyAxis(i, info, controldevice_mouse);
}
}
if (CONTROL_JoystickEnabled) {
if (CONTROL_JoystickEnabled)
{
CONTROL_GetJoyDelta();
// Why?
//CONTROL_Axes[0].analog /= 2;
//CONTROL_Axes[2].analog /= 2;
for (i=0; i<MAXJOYAXES; i++) {
for (i=0; i<MAXJOYAXES; i++)
{
CONTROL_DigitizeAxis(i, controldevice_joystick);
CONTROL_ScaleAxis(i, controldevice_joystick);
LIMITCONTROL(&CONTROL_JoyAxes[i].analog);
@ -643,7 +697,8 @@ void CONTROL_AxisFunctionState(int32 *p1)
{
int32 i, j;
for (i=0; i<CONTROL_NumMouseAxes; i++) {
for (i=0; i<CONTROL_NumMouseAxes; i++)
{
if (!CONTROL_MouseAxes[i].digital) continue;
if (CONTROL_MouseAxes[i].digital < 0)
@ -655,7 +710,8 @@ void CONTROL_AxisFunctionState(int32 *p1)
p1[j] = 1;
}
for (i=0; i<CONTROL_NumJoyAxes; i++) {
for (i=0; i<CONTROL_NumJoyAxes; i++)
{
if (!CONTROL_JoyAxes[i].digital) continue;
if (CONTROL_JoyAxes[i].digital < 0)
@ -672,7 +728,8 @@ void CONTROL_ButtonFunctionState( int32 *p1 )
{
int32 i, j;
for (i=0; i<CONTROL_NumMouseButtons; i++) {
for (i=0; i<CONTROL_NumMouseButtons; i++)
{
j = CONTROL_MouseButtonMapping[i].doubleclicked;
if (j != KEYUNDEFINED)
p1[j] |= CONTROL_MouseButtonClickedState[i];
@ -682,7 +739,8 @@ void CONTROL_ButtonFunctionState( int32 *p1 )
p1[j] |= CONTROL_MouseButtonState[i];
}
for (i=0; i<CONTROL_NumJoyButtons; i++) {
for (i=0; i<CONTROL_NumJoyButtons; i++)
{
j = CONTROL_JoyButtonMapping[i].doubleclicked;
if (j != KEYUNDEFINED)
p1[j] |= CONTROL_JoyButtonClickedState[i];
@ -823,7 +881,8 @@ void CONTROL_GetInput( ControlInfo *info )
CONTROL_ProcessBinds();
for (i=0; i<CONTROL_NUM_FLAGS; i++) {
for (i=0; i<CONTROL_NUM_FLAGS; i++)
{
CONTROL_SetFlag(i, CONTROL_KeyboardFunctionPressed(i) | periphs[i] | extinput[i]);
if (CONTROL_Flags[i].cleared == false) BUTTONSET(i, CONTROL_Flags[i].active);

View file

@ -63,7 +63,8 @@ int32 SafeOpen(const char *filename, int32 mode, int32 sharemode)
h = openfrompath(filename, mode, sharemode);
if (h < 0) Error("Error opening %s: %s", filename, strerror(errno));
if (h < MaxFiles) {
if (h < MaxFiles)
{
if (FileNames[h]) SafeFree(FileNames[h]);
FileNames[h] = (char*)SafeMalloc(strlen(filename)+1);
if (FileNames[h]) strcpy(FileNames[h], filename);
@ -74,7 +75,8 @@ int32 SafeOpen(const char *filename, int32 mode, int32 sharemode)
int32 SafeOpenRead(const char *filename, int32 filetype)
{
switch (filetype) {
switch (filetype)
{
case filetype_binary:
return SafeOpen(filename, O_RDONLY|O_BINARY, S_IREAD);
case filetype_text:
@ -88,14 +90,16 @@ int32 SafeOpenRead(const char *filename, int32 filetype)
void SafeClose(int32 handle)
{
if (handle < 0) return;
if (close(handle) < 0) {
if (close(handle) < 0)
{
if (handle < MaxFiles)
Error("Unable to close file %s", FileNames[handle]);
else
Error("Unable to close file");
}
if (handle < MaxFiles && FileNames[handle]) {
if (handle < MaxFiles && FileNames[handle])
{
SafeFree(FileNames[handle]);
FileNames[handle] = NULL;
}
@ -118,7 +122,8 @@ void SafeRead(int32 handle, void *buffer, int32 count)
int32 b;
b = read(handle, buffer, count);
if (b != count) {
if (b != count)
{
close(handle);
if (handle < MaxFiles)
Error("File read failure %s reading %d bytes from file %s.",

View file

@ -43,10 +43,12 @@ kb_scancode KB_LastScan;
static boolean numpad = 0;
// translation table for taking key names to scancodes and back again
static struct {
static struct
{
char *key;
kb_scancode sc;
} sctokeylut[] = {
} sctokeylut[] =
{
{ "Escape", 0x1 },
{ "1", 0x2 },
{ "2", 0x3 },

View file

@ -58,8 +58,10 @@ int32 SCRIPT_New(void)
{
int32 i;
for (i=0; i<MAXSCRIPTFILES; i++) {
if (!SC(i)) {
for (i=0; i<MAXSCRIPTFILES; i++)
{
if (!SC(i))
{
SC(i) = (script_t *)SafeMalloc(sizeof(script_t));
if (!SC(i)) return -1;
memset(SC(i), 0, sizeof(script_t));
@ -78,8 +80,10 @@ void SCRIPT_Delete(int32 scripthandle)
if (!SC(scripthandle)) return;
if (SCRIPT(scripthandle,script)) {
while (SCRIPT(scripthandle,script)->nextsection != SCRIPT(scripthandle,script)) {
if (SCRIPT(scripthandle,script))
{
while (SCRIPT(scripthandle,script)->nextsection != SCRIPT(scripthandle,script))
{
s = SCRIPT(scripthandle,script)->nextsection;
SCRIPT_FreeSection(SCRIPT(scripthandle,script));
SafeFree(SCRIPT(scripthandle,script));
@ -100,7 +104,8 @@ void SCRIPT_FreeSection(ScriptSectionType * section)
if (!section) return;
if (!section->entries) return;
while (section->entries->nextentry != section->entries) {
while (section->entries->nextentry != section->entries)
{
e = section->entries->nextentry;
SafeFree(section->entries);
section->entries = e;
@ -156,9 +161,12 @@ ScriptSectionType * SCRIPT_AddSection( int32 scripthandle, char * sectionname )
AllocSection(s);
s->name = strdup(sectionname);
if (!SCRIPT(scripthandle,script)) {
if (!SCRIPT(scripthandle,script))
{
SCRIPT(scripthandle,script) = s;
} else {
}
else
{
s2 = SCRIPT(scripthandle,script);
while (s2->nextsection != s2) s2=s2->nextsection;
s2->nextsection = s;
@ -198,12 +206,16 @@ void SCRIPT_AddEntry ( int32 scripthandle, char * sectionname, char * entryname,
// }
e = SCRIPT_EntryExists(s, entryname);
if (!e) {
if (!e)
{
AllocEntry(e);
e->name = strdup(entryname);
if (!s->entries) {
if (!s->entries)
{
s->entries = e;
} else {
}
else
{
e2 = s->entries;
while (e2->nextentry != e2) e2=e2->nextentry;
e2->nextentry = e;
@ -223,7 +235,8 @@ int32 SCRIPT_ParseBuffer(int32 scripthandle, char *data, int32 length)
char *currentsection = "";
char *currententry = NULL;
char *currentvalue = NULL;
enum {
enum
{
ParsingIdle,
ParsingSectionBegin,
ParsingSectionName,
@ -231,7 +244,8 @@ int32 SCRIPT_ParseBuffer(int32 scripthandle, char *data, int32 length)
ParsingValueBegin,
ParsingValue
};
enum {
enum
{
ExpectingSection = 1,
ExpectingEntry = 2,
ExpectingAssignment = 4,
@ -254,11 +268,14 @@ int32 SCRIPT_ParseBuffer(int32 scripthandle, char *data, int32 length)
#define EATLINE(p) while (length > 0 && *p != '\n' && *p != '\r') { p++; length--; }
#define LETTER() { lastch = ch; ch = *(sp++); length--; }
while (length > 0) {
switch (state) {
while (length > 0)
{
switch (state)
{
case ParsingIdle:
LETTER();
switch (ch) {
switch (ch)
{
// whitespace
case ' ':
case '\t': continue;
@ -270,30 +287,39 @@ int32 SCRIPT_ParseBuffer(int32 scripthandle, char *data, int32 length)
EATLINE(sp);
continue;
case '[': if (!(expect & ExpectingSection)) {
case '[': if (!(expect & ExpectingSection))
{
// Unexpected section start
printf("Unexpected start of section on line %d.\n", linenum);
SETRV(-1);
EATLINE(sp);
continue;
} else {
}
else
{
state = ParsingSectionBegin;
continue;
}
default: if (isalpha(ch)) {
if (!(expect & ExpectingEntry)) {
default: if (isalpha(ch))
{
if (!(expect & ExpectingEntry))
{
// Unexpected name start
printf("Unexpected entry label on line %d.\n", linenum);
SETRV(-1);
EATLINE(sp);
continue;
} else {
}
else
{
currententry = dp = sp-1;
state = ParsingEntry;
continue;
}
} else {
}
else
{
// Unexpected character
printf("Illegal character (ASCII %d) on line %d.\n", ch, linenum);
SETRV(-1);
@ -307,7 +333,8 @@ int32 SCRIPT_ParseBuffer(int32 scripthandle, char *data, int32 length)
state = ParsingSectionName;
case ParsingSectionName:
LETTER();
switch (ch) {
switch (ch)
{
case '\n':
case '\r': // Unexpected newline
printf("Unexpected newline on line %d.\n", linenum);
@ -330,7 +357,8 @@ int32 SCRIPT_ParseBuffer(int32 scripthandle, char *data, int32 length)
case ParsingEntry:
LETTER();
switch (ch) {
switch (ch)
{
case ';':
/*case '#':*/
// unexpected comment
@ -364,7 +392,8 @@ int32 SCRIPT_ParseBuffer(int32 scripthandle, char *data, int32 length)
state = ParsingValue;
case ParsingValue:
LETTER();
switch (ch) {
switch (ch)
{
case '\n':
case '\r':
// value complete, add it using parsed name
@ -423,7 +452,8 @@ int32 SCRIPT_Load ( char * filename )
SafeClose(h);
s = SCRIPT_Init(filename);
if (s<0) {
if (s<0)
{
SafeFree(b);
return -1;
}
@ -449,14 +479,16 @@ void SCRIPT_Save (int32 scripthandle, char * filename)
if (!fp) return;
numsect = SCRIPT_NumberSections(scripthandle);
for (sec=0; sec<numsect; sec++) {
for (sec=0; sec<numsect; sec++)
{
section = SCRIPT_Section(scripthandle, sec);
if (sec>0) fprintf(fp, "\n");
if (section[0] != 0)
fprintf(fp, "[%s]\n", section);
nument = SCRIPT_NumberEntries(scripthandle,section);
for (ent=0; ent<nument; ent++) {
for (ent=0; ent<nument; ent++)
{
entry = SCRIPT_Entry(scripthandle,section,ent);
value = SCRIPT_GetRaw(scripthandle,section,entry);
@ -557,14 +589,18 @@ boolean SCRIPT_GetString( int32 scripthandle, char * sectionname, char * entryna
p = e->value;
c = 0;
if (*p == '\"') {
if (*p == '\"')
{
// quoted string
p++;
while ((ch = *(p++))) {
switch (ch) {
while ((ch = *(p++)))
{
switch (ch)
{
case '\\':
ch = *(p++);
switch (ch) {
switch (ch)
{
case 0: return 0;
case 'n': dest[c++] = '\n'; break;
case 'r': dest[c++] = '\r'; break;
@ -580,8 +616,11 @@ boolean SCRIPT_GetString( int32 scripthandle, char * sectionname, char * entryna
break;
}
}
} else {
while ((ch = *(p++))) {
}
else
{
while ((ch = *(p++)))
{
if (ch == ' ' || ch == '\t') { dest[c] = 0; break; }
else dest[c++] = ch;
}
@ -610,14 +649,18 @@ boolean SCRIPT_GetDoubleString( int32 scripthandle, char * sectionname, char * e
p = e->value;
c = 0;
if (*p == '\"') {
if (*p == '\"')
{
// quoted string
p++;
while ((ch = *(p++))) {
switch (ch) {
while ((ch = *(p++)))
{
switch (ch)
{
case '\\':
ch = *(p++);
switch (ch) {
switch (ch)
{
case 0: return 0;
case 'n': dest1[c++] = '\n'; break;
case 'r': dest1[c++] = '\r'; break;
@ -634,8 +677,11 @@ boolean SCRIPT_GetDoubleString( int32 scripthandle, char * sectionname, char * e
}
}
if (ch == 0) return 0;
} else {
while ((ch = *(p++))) {
}
else
{
while ((ch = *(p++)))
{
if (ch == ' ' || ch == '\t') { dest1[c] = 0; break; }
else dest1[c++] = ch;
}
@ -647,14 +693,18 @@ breakme:
c = 0;
if (*p == '\"') {
if (*p == '\"')
{
// quoted string
p++;
while ((ch = *(p++))) {
switch (ch) {
while ((ch = *(p++)))
{
switch (ch)
{
case '\\':
ch = *(p++);
switch (ch) {
switch (ch)
{
case 0: return 0;
case 'n': dest2[c++] = '\n'; break;
case 'r': dest2[c++] = '\r'; break;
@ -670,8 +720,11 @@ breakme:
break;
}
}
} else {
while ((ch = *(p++))) {
}
else
{
while ((ch = *(p++)))
{
if (ch == ' ' || ch == '\t') { dest2[c] = 0; break; }
else dest2[c++] = ch;
}
@ -693,12 +746,16 @@ boolean SCRIPT_GetNumber( int32 scripthandle, char * sectionname, char * entryna
e = SCRIPT_EntryExists(s, entryname);
if (!e) return 1;// *number = 0;
else {
if (e->value[0] == '0' && e->value[1] == 'x') {
else
{
if (e->value[0] == '0' && e->value[1] == 'x')
{
// hex
*number = strtol(e->value+2, &p, 16);
if (p == e->value || *p != 0 || *p != ' ' || *p != '\t') return 1;
} else {
}
else
{
// decimal
*number = strtol(e->value, &p, 10);
if (p == e->value || *p != 0 || *p != ' ' || *p != '\t') return 1;
@ -720,7 +777,8 @@ boolean SCRIPT_GetBoolean( int32 scripthandle, char * sectionname, char * entryn
e = SCRIPT_EntryExists(s, entryname);
if (!e) return 1;// *boole = 0;
else {
else
{
if (!Bstrncasecmp(e->value, "true", 4)) *boole = 1;
else if (!Bstrncasecmp(e->value, "false", 5)) *boole = 0;
else if (e->value[0] == '1' && (e->value[1] == ' ' || e->value[1] == '\t' || e->value[1] == 0)) *boole = 1;
@ -758,13 +816,15 @@ void SCRIPT_PutString
int len = 3;
if (!string) string = "";
for (q=string; *q; q++) {
for (q=string; *q; q++)
{
if (*q == '\r' || *q == '\n' || *q == '\t' || *q == '\\' || *q == '"') len+=2;
else if (*q >= ' ') len++;
}
p = raw = Bmalloc(len);
*(p++) = '"';
for (q=string; *q; q++) {
for (q=string; *q; q++)
{
if (*q == '\r') { *(p++) = '\\'; *(p++) = 'r'; }
else if (*q == '\n') { *(p++) = '\\'; *(p++) = 'n'; }
else if (*q == '\t') { *(p++) = '\\'; *(p++) = 't'; }
@ -792,17 +852,20 @@ void SCRIPT_PutDoubleString
if (!string1) string1 = "";
if (!string2) string2 = "";
for (q=string1; *q; q++) {
for (q=string1; *q; q++)
{
if (*q == '\r' || *q == '\n' || *q == '\t' || *q == '\\' || *q == '"') len+=2;
else if (*q >= ' ') len++;
}
for (q=string2; *q; q++) {
for (q=string2; *q; q++)
{
if (*q == '\r' || *q == '\n' || *q == '\t' || *q == '\\' || *q == '"') len+=2;
else if (*q >= ' ') len++;
}
p = raw = Bmalloc(len);
*(p++) = '"';
for (q=string1; *q; q++) {
for (q=string1; *q; q++)
{
if (*q == '\r') { *(p++) = '\\'; *(p++) = 'r'; }
else if (*q == '\n') { *(p++) = '\\'; *(p++) = 'n'; }
else if (*q == '\t') { *(p++) = '\\'; *(p++) = 't'; }
@ -812,7 +875,8 @@ void SCRIPT_PutDoubleString
*(p++) = '"';
*(p++) = ' ';
*(p++) = '"';
for (q=string2; *q; q++) {
for (q=string2; *q; q++)
{
if (*q == '\r') { *(p++) = '\\'; *(p++) = 'r'; }
else if (*q == '\n') { *(p++) = '\\'; *(p++) = 'n'; }
else if (*q == '\t') { *(p++) = '\\'; *(p++) = 't'; }

View file

@ -54,7 +54,8 @@ void Error(char *error, ...)
if (ShutDown) ShutDown();
if (error) {
if (error)
{
va_start(va, error);
vprintf(error, va);
va_end(va);
@ -69,7 +70,8 @@ char CheckParm(char *check)
{
int c;
for (c=1;c<_buildargc;c++) {
for (c=1;c<_buildargc;c++)
{
if (_buildargv[c][0] == '/' || _buildargv[c][0] == '-')
if (!Bstrcasecmp(&_buildargv[c][1], check)) return c;
}