Replaced custom varargs handing by portable stdarg.h stuff.
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@92 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -574,10 +574,6 @@ SOURCE=..\sc2code\libs\timelib.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\sc2code\libs\vargs.h
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\sc2code\libs\vidlib.h
|
SOURCE=..\sc2code\libs\vidlib.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# End Group
|
# End Group
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
#define _CODERES_H
|
#define _CODERES_H
|
||||||
|
|
||||||
#include "reslib.h"
|
#include "reslib.h"
|
||||||
#include "vargs.h"
|
|
||||||
|
|
||||||
extern MEM_HANDLE LoadCodeResFile (PSTR pStr);
|
extern MEM_HANDLE LoadCodeResFile (PSTR pStr);
|
||||||
extern BOOLEAN InstallCodeResType (COUNT code_type);
|
extern BOOLEAN InstallCodeResType (COUNT code_type);
|
||||||
|
|||||||
@@ -515,7 +515,7 @@ Intro (void)
|
|||||||
|
|
||||||
construct_response (shared_phrase_buf,
|
construct_response (shared_phrase_buf,
|
||||||
i_am_captain0,
|
i_am_captain0,
|
||||||
(vararg_dcl)GLOBAL_SIS (CommanderName),
|
GLOBAL_SIS (CommanderName),
|
||||||
i_am_captain1,
|
i_am_captain1,
|
||||||
GLOBAL_SIS (ShipName),
|
GLOBAL_SIS (ShipName),
|
||||||
i_am_captain2,
|
i_am_captain2,
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ ByeBye (RESPONSE_REF R)
|
|||||||
|
|
||||||
construct_response (shared_phrase_buf,
|
construct_response (shared_phrase_buf,
|
||||||
name_40,
|
name_40,
|
||||||
(vararg_dcl)GLOBAL_SIS (CommanderName),
|
GLOBAL_SIS (CommanderName),
|
||||||
name_41,
|
name_41,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
@@ -524,7 +524,7 @@ RevealSelf (RESPONSE_REF R)
|
|||||||
{
|
{
|
||||||
construct_response (shared_phrase_buf,
|
construct_response (shared_phrase_buf,
|
||||||
we_are_vindicator0,
|
we_are_vindicator0,
|
||||||
(vararg_dcl)GLOBAL_SIS (CommanderName),
|
GLOBAL_SIS (CommanderName),
|
||||||
we_are_vindicator1,
|
we_are_vindicator1,
|
||||||
GLOBAL_SIS (ShipName),
|
GLOBAL_SIS (ShipName),
|
||||||
we_are_vindicator2,
|
we_are_vindicator2,
|
||||||
@@ -630,7 +630,7 @@ Intro (void)
|
|||||||
construct_response (
|
construct_response (
|
||||||
shared_phrase_buf,
|
shared_phrase_buf,
|
||||||
no_but_well_help0,
|
no_but_well_help0,
|
||||||
(vararg_dcl)GLOBAL_SIS (ShipName),
|
GLOBAL_SIS (ShipName),
|
||||||
no_but_well_help1,
|
no_but_well_help1,
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1398,7 +1398,7 @@ yack0_respond (void)
|
|||||||
construct_response (
|
construct_response (
|
||||||
shared_phrase_buf,
|
shared_phrase_buf,
|
||||||
we_are_from_alliance0,
|
we_are_from_alliance0,
|
||||||
(vararg_dcl)buf,
|
buf,
|
||||||
(RESPONSE_REF)-1
|
(RESPONSE_REF)-1
|
||||||
);
|
);
|
||||||
DoResponsePhrase (we_are_from_alliance0, DoFirstMeeting, shared_phrase_buf);
|
DoResponsePhrase (we_are_from_alliance0, DoFirstMeeting, shared_phrase_buf);
|
||||||
|
|||||||
@@ -521,7 +521,7 @@ OrzNeutral (RESPONSE_REF R)
|
|||||||
{
|
{
|
||||||
construct_response (shared_phrase_buf,
|
construct_response (shared_phrase_buf,
|
||||||
we_are_vindicator0,
|
we_are_vindicator0,
|
||||||
(vararg_dcl)GLOBAL_SIS (CommanderName),
|
GLOBAL_SIS (CommanderName),
|
||||||
we_are_vindicator1,
|
we_are_vindicator1,
|
||||||
GLOBAL_SIS (ShipName),
|
GLOBAL_SIS (ShipName),
|
||||||
we_are_vindicator2,
|
we_are_vindicator2,
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ DiscussConquer (RESPONSE_REF R)
|
|||||||
construct_response (
|
construct_response (
|
||||||
shared_phrase_buf,
|
shared_phrase_buf,
|
||||||
conquer_because_1,
|
conquer_because_1,
|
||||||
(vararg_dcl)buf,
|
buf,
|
||||||
(RESPONSE_REF)-1
|
(RESPONSE_REF)-1
|
||||||
);
|
);
|
||||||
DoResponsePhrase (conquer_because_1, DiscussConquer, shared_phrase_buf);
|
DoResponsePhrase (conquer_because_1, DiscussConquer, shared_phrase_buf);
|
||||||
@@ -607,7 +607,7 @@ PkunkHome (RESPONSE_REF R)
|
|||||||
{
|
{
|
||||||
construct_response (shared_phrase_buf,
|
construct_response (shared_phrase_buf,
|
||||||
we_are_vindicator0,
|
we_are_vindicator0,
|
||||||
(vararg_dcl)GLOBAL_SIS (CommanderName),
|
GLOBAL_SIS (CommanderName),
|
||||||
we_are_vindicator1,
|
we_are_vindicator1,
|
||||||
GLOBAL_SIS (ShipName),
|
GLOBAL_SIS (ShipName),
|
||||||
we_are_vindicator2,
|
we_are_vindicator2,
|
||||||
|
|||||||
@@ -329,7 +329,7 @@ RealizeMistake (RESPONSE_REF R)
|
|||||||
construct_response (
|
construct_response (
|
||||||
shared_phrase_buf,
|
shared_phrase_buf,
|
||||||
i_am_captain0,
|
i_am_captain0,
|
||||||
(vararg_dcl)GLOBAL_SIS (CommanderName),
|
GLOBAL_SIS (CommanderName),
|
||||||
i_am_captain1,
|
i_am_captain1,
|
||||||
buf,
|
buf,
|
||||||
i_am_captain2,
|
i_am_captain2,
|
||||||
|
|||||||
@@ -723,7 +723,7 @@ HomeWorld (RESPONSE_REF R)
|
|||||||
case 0:
|
case 0:
|
||||||
construct_response (shared_phrase_buf,
|
construct_response (shared_phrase_buf,
|
||||||
we_are_us0,
|
we_are_us0,
|
||||||
(vararg_dcl)GLOBAL_SIS (CommanderName),
|
GLOBAL_SIS (CommanderName),
|
||||||
we_are_us1,
|
we_are_us1,
|
||||||
GLOBAL_SIS (ShipName),
|
GLOBAL_SIS (ShipName),
|
||||||
we_are_us2,
|
we_are_us2,
|
||||||
|
|||||||
@@ -853,7 +853,7 @@ SpathiPassword (RESPONSE_REF R)
|
|||||||
{
|
{
|
||||||
construct_response (shared_phrase_buf,
|
construct_response (shared_phrase_buf,
|
||||||
we_are_vindicator0,
|
we_are_vindicator0,
|
||||||
(vararg_dcl)GLOBAL_SIS (CommanderName),
|
GLOBAL_SIS (CommanderName),
|
||||||
we_are_vindicator1,
|
we_are_vindicator1,
|
||||||
GLOBAL_SIS (ShipName),
|
GLOBAL_SIS (ShipName),
|
||||||
we_are_vindicator2,
|
we_are_vindicator2,
|
||||||
|
|||||||
@@ -917,7 +917,7 @@ TellStarBase (RESPONSE_REF R)
|
|||||||
construct_response (
|
construct_response (
|
||||||
buf0,
|
buf0,
|
||||||
tell_me_about_modules0,
|
tell_me_about_modules0,
|
||||||
(vararg_dcl)GLOBAL_SIS (ShipName),
|
GLOBAL_SIS (ShipName),
|
||||||
tell_me_about_modules1,
|
tell_me_about_modules1,
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
@@ -933,7 +933,7 @@ TellStarBase (RESPONSE_REF R)
|
|||||||
construct_response (
|
construct_response (
|
||||||
shared_phrase_buf,
|
shared_phrase_buf,
|
||||||
tell_me_about_fuel0,
|
tell_me_about_fuel0,
|
||||||
(vararg_dcl)GLOBAL_SIS (ShipName),
|
GLOBAL_SIS (ShipName),
|
||||||
tell_me_about_fuel1,
|
tell_me_about_fuel1,
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -406,7 +406,7 @@ NeutralSupox (RESPONSE_REF R)
|
|||||||
case 0:
|
case 0:
|
||||||
construct_response (shared_phrase_buf,
|
construct_response (shared_phrase_buf,
|
||||||
i_am0,
|
i_am0,
|
||||||
(vararg_dcl)GLOBAL_SIS (CommanderName),
|
GLOBAL_SIS (CommanderName),
|
||||||
i_am1,
|
i_am1,
|
||||||
0);
|
0);
|
||||||
pStr[0] = i_am0;
|
pStr[0] = i_am0;
|
||||||
@@ -415,7 +415,7 @@ NeutralSupox (RESPONSE_REF R)
|
|||||||
case 1:
|
case 1:
|
||||||
construct_response (shared_phrase_buf,
|
construct_response (shared_phrase_buf,
|
||||||
my_ship0,
|
my_ship0,
|
||||||
(vararg_dcl)GLOBAL_SIS (ShipName),
|
GLOBAL_SIS (ShipName),
|
||||||
my_ship1,
|
my_ship1,
|
||||||
0);
|
0);
|
||||||
pStr[0] = my_ship0;
|
pStr[0] = my_ship0;
|
||||||
@@ -429,7 +429,7 @@ NeutralSupox (RESPONSE_REF R)
|
|||||||
construct_response (
|
construct_response (
|
||||||
shared_phrase_buf,
|
shared_phrase_buf,
|
||||||
from_alliance0,
|
from_alliance0,
|
||||||
(vararg_dcl)buf,
|
buf,
|
||||||
from_alliance1,
|
from_alliance1,
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -870,7 +870,7 @@ Intro (void)
|
|||||||
{
|
{
|
||||||
construct_response (shared_phrase_buf,
|
construct_response (shared_phrase_buf,
|
||||||
we_are_vindicator0,
|
we_are_vindicator0,
|
||||||
(vararg_dcl)GLOBAL_SIS (CommanderName),
|
GLOBAL_SIS (CommanderName),
|
||||||
we_are_vindicator1,
|
we_are_vindicator1,
|
||||||
GLOBAL_SIS (ShipName),
|
GLOBAL_SIS (ShipName),
|
||||||
we_are_vindicator2,
|
we_are_vindicator2,
|
||||||
|
|||||||
@@ -491,7 +491,7 @@ CompelPlayer (RESPONSE_REF R)
|
|||||||
construct_response (
|
construct_response (
|
||||||
shared_phrase_buf,
|
shared_phrase_buf,
|
||||||
we_are_vindicator0,
|
we_are_vindicator0,
|
||||||
(vararg_dcl)GLOBAL_SIS (ShipName),
|
GLOBAL_SIS (ShipName),
|
||||||
we_are_vindicator1,
|
we_are_vindicator1,
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -350,7 +350,7 @@ Zombies (RESPONSE_REF R)
|
|||||||
{
|
{
|
||||||
construct_response (shared_phrase_buf,
|
construct_response (shared_phrase_buf,
|
||||||
we_vindicator0,
|
we_vindicator0,
|
||||||
(vararg_dcl)GLOBAL_SIS (CommanderName),
|
GLOBAL_SIS (CommanderName),
|
||||||
we_vindicator1,
|
we_vindicator1,
|
||||||
GLOBAL_SIS (ShipName),
|
GLOBAL_SIS (ShipName),
|
||||||
we_vindicator2,
|
we_vindicator2,
|
||||||
|
|||||||
@@ -528,7 +528,7 @@ NeutralUtwig (RESPONSE_REF R)
|
|||||||
construct_response (
|
construct_response (
|
||||||
shared_phrase_buf,
|
shared_phrase_buf,
|
||||||
we_are_vindicator0,
|
we_are_vindicator0,
|
||||||
(vararg_dcl)GLOBAL_SIS (CommanderName),
|
GLOBAL_SIS (CommanderName),
|
||||||
we_are_vindicator1,
|
we_are_vindicator1,
|
||||||
buf,
|
buf,
|
||||||
we_are_vindicator2,
|
we_are_vindicator2,
|
||||||
|
|||||||
@@ -360,7 +360,7 @@ YehatHome (RESPONSE_REF R)
|
|||||||
construct_response (
|
construct_response (
|
||||||
shared_phrase_buf,
|
shared_phrase_buf,
|
||||||
i_demand_you_ally_homeworld0,
|
i_demand_you_ally_homeworld0,
|
||||||
(vararg_dcl)GLOBAL_SIS (CommanderName),
|
GLOBAL_SIS (CommanderName),
|
||||||
i_demand_you_ally_homeworld1,
|
i_demand_you_ally_homeworld1,
|
||||||
buf,
|
buf,
|
||||||
i_demand_you_ally_homeworld2,
|
i_demand_you_ally_homeworld2,
|
||||||
@@ -486,7 +486,7 @@ YehatSpace (RESPONSE_REF R)
|
|||||||
construct_response (
|
construct_response (
|
||||||
shared_phrase_buf,
|
shared_phrase_buf,
|
||||||
i_demand_you_ally_space0,
|
i_demand_you_ally_space0,
|
||||||
(vararg_dcl)GLOBAL_SIS (CommanderName),
|
GLOBAL_SIS (CommanderName),
|
||||||
i_demand_you_ally_space1,
|
i_demand_you_ally_space1,
|
||||||
GLOBAL_SIS (ShipName),
|
GLOBAL_SIS (ShipName),
|
||||||
i_demand_you_ally_space2,
|
i_demand_you_ally_space2,
|
||||||
|
|||||||
@@ -465,7 +465,7 @@ AquaintZoqFot (RESPONSE_REF R)
|
|||||||
construct_response (
|
construct_response (
|
||||||
shared_phrase_buf,
|
shared_phrase_buf,
|
||||||
we_are_vindicator0,
|
we_are_vindicator0,
|
||||||
(vararg_dcl)buf,
|
buf,
|
||||||
we_are_vindicator1,
|
we_are_vindicator1,
|
||||||
GLOBAL_SIS (ShipName),
|
GLOBAL_SIS (ShipName),
|
||||||
we_are_vindicator2,
|
we_are_vindicator2,
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "starcon.h"
|
#include "starcon.h"
|
||||||
#include "commglue.h"
|
#include "commglue.h"
|
||||||
#include "libs/sound/trackplayer.h"
|
#include "libs/sound/trackplayer.h"
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
void
|
void
|
||||||
NPCPhrase (int index)
|
NPCPhrase (int index)
|
||||||
@@ -106,13 +107,12 @@ GetAllianceName (UNICODE *buf, RESPONSE_REF name_1)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
construct_response (UNICODE *buf, RESPONSE_REF R, vararg_dcl c_args,
|
construct_response (UNICODE *buf, RESPONSE_REF R, ...)
|
||||||
...)
|
|
||||||
{
|
{
|
||||||
UNICODE *name;
|
UNICODE *name;
|
||||||
vararg_list vlist;
|
va_list vlist;
|
||||||
|
|
||||||
vararg_start (vlist, c_args);
|
va_start (vlist, R);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
COUNT len;
|
COUNT len;
|
||||||
@@ -122,18 +122,18 @@ construct_response (UNICODE *buf, RESPONSE_REF R, vararg_dcl c_args,
|
|||||||
wstrcpy (buf, (UNICODE *)GetStringAddress (S));
|
wstrcpy (buf, (UNICODE *)GetStringAddress (S));
|
||||||
len = wstrlen (buf);
|
len = wstrlen (buf);
|
||||||
buf += len;
|
buf += len;
|
||||||
name = vararg_val (vlist, UNICODE *);
|
name = va_arg (vlist, UNICODE *);
|
||||||
if (name)
|
if (name)
|
||||||
{
|
{
|
||||||
len = wstrlen (name);
|
len = wstrlen (name);
|
||||||
wstrncpy (buf, name, len);
|
wstrncpy (buf, name, len);
|
||||||
buf += len;
|
buf += len;
|
||||||
|
|
||||||
if ((R = vararg_val (vlist, RESPONSE_REF)) == (RESPONSE_REF)-1)
|
if ((R = va_arg (vlist, RESPONSE_REF)) == (RESPONSE_REF)-1)
|
||||||
name = 0;
|
name = 0;
|
||||||
}
|
}
|
||||||
} while (name);
|
} while (name);
|
||||||
vararg_end (vlist);
|
va_end (vlist);
|
||||||
|
|
||||||
*buf = '\0';
|
*buf = '\0';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,8 +19,6 @@
|
|||||||
#ifndef _COMMGLUE_H
|
#ifndef _COMMGLUE_H
|
||||||
#define _COMMGLUE_H
|
#define _COMMGLUE_H
|
||||||
|
|
||||||
#include "libs/vargs.h"
|
|
||||||
|
|
||||||
extern LOCDATA CommData;
|
extern LOCDATA CommData;
|
||||||
extern int cur_comm;
|
extern int cur_comm;
|
||||||
extern UNICODE shared_phrase_buf[256];
|
extern UNICODE shared_phrase_buf[256];
|
||||||
@@ -61,8 +59,7 @@ extern void NPCPhrase (int index);
|
|||||||
|
|
||||||
extern void GetAllianceName (UNICODE *buf, RESPONSE_REF name_1);
|
extern void GetAllianceName (UNICODE *buf, RESPONSE_REF name_1);
|
||||||
|
|
||||||
extern void construct_response (UNICODE *buf, RESPONSE_REF R, vararg_dcl
|
extern void construct_response (UNICODE *buf, RESPONSE_REF R, ...);
|
||||||
c_args, ...);
|
|
||||||
|
|
||||||
extern LOCDATAPTR init_race (RESOURCE comm_id);
|
extern LOCDATAPTR init_race (RESOURCE comm_id);
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ SUBDIRS = decomp graphics input math memory resource sound strings \
|
|||||||
noinst_HEADERS = \
|
noinst_HEADERS = \
|
||||||
compiler.h declib.h gfxlib.h inplib.h mathlib.h \
|
compiler.h declib.h gfxlib.h inplib.h mathlib.h \
|
||||||
memlib.h reslib.h sndlib.h strlib.h tasklib.h threadlib.h \
|
memlib.h reslib.h sndlib.h strlib.h tasklib.h threadlib.h \
|
||||||
timelib.h vargs.h vidlib.h misc.h
|
timelib.h vidlib.h misc.h
|
||||||
|
|
||||||
INCLUDES = @SDL_CFLAGS@ \
|
INCLUDES = @SDL_CFLAGS@ \
|
||||||
-I$(top_srcdir)/src \
|
-I$(top_srcdir)/src \
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
//Copyright Paul Reiche, Fred Ford. 1992-2002
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _VARARGS_H
|
|
||||||
#define _VARARGS_H
|
|
||||||
|
|
||||||
typedef char *vararg_list;
|
|
||||||
typedef char *vararg_dcl;
|
|
||||||
#define vararg_start(list,alist) (list) = (vararg_list)&(alist)
|
|
||||||
#define vararg_end(list)
|
|
||||||
#define vararg_val(list,type) \
|
|
||||||
(sizeof (type) >= sizeof (int) ? \
|
|
||||||
(((type *)((list) += sizeof (type)))[-1]) : \
|
|
||||||
((type)((int *)((list) += sizeof (int)))[-1]))
|
|
||||||
#define vararg_farval(list,type) \
|
|
||||||
(sizeof (type) >= sizeof (int) ? \
|
|
||||||
(((type *)((list) += sizeof (type)))[-1]) : \
|
|
||||||
(((int *)((list) += sizeof (int)))[-1]))
|
|
||||||
#define begin_arg_stack(name) char name[0
|
|
||||||
#define add_to_arg_stack(type) + (sizeof (type) > sizeof (int) ? \
|
|
||||||
sizeof (type) : sizeof (int))
|
|
||||||
#define end_arg_stack ];
|
|
||||||
#define arg_stack_push(list,type,val) \
|
|
||||||
(sizeof (type) >= sizeof (int) ? \
|
|
||||||
(((type *)((list) += sizeof (type)))[-1] = (val)) : \
|
|
||||||
(((int *)((list) += sizeof (int)))[-1] = (int)(val)))
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* _VARARGS_H */
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user