1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696
|
diff -ruN -x Makefile -x Makefile.in -x configure koth-0.7.5.orig/configure.in koth-0.7.5/configure.in
--- koth-0.7.5.orig/configure.in Mon Aug 23 12:15:51 1999
+++ koth-0.7.5/configure.in Sat Aug 28 22:07:08 1999
@@ -27,6 +27,12 @@
exit)
fi
+DEFAULT_SERVER="localhost"
+AC_SUBST(DEFAULT_SERVER)
+AC_ARG_WITH(default_server,
+ [ --with-default-server=string Default localhost],
+ DEFAULT_SERVER="$withval")
+
AC_CHECK_LIB(m, cos, REQLIBS=" -lm $REQLIBS",
AC_MSG_ERROR("You do not have a math library??? KOTH cannot continue\!"))
AC_CHECK_LIB(socket, socket)
@@ -42,4 +48,4 @@
AC_SUBST(CLIENTLIBS)
AC_SUBST(REQLIBS)
-AC_OUTPUT(Makefile src/Makefile src/baseimages/Makefile src/weapons/Makefile doc/Makefile)
\ No newline at end of file
+AC_OUTPUT(Makefile src/Makefile src/baseimages/Makefile src/weapons/Makefile doc/Makefile)
diff -ruN -x Makefile -x Makefile.in -x configure koth-0.7.5.orig/src/ai-moron.c koth-0.7.5/src/ai-moron.c
--- koth-0.7.5.orig/src/ai-moron.c Sat Aug 28 23:47:14 1999
+++ koth-0.7.5/src/ai-moron.c Sat Aug 28 17:14:23 1999
@@ -38,6 +38,7 @@
#include "../config.h"
#define DEFAULT_PORT 8086
+#define DEFAULT_SERVER "localhost"
static RNDLIST *name_list;
@@ -97,52 +98,65 @@
{
char buf[548];
int sock;
- char* server="localhost";
+ char* server=NULL, *configfile=NULL;
int go;
- int port;
+ int port=0;
char *name=NULL;
char *helptext =
-" Options:
- -sNAME server to connect to (default localhost)
- -nNAME name to join with (default \"AI-moron\")";
- int sset=0,pset=0;
+"Syntax: %s [-fFilename] [-sName] [-nName] [-pPort]
+ -fSTR configuration file to use (default %s)
+ -sSTR server to connect to (default localhost)
+ -nSTR name to join with (default \"AI-moron\")
+ -pINT port to connect to (default 8086)
+ -lSTR 'critical', 'interesting', 'debug', 'spam'
+ -h this help text.";
+
logPrintf(INTERESTING, "King of the Hill (KOTH) Moron AI version %s\n", VERSION);
logPrintf(INTERESTING, "Copyright (C) 1999 Peter Amstutz\n");
logPrintf(INTERESTING, "KOTH comes with ABSOLUTELY NO WARRANTY\n");
logPrintf(INTERESTING, "This is free software, and you are welcome to redistribute it\n");
logPrintf(INTERESTING, "under the conditions of the GNU GPL\n");
- while(1)
+ while((go=getopt(argc, argv, "f:s:n:p:l:h")) != EOF)
{
- go=getopt(argc, argv, "s:n:");
- if(go==EOF) break;
switch(go)
{
+ case 'f':
+ configfile=strdup(optarg);
+ break;
case 's':
server=strdup(optarg);
- sset=1;
break;
case 'n':
name=strdup(optarg);
break;
+ case 'p':
+ port=atoi(optarg);
+ break;
+ case 'l':
+ if(strcmp(optarg, "critical")==0)
+ log_level=CRITICAL;
+ else if(strcmp(optarg, "interesting")==0)
+ log_level=INTERESTING;
+ else if(strcmp(optarg, "debug")==0)
+ log_level=DEBUG;
+ else if(strcmp(optarg, "spam")==0)
+ log_level=SPAM;
+ else
+ logPrintf(CRITICAL, "Bad log level %s\n", optarg);
+ break;
case 'h':
puts(helptext);
exit(0);
- break;
}
}
- if(server==NULL)
- {
- puts(helptext);
- exit(-1);
- }
-
- cfg_configuration=cfgReadConfiguration(DEFAULT_CONFIGFILE);
+ if(configfile==NULL) configfile=DEFAULT_CONFIGFILE;
+ cfg_configuration=cfgReadConfiguration(configfile);
if(cfg_configuration !=NULL)
{
- if(!sset)
+ if(server==NULL)
{
if(! cfgLoadConfigItemStr(cfg_configuration, "server.host", &server))
{
@@ -151,14 +165,12 @@
}
}
- cfgLoadConfigItemInt(cfg_configuration, "server.port", &port);
+ if(port==0) cfgLoadConfigItemInt(cfg_configuration, "server.port", &port);
}
- else
- {
- if(! pset) port=DEFAULT_PORT;
- }
-
+ if(port==0) port=DEFAULT_PORT;
+ if(server==NULL) server=DEFAULT_SERVER;
+
if((sock=tcpDial(server, port)) < 0)
{
logPrintf(CRITICAL, "Server not responding\n");
diff -ruN -x Makefile -x Makefile.in -x configure koth-0.7.5.orig/src/game.h koth-0.7.5/src/game.h
--- koth-0.7.5.orig/src/game.h Sat Aug 28 23:47:13 1999
+++ koth-0.7.5/src/game.h Sat Aug 28 23:44:08 1999
@@ -36,4 +36,7 @@
extern int gm_dq_pos;
extern int gm_killNumber; /* how many people have died so far */
extern int gm_def_armor;
+extern Weapon_wep *wepDefaultWeapon;
+
+
#endif
diff -ruN -x Makefile -x Makefile.in -x configure koth-0.7.5.orig/src/kclient.c koth-0.7.5/src/kclient.c
--- koth-0.7.5.orig/src/kclient.c Sat Aug 28 23:47:14 1999
+++ koth-0.7.5/src/kclient.c Sat Aug 28 02:22:35 1999
@@ -41,13 +41,14 @@
#include "../config.h"
#define DEFAULT_PORT 8086
-#define HELP_TEXT "Syntax: %s [-fFilename] [-sName] [-xRes] [-yRes]\n" \
+#define HELP_TEXT "Syntax: %s [-fFilename] [-sName] [-xRes] [-yRes] [-pPort] [-lLevel] [-d] [-o]\n" \
"Options:\n"\
" -fSTR configuration file to use (default %s)\n" \
" -sSTR server to connect to\n" \
" -pINT port to connect to (default 8086)\n" \
" -xINT horizontal resolution (default 640)\n" \
" -yINT vertical resolution (default 480)\n" \
+ " -lSTR 'critical', 'interesting', 'debug', 'spam'\n" \
" -d record a demo\n" \
" -o observe a demo\n"
@@ -201,6 +202,7 @@
break;
}
}
+logPrintf(INTERESTING,"configfile=%s\n", configfile);
/*
if(configfile==NULL)
configfile=DEFAULT_CONFIGFILE;
@@ -243,10 +245,15 @@
}
gfxInit();
+ logPrintf(INTERESTING, "foo\n ");
txtInit();
+ logPrintf(INTERESTING, "foo\n ");
wepInit();
+ logPrintf(INTERESTING, "foo\n ");
wgxInit();
+ logPrintf(INTERESTING, "foo\n ");
balInit();
+ logPrintf(INTERESTING, "foo\n ");
pl_tankwidth=ter_sizex/TANKSCREENRATIO_X;
pl_tankheight=ter_sizey/TANKSCREENRATIO_Y;
@@ -265,6 +272,8 @@
clBuyWeapon, clSellWeapon, clDrawWeaponElement);
tmp=wep_WeaponList;
do {
+ int c = 0;
+ logPrintf(INTERESTING, "%i ", c++);
if(tmp->cost > 0)
txtAddToListBox(wpnlist, tmp->name);
tmp=tmp->next;
diff -ruN -x Makefile -x Makefile.in -x configure koth-0.7.5.orig/src/koth.cfg koth-0.7.5/src/koth.cfg
--- koth-0.7.5.orig/src/koth.cfg Tue Aug 24 19:46:42 1999
+++ koth-0.7.5/src/koth.cfg Sat Aug 28 00:38:17 1999
@@ -41,3 +41,10 @@
capital=2400 # tank startup money
stipend=600 # money tank gets "for free" each turn
bounty=1200 # money tank gets for each kill
+
+[weapons]
+count=13
+id-13=12
+name-13=Napalm
+cost-13=500
+count-13=1
diff -ruN -x Makefile -x Makefile.in -x configure koth-0.7.5.orig/src/player.c koth-0.7.5/src/player.c
--- koth-0.7.5.orig/src/player.c Sat Aug 28 23:47:14 1999
+++ koth-0.7.5/src/player.c Sat Aug 28 23:30:31 1999
@@ -79,7 +79,7 @@
pl_end->itemstock->next=pl_end->itemstock;
pl_end->itemstock->prev=pl_end->itemstock;
pl_end->itemstock->type=WEAPON;
- (Weapon_wep*)pl_end->itemstock->info=wepLookupWeapon("Basic Shell");
+ (Weapon_wep*)pl_end->itemstock->info=wepDefaultWeapon;
pl_end->itemstock->count=0x0FFFFFFF;
return pl_end;
}
@@ -135,21 +135,21 @@
{
amt -= pl->shield;
pl->shield=0;
- }
+ pl->armor-=amt;
+ if(pl->armor <= 0)
+ {
+ plDestroyTank(pl, srcid);
+ return 1;
+ }
else
{
pl->shield -= amt;
amt=0;
}
- pl->armor-=amt;
if(pl==gm_myplstruct) gm_tank_damaged=1;
logPrintf(DEBUG, "Damage of tank %s is %i\n", pl->name, pl->armor);
- if(pl->armor <= 0)
- {
- plDestroyTank(pl, srcid);
- return 1;
} else return 0;
}
diff -ruN -x Makefile -x Makefile.in -x configure koth-0.7.5.orig/src/weapons/weapon.c koth-0.7.5/src/weapons/weapon.c
--- koth-0.7.5.orig/src/weapons/weapon.c Sat Aug 28 23:47:13 1999
+++ koth-0.7.5/src/weapons/weapon.c Sat Aug 28 02:03:20 1999
@@ -19,9 +19,12 @@
#include <math.h>
#include <stdlib.h>
+#include <stdio.h>
#include "weapon.h"
#include "../ballistics.h"
#include "../terrain.h"
+#include "../cfgfile.h"
+#include "../log.h"
#include "basic.h"
#include "large.h"
@@ -40,137 +43,229 @@
/* note: WeaponList is a CIRCULAR linked list! */
Weapon_wep *wep_WeaponList=NULL;
-void wepAddWeapon(char* name, int cost, int count,
- Shellstat_bal (*initguidance)(int id, struct Projectilepos_bal *prjpos, void** guideshotinfo,
- Shellstat_bal (*initexplosion)(int id, struct Projectilepos_bal *prjpos,
- void** explosioninfo),
- void** explosioninfo),
- Shellstat_bal (*doguidance)(void* info, struct Projectilepos_bal *prjpos,
- Shellstat_bal (*initexplosion)(int id, struct Projectilepos_bal *prjpos,
- void** explosioninfo),
- void **explosioninfo),
- Shellstat_bal (*initexplosion)(int id, struct Projectilepos_bal *prjpos,
- void** explosioninfo),
- Shellstat_bal (*doexplosion)(void* info))
+
+void wepAddWeaponPrivate(int id, char *name, int cost, int count,
+ Shellstat_bal (*initguidance)(int id, struct Projectilepos_bal *prjpos, void** guideshotinfo,
+ Shellstat_bal (*initexplosion)(int id, struct Projectilepos_bal *prjpos, void** explosioninfo),
+ void** explosioninfo),
+ Shellstat_bal (*doguidance)(void* info, struct Projectilepos_bal *prjpos, Shellstat_bal (*initexplosion)(int id, struct Projectilepos_bal *prjpos, void** explosioninfo),
+ void **explosioninfo),
+ Shellstat_bal (*initexplosion)(int id, struct Projectilepos_bal *prjpos, void** explosioninfo),
+ Shellstat_bal (*doexplosion)(void* info))
{
Weapon_wep *wnew=(Weapon_wep*)malloc(sizeof(Weapon_wep));
+ wnew->id=id;
wnew->name=name;
- wnew->cost=cost;
- wnew->count=count;
+ wnew->cost=cost;
+ wnew->count=count;
wnew->initguidance=initguidance;
wnew->doguidance=doguidance;
wnew->initexplosion=initexplosion;
wnew->doexplosion=doexplosion;
- wnew->drawshot=NULL;
- wnew->drawexplosion=NULL;
+ wnew->drawshot=NULL;
+ wnew->drawexplosion=NULL;
if(wep_WeaponList)
{
- wnew->next=wep_WeaponList;
- wnew->prev=wep_WeaponList->prev;
- wnew->next->prev=wnew;
- wnew->prev->next=wnew;
- wep_WeaponList=wnew;
+ wnew->next=wep_WeaponList;
+ wnew->prev=wep_WeaponList->prev;
+ wnew->next->prev=wnew;
+ wnew->prev->next=wnew;
+ wep_WeaponList=wnew;
}
else
{
- wnew->next=wnew;
- wnew->prev=wnew;
- wep_WeaponList=wnew;
+ wnew->next=wnew;
+ wnew->prev=wnew;
+ wep_WeaponList=wnew;
}
}
+void wepAddWeapon(char *name, int cost, int count,
+ Shellstat_bal (*initguidance)(int id, struct Projectilepos_bal *prjpos, void** guideshotinfo,
+ Shellstat_bal (*initexplosion)(int id, struct Projectilepos_bal *prjpos, void** explosioninfo),
+ void** explosioninfo),
+ Shellstat_bal (*doguidance)(void* info, struct Projectilepos_bal *prjpos, Shellstat_bal (*initexplosion)(int id, struct Projectilepos_bal *prjpos, void** explosioninfo),
+ void **explosioninfo),
+ Shellstat_bal (*initexplosion)(int id, struct Projectilepos_bal *prjpos, void** explosioninfo),
+ Shellstat_bal (*doexplosion)(void* info))
+{
+ wepAddWeaponPrivate(-1, name, cost, count,
+ initguidance,
+ doguidance,
+ initexplosion,
+ doexplosion);
+}
+void wepAddWeaponId(int id,
+ Shellstat_bal (*initguidance)(int id, struct Projectilepos_bal *prjpos, void** guideshotinfo,
+ Shellstat_bal (*initexplosion)(int id, struct Projectilepos_bal *prjpos, void** explosioninfo),
+ void** explosioninfo),
+ Shellstat_bal (*doguidance)(void* info, struct Projectilepos_bal *prjpos, Shellstat_bal (*initexplosion)(int id, struct Projectilepos_bal *prjpos, void** explosioninfo),
+ void **explosioninfo),
+ Shellstat_bal (*initexplosion)(int id, struct Projectilepos_bal *prjpos, void** explosioninfo),
+ Shellstat_bal (*doexplosion)(void* info))
+{
+ wepAddWeaponPrivate(id, NULL, 0, 0,
+ initguidance,
+ doguidance,
+ initexplosion,
+ doexplosion);
+}
Weapon_wep *wepLookupWeapon(char *name)
{
Weapon_wep *wcur;
+ if(wep_WeaponList==NULL) return NULL;
+ for(wcur=wep_WeaponList;wcur!=wep_WeaponList;wcur=wcur->next)
+ if(wep_WeaponList->name != NULL && (strcmp(name, wep_WeaponList->name) == 0))
+ return wcur;
+ return NULL;
+}
+Weapon_wep *wepLookupWeaponId(int id)
+{
+ Weapon_wep *wcur;
if(wep_WeaponList==NULL) return NULL;
- if(strcmp(name, wep_WeaponList->name)==0) return wep_WeaponList;
+ if(wep_WeaponList->id==id) return wep_WeaponList;
wcur=wep_WeaponList;
do {
- if(strcmp(name, wcur->name)==0) return wcur;
+ if(wcur->id==id) return wcur;
wcur=wcur->next;
} while(wcur!=wep_WeaponList);
- return NULL;
+ return NULL;
}
void wepInit()
{
- wepAddWeapon("Basic Shell", 0, 1,
+ int num_weapons = 0;
+
+/* Add static, helper weapons. These are used by the dynamic weapons loaded later. */
+ wepAddWeapon("Cluster Fragment", 0, 1,
+ wepBasicInit,
+ wepBasicGuidance,
+ wepFragmentExplosionInit,
+ wepSimpleExplosion);
+ wepAddWeapon("Roller Ball", 0, 1,
+ wepRollerInit,
+ wepRollerGuidance,
+ wepTacNukeExplosionInit,
+ wepSimpleExplosion);
+ wepAddWeapon("Burning Napalm", 0, 1,
+ wepBasicInit,
+ wepBasicGuidance,
+ wepBurningNapalmExplosionInit,
+ wepBurningNapalmExplosion);
+/* Now load the dynamic weapons */
+/* Basic Shell */
+ wepAddWeaponId(wepBASIC_SHELL,
wepBasicInit,
wepBasicGuidance,
wepBasicExplosionInit,
wepSimpleExplosion);
- wepAddWeapon("Large Shell", 50, 1,
+/* Large Shell */
+ wepAddWeaponId(wepLARGE_SHELL,
wepBasicInit,
wepBasicGuidance,
wepLargeExplosionInit,
wepSimpleExplosion);
- wepAddWeapon("Tac Nuke", 800, 1,
+/* Tac Nuke */
+ wepAddWeaponId(wepTAC_NUKE,
wepBasicInit,
wepBasicGuidance,
wepTacNukeExplosionInit,
wepSimpleExplosion);
- wepAddWeapon("Super Nuke", 1400, 1,
+/* Super Nuke */
+ wepAddWeaponId(wepSUPER_NUKE,
wepBasicInit,
wepBasicGuidance,
wepSuperNukeExplosionInit,
wepSimpleExplosion);
- wepAddWeapon("Cluster Bomb", 250, 1,
+/* Cluster Bomb */
+ wepAddWeaponId(wepCLUSTER_BOMB,
wepBasicInit,
wepBasicGuidance,
wepClusterExplosionInit,
NULL);
- wepAddWeapon("Cluster Fragment", 0, 1,
- wepBasicInit,
- wepBasicGuidance,
- wepFragmentExplosionInit,
- wepSimpleExplosion);
- wepAddWeapon("MIRV", 300, 1,
+/* MIRV */
+ wepAddWeaponId(wepMIRV,
wepBasicInit,
wepMIRVGuidance,
wepBasicExplosionInit,
wepSimpleExplosion);
- wepAddWeapon("Dirt Ball", 200, 1,
+/* Dirt Ball */
+ wepAddWeaponId(wepDIRT_BALL,
wepBasicInit,
wepBasicGuidance,
wepDirtExplosionInit,
wepDirtExplosion);
- wepAddWeapon("Roller", 900, 1,
+/* Roller */
+ wepAddWeaponId(wepROLLER,
wepBasicInit,
wepBasicGuidance,
wepRollerExplosionInit,
NULL);
- wepAddWeapon("Roller Ball", 0, 1,
- wepRollerInit,
- wepRollerGuidance,
- wepTacNukeExplosionInit,
- wepSimpleExplosion);
- wepAddWeapon("Death From Above", 600, 1,
+/* Death From Above */
+ wepAddWeaponId(wepDEATH_FROM_ABOVE,
wepBasicInit,
wepDFAGuidance,
wepBasicExplosionInit,
wepSimpleExplosion);
- wepAddWeapon("Funky Bomb", 500, 1,
+/* Funky Bomb */
+ wepAddWeaponId(wepFUNKY_BOMB,
wepBasicInit,
wepFunkyGuidance,
wepBasicExplosionInit,
wepSimpleExplosion);
-
- wepAddWeapon("Tunneler", 50, 1,
+/* Tunneler */
+ wepAddWeaponId(wepTUNNELER,
wepTunnelInit,
wepTunnelGuidance,
NULL,
NULL);
- wepAddWeapon("Napalm", 500, 1,
+/* Napalm */
+ wepAddWeaponId(wepNAPALM,
wepBasicInit,
wepNapalmGuidance,
wepBasicExplosionInit,
wepSimpleExplosion);
- wepAddWeapon("Burning Napalm", 0, 1,
- wepBasicInit,
- wepBasicGuidance,
- wepBurningNapalmExplosionInit,
- wepBurningNapalmExplosion);
+
+
+ if(! cfgLoadConfigItemInt(cfg_configuration, "weapons.count", &num_weapons))
+ logPrintf(CRITICAL, "No weapons defined in config file!\n");
+ for(; num_weapons > 0; num_weapons--) {
+ char *name, myCfgItem[30];
+ int cost=0, count=0, id=0;
+ Weapon_wep *wep=NULL;
+ snprintf(myCfgItem, sizeof(myCfgItem), "weapons.id-%i", num_weapons);
+ if(! cfgLoadConfigItemInt(cfg_configuration, myCfgItem, &id)) {
+ logPrintf(CRITICAL, "Couldn't find %s in config file!\n", myCfgItem);
+ continue;
+ }
+
+ snprintf(myCfgItem, sizeof(myCfgItem), "weapons.name-%i", num_weapons);
+ if(! cfgLoadConfigItemStr(cfg_configuration, myCfgItem, &name)) {
+ logPrintf(CRITICAL, "Couldn't find %s in config file!\n", myCfgItem);
+ continue;
+ }
+
+ snprintf(myCfgItem, sizeof(myCfgItem), "weapons.cost-%i", num_weapons);
+ if(! cfgLoadConfigItemInt(cfg_configuration, myCfgItem, &cost)) {
+ logPrintf(CRITICAL, "Couldn't find %s in config file!\n", myCfgItem);
+ continue;
+ }
+
+ snprintf(myCfgItem, sizeof(myCfgItem), "weapons.count-%i", num_weapons);
+ if(! cfgLoadConfigItemInt(cfg_configuration, myCfgItem, &count)) {
+ logPrintf(CRITICAL, "Couldn't find %s in config file!\n", myCfgItem);
+ continue;
+ }
+
+ if((wep=wepLookupWeaponId(id))==NULL) {
+ logPrintf(CRITICAL, "Couldn't find weapon id %i!\n", id);
+ continue;
+ }
+ wep->name=name;
+ wep->cost=cost;
+ wep->count=count;
+ }
}
diff -ruN -x Makefile -x Makefile.in -x configure koth-0.7.5.orig/src/weapons/weapon.h koth-0.7.5/src/weapons/weapon.h
--- koth-0.7.5.orig/src/weapons/weapon.h Sat Aug 28 23:47:13 1999
+++ koth-0.7.5/src/weapons/weapon.h Sat Aug 28 01:31:59 1999
@@ -28,27 +28,23 @@
typedef struct Weapon_wep
{
- char* name;
-
- Shellstat_bal (*initguidance)(int id, struct Projectilepos_bal *prjpos, void** guideshotinfo,
- Shellstat_bal (*initexplosion)(int id, struct Projectilepos_bal *prjpos,
- void** explosioninfo),
- void** explosioninfo);
- Shellstat_bal(*doguidance)(void* info, struct Projectilepos_bal *prjpos,
- Shellstat_bal (*initexplosion)(int id, struct Projectilepos_bal *prjpos,
- void** explosioninfo),
- void** explosioninfo);
- void (*drawshot)(struct Projectilepos_bal *prjpos, void* info); /* handles drawing/erasing of the shell */
- Shellstat_bal (*initexplosion)(int id, struct Projectilepos_bal *prjpos,
- void** explosioninfo);
- Shellstat_bal (*doexplosion)(void* info);
- void (*drawexplosion)(void* info); /* handles drawing/erasing of the explosion */
+ char* name;
+ int cost, count, id;
- struct Weapon_wep *next;
- struct Weapon_wep *prev;
+ Shellstat_bal (*initguidance)(int id, struct Projectilepos_bal *prjpos, void** guideshotinfo,
+ Shellstat_bal (*initexplosion)(int id, struct Projectilepos_bal *prjpos, void** explosioninfo),
+ void** explosioninfo);
+ Shellstat_bal(*doguidance)(void* info, struct Projectilepos_bal *prjpos,
+ Shellstat_bal (*initexplosion)(int id, struct Projectilepos_bal *prjpos, void** explosioninfo),
+ void** explosioninfo);
+ void (*drawshot)(struct Projectilepos_bal *prjpos, void* info); /* handles drawing/erasing of the shell */
+ Shellstat_bal (*initexplosion)(int id, struct Projectilepos_bal *prjpos, void** explosioninfo);
+ Shellstat_bal (*doexplosion)(void* info);
+ void (*drawexplosion)(void* info); /* handles drawing/erasing of the explosion */
+
+ struct Weapon_wep *next;
+ struct Weapon_wep *prev;
- int cost;
- int count;
} Weapon_wep;
@@ -72,16 +68,25 @@
void wepInit();
Weapon_wep *wepLookupWeapon(char *name);
void wepAddWeapon(char* name, int cost, int count,
- Shellstat_bal (*initguidance)(int id, struct Projectilepos_bal *prjpos, void** guideshotinfo,
- Shellstat_bal (*initexplosion)(int id, struct Projectilepos_bal *prjpos,
- void** explosioninfo),
- void** explosioninfo),
- Shellstat_bal (*doguidance)(void* info, struct Projectilepos_bal *prjpos,
- Shellstat_bal (*initexplosion)(int id, struct Projectilepos_bal *prjpos,
- void** explosioninfo),
- void **explosioninfo),
- Shellstat_bal (*initexplosion)(int id, struct Projectilepos_bal *prjpos,
- void** explosioninfo),
- Shellstat_bal (*doexplosion)(void* info));
+ Shellstat_bal (*initguidance)(int id, struct Projectilepos_bal *prjpos, void** guideshotinfo,
+ Shellstat_bal (*initexplosion)(int id, struct Projectilepos_bal *prjpos, void** explosioninfo),
+ void** explosioninfo),
+ Shellstat_bal (*doguidance)(void* info, struct Projectilepos_bal *prjpos,
+ Shellstat_bal (*initexplosion)(int id, struct Projectilepos_bal *prjpos, void** explosioninfo),
+ void **explosioninfo),
+ Shellstat_bal (*initexplosion)(int id, struct Projectilepos_bal *prjpos, void** explosioninfo),
+ Shellstat_bal (*doexplosion)(void* info));
#endif
+#define wepBASIC_SHELL 0
+#define wepLARGE_SHELL 1
+#define wepTAC_NUKE 2
+#define wepSUPER_NUKE 3
+#define wepCLUSTER_BOMB 4
+#define wepMIRV 5
+#define wepDIRT_BALL 6
+#define wepROLLER 7
+#define wepDEATH_FROM_ABOVE 8
+#define wepFUNKY_BOMB 9
+#define wepTUNNELER 10
+#define wepNAPALM 11
diff -ruN -x Makefile -x Makefile.in -x configure koth-0.7.5.orig/src/weapons/weapongfx.c koth-0.7.5/src/weapons/weapongfx.c
--- koth-0.7.5.orig/src/weapons/weapongfx.c Sat Aug 28 23:47:13 1999
+++ koth-0.7.5/src/weapons/weapongfx.c Sat Aug 28 02:03:49 1999
@@ -19,6 +19,7 @@
#include "weapon.h"
#include "../gfx.h"
+#include "../log.h"
#include "simplegfx.h"
#include "dirtgfx.h"
@@ -36,21 +37,33 @@
wcur->drawexplosion=drawexplosion;
}
+void wgxSetWeaponDrawFuncId(int id,
+ void (*drawshot)(struct Projectilepos_bal *prjpos, void* info),
+ void (*drawexplosion)(void* info))
+{
+ Weapon_wep *wcur;
+
+ wcur=wepLookupWeaponId(id);
+ if(wcur==NULL) return;
+ wcur->drawshot=drawshot;
+ wcur->drawexplosion=drawexplosion;
+}
+
void wgxInit()
{
- wgxSetWeaponDrawFunc("Basic Shell", wgxDrawSimpleShot, wgxDrawSimpleExplosion);
- wgxSetWeaponDrawFunc("Large Shell", wgxDrawSimpleShot, wgxDrawSimpleExplosion);
- wgxSetWeaponDrawFunc("Tac Nuke", wgxDrawSimpleShot, wgxDrawSimpleExplosion);
- wgxSetWeaponDrawFunc("Super Nuke", wgxDrawSimpleShot, wgxDrawSimpleExplosion);
- wgxSetWeaponDrawFunc("Cluster Bomb", wgxDrawSimpleShot, NULL);
+ wgxSetWeaponDrawFuncId(wepBASIC_SHELL, wgxDrawSimpleShot, wgxDrawSimpleExplosion);
+ wgxSetWeaponDrawFuncId(wepLARGE_SHELL, wgxDrawSimpleShot, wgxDrawSimpleExplosion);
+ wgxSetWeaponDrawFuncId(wepTAC_NUKE, wgxDrawSimpleShot, wgxDrawSimpleExplosion);
+ wgxSetWeaponDrawFuncId(wepSUPER_NUKE, wgxDrawSimpleShot, wgxDrawSimpleExplosion);
+ wgxSetWeaponDrawFuncId(wepCLUSTER_BOMB, wgxDrawSimpleShot, NULL);
wgxSetWeaponDrawFunc("Cluster Fragment", wgxDrawSimpleShot, wgxDrawSimpleExplosion);
- wgxSetWeaponDrawFunc("MIRV", wgxDrawSimpleShot, wgxDrawSimpleExplosion);
- wgxSetWeaponDrawFunc("Dirt Ball", wgxDrawSimpleShot, wgxDrawDirtExplosion);
- wgxSetWeaponDrawFunc("Roller", wgxDrawSimpleShot, NULL);
+ wgxSetWeaponDrawFuncId(wepMIRV, wgxDrawSimpleShot, wgxDrawSimpleExplosion);
+ wgxSetWeaponDrawFuncId(wepDIRT_BALL, wgxDrawSimpleShot, wgxDrawDirtExplosion);
+ wgxSetWeaponDrawFuncId(wepROLLER, wgxDrawSimpleShot, NULL);
wgxSetWeaponDrawFunc("Roller Ball", wgxDrawSimpleShot, wgxDrawSimpleExplosion);
- wgxSetWeaponDrawFunc("Death From Above", wgxDrawSimpleShot, wgxDrawSimpleExplosion);
- wgxSetWeaponDrawFunc("Funky Bomb", wgxDrawSimpleShot, wgxDrawSimpleExplosion);
- wgxSetWeaponDrawFunc("Tunneler", wgxDrawSimpleShot, wgxDrawSimpleExplosion);
- wgxSetWeaponDrawFunc("Napalm", wgxDrawSimpleShot, wgxDrawSimpleExplosion);
+ wgxSetWeaponDrawFuncId(wepDEATH_FROM_ABOVE, wgxDrawSimpleShot, wgxDrawSimpleExplosion);
+ wgxSetWeaponDrawFuncId(wepFUNKY_BOMB, wgxDrawSimpleShot, wgxDrawSimpleExplosion);
+ wgxSetWeaponDrawFuncId(wepTUNNELER, wgxDrawSimpleShot, wgxDrawSimpleExplosion);
+ wgxSetWeaponDrawFuncId(wepNAPALM, wgxDrawSimpleShot, wgxDrawSimpleExplosion);
wgxSetWeaponDrawFunc("Burning Napalm", wgxDrawBurningNapalmShot, wgxDrawBurningNapalmExplosion);
}
|