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

Comparing deliantra/server/common/loader.C (file contents):
Revision 1.1 by root, Sun Sep 3 22:45:55 2006 UTC vs.
Revision 1.10 by root, Fri Sep 8 16:51:42 2006 UTC

499 if (thawer.get_sint32 ()) \ 499 if (thawer.get_sint32 ()) \
500 SET_FLAG (op, flag); \ 500 SET_FLAG (op, flag); \
501 else \ 501 else \
502 CLEAR_FLAG (op, flag) \ 502 CLEAR_FLAG (op, flag) \
503 503
504int parse_object (object * op, object_thawer & thawer, int map_flags) 504int parse_object (object *op, object_thawer &thawer, int map_flags)
505{ 505{
506 bool ismore = 0; 506 bool ismore = 0;
507 object *op_inv = op->inv;
507 508
508 for (;;) 509 for (;;)
509 { 510 {
510 keyword kw = thawer.get_kv (); 511 keyword kw = thawer.get_kv ();
511 512
512 switch (kw) 513 switch (kw)
513 { 514 {
515 case KW_Object: // uppercase alias
514 case KW_object: 516 case KW_object:
515 thawer.get (op->name); 517 thawer.get (op->name);
516 518
517 if (op->arch != NULL) 519 if (op->arch != NULL)
518 op->arch->name = op->name; 520 op->arch->name = op->name;
554 } 556 }
555 557
556 parse_object (tmp, thawer, map_flags); 558 parse_object (tmp, thawer, map_flags);
557 559
558 if (tmp->arch) 560 if (tmp->arch)
561 {
559 insert_ob_in_ob (tmp, op); 562 // was: insert_ob_in_ob (tmp, op);
563 // but manually adding it can improve map loading times a lot
564 // also, appending instead of prepending keeps the
565 // save ordering the same between repeated load/saves.
566 CLEAR_FLAG (tmp, FLAG_OBJ_ORIGINAL);
567 CLEAR_FLAG (tmp, FLAG_REMOVED);
568
569 if (!op_inv)
570 {
571 op->inv = tmp;
572 tmp->above = 0;
573 }
574 else
575 {
576 while (op_inv->below)
577 op_inv = op_inv->below;
578
579 op_inv->below = tmp;
580 tmp->above = op_inv;
581 }
582
583 tmp->below = 0;
584 tmp->env = op;
585 op_inv = tmp;
586 }
560 else 587 else
561 { 588 {
562 LOG (llevDebug, "Discarding object without arch: %s\n", 589 LOG (llevDebug, "Discarding object without arch: %s\n",
563 tmp->name ? (const char *) tmp->name : "(null)"); 590 tmp->name ? (const char *) tmp->name : "(null)");
564 free_object (tmp); 591 free_object (tmp);
625 thawer.get (op->move_slow_penalty); 652 thawer.get (op->move_slow_penalty);
626 break; 653 break;
627 654
628 case KW_face: 655 case KW_face:
629 op->face = &new_faces[FindFace (thawer.get_str (), 0)]; 656 op->face = &new_faces[FindFace (thawer.get_str (), 0)];
630 break;
631 657
632 case KW_x: thawer.get (op->x); break; 658 case KW_x: thawer.get (op->x); break;
633 case KW_y: thawer.get (op->y); break; 659 case KW_y: thawer.get (op->y); break;
660 case KW_Str: // uppercase alias
634 case KW_str: thawer.get (op->stats.Str); break; 661 case KW_str: thawer.get (op->stats.Str); break;
662 case KW_Dex: // uppercase alias
635 case KW_dex: thawer.get (op->stats.Dex); break; 663 case KW_dex: thawer.get (op->stats.Dex); break;
664 case KW_Con: // uppercase alias
636 case KW_con: thawer.get (op->stats.Con); break; 665 case KW_con: thawer.get (op->stats.Con); break;
666 case KW_Wis: // uppercase alias
637 case KW_wis: thawer.get (op->stats.Wis); break; 667 case KW_wis: thawer.get (op->stats.Wis); break;
668 case KW_Cha: // uppercase alias
638 case KW_cha: thawer.get (op->stats.Cha); break; 669 case KW_cha: thawer.get (op->stats.Cha); break;
670 case KW_Int: // uppercase alias
639 case KW_int: thawer.get (op->stats.Int); break; 671 case KW_int: thawer.get (op->stats.Int); break;
672 case KW_Pow: // uppercase alias
640 case KW_pow: thawer.get (op->stats.Pow); break; 673 case KW_pow: thawer.get (op->stats.Pow); break;
641 case KW_hp: thawer.get (op->stats.hp); break; 674 case KW_hp: thawer.get (op->stats.hp); break;
642 case KW_maxhp: thawer.get (op->stats.maxhp); break; 675 case KW_maxhp: thawer.get (op->stats.maxhp); break;
643 case KW_sp: thawer.get (op->stats.sp); break; 676 case KW_sp: thawer.get (op->stats.sp); break;
644 case KW_maxsp: thawer.get (op->stats.maxsp); break; 677 case KW_maxsp: thawer.get (op->stats.maxsp); break;
965 998
966 case KW_editable: 999 case KW_editable:
967 case KW_editor_folder: 1000 case KW_editor_folder:
968 break; 1001 break;
969 1002
1003 case KW_More: // uppercase alias
970 case KW_more: 1004 case KW_more:
971 /* We need to record that this is a multipart object, 1005 /* We need to record that this is a multipart object,
972 * so the calling function can glue things back together 1006 * so the calling function can glue things back together
973 */ 1007 */
974 ismore = 1; 1008 ismore = 1;
984 1018
985 case KW_EOF: 1019 case KW_EOF:
986 return LL_EOF; 1020 return LL_EOF;
987 1021
988 case KW_ERROR: 1022 case KW_ERROR:
989 set_ob_key_value(op, thawer.line, thawer.last_value, true); 1023 set_ob_key_value (op, thawer.line, thawer.last_value, true);
990 //printf ("addkv(%s,%s)\n", thawer.line, thawer.get_str());//D 1024 //printf ("addkv(%s,%s)\n", thawer.line, thawer.get_str());//D
991 1025
992 // skip line, ugly 1026 //TODO: skip line, ugly, factor parsing better
1027 if (thawer.last_value)
1028 thawer.line = thawer.last_value;
1029
993 thawer.line = thawer.last_value + strlen (thawer.last_value) + 1; 1030 thawer.line += strlen (thawer.line) + 1;
1031
994 break; 1032 break;
995 1033
996 default: 1034 default:
997 printf ("kw abort %d\n", kw);//D 1035 LOG (llevError, "UNSUPPORTED KEYWORD IN MAP: \"%s\", bug in normaliser. skipping.\n", keyword_str [kw]);
998 abort (); 1036 break;
999 } 1037 }
1000 } 1038 }
1001} 1039}
1002 1040
1003/* 1041/*
1024 * as appropriate in op. 1062 * as appropriate in op.
1025 * 1063 *
1026 * This function appears to be used in only 2 places - in crossedit to 1064 * This function appears to be used in only 2 places - in crossedit to
1027 * override values and in c_wiz to mutate values. 1065 * override values and in c_wiz to mutate values.
1028 */ 1066 */
1067int
1029int set_variable(object *op,char *buf) { 1068set_variable(object *op, char *buf)
1069{
1070 return 0;
1030#if 0 1071#if 0
1031 int retval; 1072 int retval;
1032 object_thawer thawer (0); 1073 object_thawer thawer (0);
1033 1074
1034 strcpy(msgbuf, ""); 1075 strcpy(msgbuf, "");
1091 1132
1092void init_vars() { 1133void init_vars() {
1093} 1134}
1094 1135
1095/* This returns a string of the integer movement type */ 1136/* This returns a string of the integer movement type */
1137#if 0
1138// unused function
1096static char* get_string_move_type(MoveType mt) 1139static char* get_string_move_type(MoveType mt)
1097{ 1140{
1098 static char retbuf[MAX_BUF], retbuf_all[MAX_BUF]; 1141 static char retbuf[MAX_BUF], retbuf_all[MAX_BUF];
1099 int i, all_count=0, count; 1142 int i, all_count=0, count;
1100 1143
1128 * 'all -walk -fly_low' - it is shorter to return 'fly_high swim' 1171 * 'all -walk -fly_low' - it is shorter to return 'fly_high swim'
1129 */ 1172 */
1130 if (all_count <=1) return retbuf_all+1; 1173 if (all_count <=1) return retbuf_all+1;
1131 else return retbuf+1; 1174 else return retbuf+1;
1132} 1175}
1133 1176#endif
1134 1177
1135// compare *op against *tmp and output differences 1178// compare *op against *tmp and output differences
1136void 1179void
1137put (object_freezer &f, object *op, object *tmp) 1180put (object_freezer &f, object *op, object *tmp)
1138{ 1181{
1169 if (op->lore != tmp->lore) f.put (KW_lore, KW_endlore, op->lore); 1212 if (op->lore != tmp->lore) f.put (KW_lore, KW_endlore, op->lore);
1170 1213
1171 CMP_OUT (other_arch); 1214 CMP_OUT (other_arch);
1172 CMP_OUT (face); 1215 CMP_OUT (face);
1173 1216
1217 if (!op->face || !op->face->name)
1218 printf ("ERRFACE<%s,%s, face %p,%p, fname%s>\n", &tmp->name, &op->name, tmp->face, op->face, op->face ? &op->face->name : "<noface>");//D
1219
1174 if (op->animation_id != tmp->animation_id) 1220 if (op->animation_id != tmp->animation_id)
1175 if (op->animation_id) 1221 if (op->animation_id)
1176 { 1222 {
1177 f.put (KW_animation, animations[GET_ANIM_ID (op)].name); 1223 f.put (KW_animation, animations[GET_ANIM_ID (op)].name);
1178 1224
1179 if (!QUERY_FLAG (op, FLAG_ANIMATE)) 1225 if (!QUERY_FLAG (op, FLAG_ANIMATE))
1180 f.put (KW_is_animated, 0); 1226 f.put (KW_is_animated, (sint32)0);
1181 } 1227 }
1182 else 1228 else
1183 f.put (KW_animation, "NONE"); 1229 f.put (KW_animation, (const char *)0);
1184 1230
1185 CMP_OUT2 (str , stats.Str); 1231 CMP_OUT2 (str , stats.Str);
1186 CMP_OUT2 (dex , stats.Dex); 1232 CMP_OUT2 (dex , stats.Dex);
1187 CMP_OUT2 (con , stats.Con); 1233 CMP_OUT2 (con , stats.Con);
1188 CMP_OUT2 (wis , stats.Wis); 1234 CMP_OUT2 (wis , stats.Wis);
1272 1318
1273 if (!COMPARE_FLAGS (op, tmp)) 1319 if (!COMPARE_FLAGS (op, tmp))
1274 for (i = 0; i <= NUM_FLAGS; i++) 1320 for (i = 0; i <= NUM_FLAGS; i++)
1275 if (flag_names [i] 1321 if (flag_names [i]
1276 && (QUERY_FLAG (op, i) != QUERY_FLAG (tmp, i))) 1322 && (QUERY_FLAG (op, i) != QUERY_FLAG (tmp, i)))
1277 f.put (flag_names [i], QUERY_FLAG (op, i) ? "1" : 0); 1323 f.put (flag_names [i], QUERY_FLAG (op, i) ? "1" : "0");
1278 1324
1279 /* Save body locations */ 1325 /* Save body locations */
1280 for (i = 0; i < NUM_BODY_LOCATIONS; i++) 1326 for (i = 0; i < NUM_BODY_LOCATIONS; i++)
1281 if (op->body_info[i] != tmp->body_info[i]) 1327 if (op->body_info[i] != tmp->body_info[i])
1282 f.put (body_locations[i].save_name, op->body_info[i]); 1328 f.put (body_locations[i].save_name, op->body_info[i]);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines