1 | /* |
1 | /* |
2 | * static char *rcsid_map_c = |
2 | * static char *rcsid_map_c = |
3 | * "$Id: map.C,v 1.19 2006/08/31 18:59:23 root Exp $"; |
3 | * "$Id: map.C,v 1.21 2006/09/03 22:45:55 root Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
482 | op->x += tmp->x; |
482 | op->x += tmp->x; |
483 | op->y += tmp->y; |
483 | op->y += tmp->y; |
484 | op->head = tmp; |
484 | op->head = tmp; |
485 | op->map = m; |
485 | op->map = m; |
486 | last->more = op; |
486 | last->more = op; |
487 | if (tmp->name != op->name) { |
|
|
488 | if (op->name) free_string(op->name); |
|
|
489 | op->name = add_string(tmp->name); |
487 | op->name = tmp->name; |
490 | } |
|
|
491 | if (tmp->title != op->title) { |
|
|
492 | if (op->title) free_string(op->title); |
|
|
493 | op->title = add_string(tmp->title); |
488 | op->title = tmp->title; |
494 | } |
|
|
495 | /* we could link all the parts onto tmp, and then just |
489 | /* we could link all the parts onto tmp, and then just |
496 | * call insert_ob_in_map once, but the effect is the same, |
490 | * call insert_ob_in_map once, but the effect is the same, |
497 | * as insert_ob_in_map will call itself with each part, and |
491 | * as insert_ob_in_map will call itself with each part, and |
498 | * the coding is simpler to just to it here with each part. |
492 | * the coding is simpler to just to it here with each part. |
499 | */ |
493 | */ |
… | |
… | |
509 | * file pointer. |
503 | * file pointer. |
510 | * mapflags is the same as we get with load_original_map |
504 | * mapflags is the same as we get with load_original_map |
511 | */ |
505 | */ |
512 | |
506 | |
513 | void load_objects (mapstruct *m, object_thawer &fp, int mapflags) { |
507 | void load_objects (mapstruct *m, object_thawer &fp, int mapflags) { |
514 | int i,j,bufstate=LO_NEWFILE; |
508 | int i,j; |
515 | int unique; |
509 | int unique; |
516 | object *op, *prev=NULL,*last_more=NULL, *otmp; |
510 | object *op, *prev=NULL,*last_more=NULL, *otmp; |
517 | |
511 | |
518 | op=get_object(); |
512 | op=get_object(); |
519 | op->map = m; /* To handle buttons correctly */ |
513 | op->map = m; /* To handle buttons correctly */ |
520 | |
514 | |
521 | while((i = load_object (fp, op, bufstate, mapflags))) { |
515 | while((i = load_object (fp, op, mapflags))) { |
522 | /* Since the loading of the map header does not load an object |
|
|
523 | * anymore, we need to pass LO_NEWFILE for the first object loaded, |
|
|
524 | * and then switch to LO_REPEAT for faster loading. |
|
|
525 | */ |
|
|
526 | bufstate = LO_REPEAT; |
|
|
527 | |
|
|
528 | /* if the archetype for the object is null, means that we |
516 | /* if the archetype for the object is null, means that we |
529 | * got an invalid object. Don't do anything with it - the game |
517 | * got an invalid object. Don't do anything with it - the game |
530 | * or editor will not be able to do anything with it either. |
518 | * or editor will not be able to do anything with it either. |
531 | */ |
519 | */ |
532 | if (op->arch==NULL) { |
520 | if (op->arch==NULL) { |
… | |
… | |
618 | * Modified to no longer take a path option which was not being |
606 | * Modified to no longer take a path option which was not being |
619 | * used anyways. MSW 2001-07-01 |
607 | * used anyways. MSW 2001-07-01 |
620 | */ |
608 | */ |
621 | |
609 | |
622 | mapstruct *get_linked_map(void) { |
610 | mapstruct *get_linked_map(void) { |
623 | mapstruct *map=(mapstruct *) calloc(1,sizeof(mapstruct)); |
611 | mapstruct *map = new mapstruct; |
624 | mapstruct *mp; |
612 | mapstruct *mp; |
625 | |
|
|
626 | if(map==NULL) |
|
|
627 | fatal(OUT_OF_MEMORY); |
|
|
628 | |
613 | |
629 | for(mp=first_map;mp!=NULL&&mp->next!=NULL;mp=mp->next); |
614 | for(mp=first_map;mp!=NULL&&mp->next!=NULL;mp=mp->next); |
630 | if(mp==NULL) |
615 | if(mp==NULL) |
631 | first_map=map; |
616 | first_map=map; |
632 | else |
617 | else |
… | |
… | |
888 | * what really should be used. |
873 | * what really should be used. |
889 | */ |
874 | */ |
890 | else if (!strcmp(key,"oid")) { |
875 | else if (!strcmp(key,"oid")) { |
891 | fp.get (m, atoi(value)); |
876 | fp.get (m, atoi(value)); |
892 | } else if (!strcmp(key, "attach")) { |
877 | } else if (!strcmp(key, "attach")) { |
893 | m->attach = add_string (value); |
878 | m->attach = value; |
894 | } else if (!strcmp(key,"hp") || !strcmp(key, "enter_x")) { |
879 | } else if (!strcmp(key,"hp") || !strcmp(key, "enter_x")) { |
895 | m->enter_x = atoi(value); |
880 | m->enter_x = atoi(value); |
896 | } else if (!strcmp(key,"sp") || !strcmp(key, "enter_y")) { |
881 | } else if (!strcmp(key,"sp") || !strcmp(key, "enter_y")) { |
897 | m->enter_y = atoi(value); |
882 | m->enter_y = atoi(value); |
898 | } else if (!strcmp(key,"x") || !strcmp(key, "width")) { |
883 | } else if (!strcmp(key,"x") || !strcmp(key, "width")) { |
… | |
… | |
1179 | return; |
1164 | return; |
1180 | |
1165 | |
1181 | m->in_memory=MAP_LOADING; |
1166 | m->in_memory=MAP_LOADING; |
1182 | if (m->tmpname == NULL) /* if we have loaded unique items from */ |
1167 | if (m->tmpname == NULL) /* if we have loaded unique items from */ |
1183 | delete_unique_items(m); /* original map before, don't duplicate them */ |
1168 | delete_unique_items(m); /* original map before, don't duplicate them */ |
1184 | load_object(thawer, NULL, LO_NOREAD,0); |
|
|
1185 | load_objects (m, thawer, 0); |
1169 | load_objects (m, thawer, 0); |
1186 | |
1170 | |
1187 | m->in_memory=MAP_IN_MEMORY; |
1171 | m->in_memory=MAP_IN_MEMORY; |
1188 | } |
1172 | } |
1189 | |
1173 | |
… | |
… | |
1482 | m->path); |
1466 | m->path); |
1483 | } |
1467 | } |
1484 | else |
1468 | else |
1485 | last->next = m->next; |
1469 | last->next = m->next; |
1486 | |
1470 | |
1487 | free (m); |
1471 | delete m; |
1488 | } |
1472 | } |
1489 | |
1473 | |
1490 | |
1474 | |
1491 | |
1475 | |
1492 | /* |
1476 | /* |
… | |
… | |
1535 | if (flags & MAP_PLAYER_UNIQUE) |
1519 | if (flags & MAP_PLAYER_UNIQUE) |
1536 | LOG(llevDebug, "Trying to load map %s.\n", name); |
1520 | LOG(llevDebug, "Trying to load map %s.\n", name); |
1537 | else |
1521 | else |
1538 | LOG(llevDebug, "Trying to load map %s.\n", create_pathname(name)); |
1522 | LOG(llevDebug, "Trying to load map %s.\n", create_pathname(name)); |
1539 | |
1523 | |
|
|
1524 | //0.427459955215454 /var/crossfire/players/Saladon/_scorn_apartment_apartments |
|
|
1525 | //0.414906024932861 |
|
|
1526 | //0.427063941955566 |
|
|
1527 | eval_pv ("$x = Event::time", 1);//D |
1540 | if (!(m = load_original_map(name, (flags & MAP_PLAYER_UNIQUE)))) |
1528 | if (!(m = load_original_map(name, (flags & MAP_PLAYER_UNIQUE)))) |
1541 | return (NULL); |
1529 | return (NULL); |
|
|
1530 | eval_pv ("warn \"LOAD \", Event::time - $x", 1);//D |
1542 | |
1531 | |
1543 | fix_auto_apply(m); /* Chests which open as default */ |
1532 | fix_auto_apply(m); /* Chests which open as default */ |
1544 | |
1533 | |
1545 | /* If a player unique map, no extra unique object file to load. |
1534 | /* If a player unique map, no extra unique object file to load. |
1546 | * if from the editor, likewise. |
1535 | * if from the editor, likewise. |