ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/arch.C
(Generate patch)

Comparing deliantra/server/common/arch.C (file contents):
Revision 1.20 by root, Thu Sep 14 21:16:11 2006 UTC vs.
Revision 1.22 by root, Thu Sep 14 22:35:53 2006 UTC

16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 20
21 The authors can be reached via e-mail at crossfire-devel@real-time.com 21 The authors can be reached via e-mail at <crossfire@schmorp.de>
22*/ 22*/
23 23
24#include <cassert> 24#include <cassert>
25 25
26#include <tr1/unordered_map> 26#include <tr1/unordered_map>
206 * Last, make a check on the full name. 206 * Last, make a check on the full name.
207 */ 207 */
208int 208int
209item_matched_string (object *pl, object *op, const char *name) 209item_matched_string (object *pl, object *op, const char *name)
210{ 210{
211 char *
212 cp,
213 local_name[MAX_BUF]; 211 char *cp, local_name[MAX_BUF];
214 int 212 int count, retval = 0;
215 count,
216 retval = 0;
217 213
218 strcpy (local_name, name); /* strtok is destructive to name */ 214 strcpy (local_name, name); /* strtok is destructive to name */
219 215
220 for (cp = strtok (local_name, ","); cp; cp = strtok (NULL, ",")) 216 for (cp = strtok (local_name, ","); cp; cp = strtok (NULL, ","))
221 { 217 {
361 */ 357 */
362 358
363void 359void
364init_archetable (void) 360init_archetable (void)
365{ 361{
366 archetype * 362 archetype *at;
367 at;
368 363
369 LOG (llevDebug, " Setting up archetable...\n"); 364 LOG (llevDebug, " Setting up archetable...\n");
370 365
371 for (at = first_archetype; at != NULL; at = (at->more == NULL) ? at->next : at->more) 366 for (at = first_archetype; at != NULL; at = (at->more == NULL) ? at->next : at->more)
372 add_arch (at); 367 add_arch (at);
391 */ 386 */
392 387
393void 388void
394dump_all_archetypes (void) 389dump_all_archetypes (void)
395{ 390{
396 archetype * 391 archetype *at;
397 at;
398 392
399 for (at = first_archetype; at != NULL; at = (at->more == NULL) ? at->next : at->more) 393 for (at = first_archetype; at != NULL; at = (at->more == NULL) ? at->next : at->more)
400 { 394 {
401 dump_arch (at); 395 dump_arch (at);
402 fprintf (logfile, "%s\n", errmsg); 396 fprintf (logfile, "%s\n", errmsg);
404} 398}
405 399
406void 400void
407free_all_archs (void) 401free_all_archs (void)
408{ 402{
409 archetype * 403 archetype *at, *next;
410 at, *
411 next;
412 int
413 i = 0, f = 0; 404 int i = 0, f = 0;
414 405
415 for (at = first_archetype; at != NULL; at = next) 406 for (at = first_archetype; at != NULL; at = next)
416 { 407 {
417 if (at->more) 408 if (at->more)
418 next = at->more; 409 next = at->more;
443 * of archetype-structures. 434 * of archetype-structures.
444 */ 435 */
445void 436void
446first_arch_pass (object_thawer & fp) 437first_arch_pass (object_thawer & fp)
447{ 438{
448 archetype *
449 at, *
450 head = NULL, *last_more = NULL; 439 archetype *at, *head = NULL, *last_more = NULL;
451 440
452 at->clone.arch = first_archetype = at = new archetype; 441 at->clone.arch = first_archetype = at = new archetype;
453 442
454 while (int i = load_object (fp, &at->clone, 0)) 443 while (int i = load_object (fp, &at->clone, 0))
455 { 444 {
524 */ 513 */
525 514
526void 515void
527second_arch_pass (object_thawer & thawer) 516second_arch_pass (object_thawer & thawer)
528{ 517{
529 char
530 buf[MAX_BUF], *
531 variable = buf, *argument, *cp; 518 char buf[MAX_BUF], *variable = buf, *argument, *cp;
532 archetype *
533 at = NULL, *other; 519 archetype *at = NULL, *other;
534 520
535 while (fgets (buf, MAX_BUF, thawer) != NULL) 521 while (fgets (buf, MAX_BUF, thawer) != NULL)
536 { 522 {
537 if (*buf == '#') 523 if (*buf == '#')
538 continue; 524 continue;
579 565
580#ifdef DEBUG 566#ifdef DEBUG
581void 567void
582check_generators (void) 568check_generators (void)
583{ 569{
584 archetype * 570 archetype *at;
585 at;
586 571
587 for (at = first_archetype; at != NULL; at = at->next) 572 for (at = first_archetype; at != NULL; at = at->next)
588 if (QUERY_FLAG (&at->clone, FLAG_GENERATOR) && at->clone.other_arch == NULL) 573 if (QUERY_FLAG (&at->clone, FLAG_GENERATOR) && at->clone.other_arch == NULL)
589 LOG (llevError, "Warning: %s is generator but lacks other_arch.\n", &at->name); 574 LOG (llevError, "Warning: %s is generator but lacks other_arch.\n", &at->name);
590} 575}
598 */ 583 */
599 584
600void 585void
601load_archetypes (void) 586load_archetypes (void)
602{ 587{
603 char
604 filename[MAX_BUF]; 588 char filename[MAX_BUF];
605 589
606#if TIME_ARCH_LOAD 590#if TIME_ARCH_LOAD
607 struct timeval 591 struct timeval
608 tv1, 592 tv1,
609 tv2; 593 tv2;
647 */ 631 */
648 632
649object * 633object *
650arch_to_object (archetype *at) 634arch_to_object (archetype *at)
651{ 635{
652 object * 636 object *op;
653 op;
654 637
655 if (at == NULL) 638 if (at == NULL)
656 { 639 {
657 if (warn_archetypes) 640 if (warn_archetypes)
658 LOG (llevError, "Couldn't find archetype.\n"); 641 LOG (llevError, "Couldn't find archetype.\n");
675 */ 658 */
676 659
677object * 660object *
678create_singularity (const char *name) 661create_singularity (const char *name)
679{ 662{
680 object * op; 663 object *op;
681 char buf[MAX_BUF]; 664 char buf[MAX_BUF];
682 665
683 sprintf (buf, "%s (%s)", ARCH_SINGULARITY, name); 666 sprintf (buf, "%s (%s)", ARCH_SINGULARITY, name);
684 op = get_object (); 667 op = get_object ();
685 op->name = op->name_pl = buf; 668 op->name = op->name_pl = buf;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines