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.167 by elmex, Thu Apr 28 12:11:03 2011 UTC vs.
Revision 1.168 by root, Sun May 1 13:18:23 2011 UTC

550 550
551bool 551bool
552object::parse_kv (object_thawer &f) 552object::parse_kv (object_thawer &f)
553{ 553{
554 object *op_inv = inv; 554 object *op_inv = inv;
555 key_value *last_kv = key_values; 555 key_value *last_kv = kv.first;
556 556
557 for (;;) 557 for (;;)
558 { 558 {
559 switch (f.kw) 559 switch (f.kw)
560 { 560 {
1040 1040
1041 f.next (); 1041 f.next ();
1042 return true; 1042 return true;
1043 1043
1044 case KW_ERROR: 1044 case KW_ERROR:
1045 // append as key value pair (do not use kv_set as it prepends)
1046 // we also do not even try to find old values, duplicate keys stay duplicate 1045 // we do not even try to find old values, duplicate keys stay duplicate
1047 { 1046 // the list gets reversed after loading
1048 key_value *kv = new key_value; 1047 kv.add (shstr (f.kw_str), shstr (f.value));
1049
1050 kv->next = 0;
1051 kv->key = shstr (f.kw_str);
1052 kv->value = shstr (f.value);
1053
1054 if (!last_kv)
1055 key_values = last_kv = kv;
1056 else
1057 {
1058 while (last_kv->next)
1059 last_kv = last_kv->next;
1060
1061 last_kv->next = kv;
1062 last_kv = kv;
1063 }
1064 }
1065 //fprintf (stderr, "addkv(%s,%s)\n", f.kw_str, f.value);//D
1066 break; 1048 break;
1067 1049
1068 default: 1050 default:
1069 if (!f.parse_error ("object", name)) 1051 if (!f.parse_error ("object", name))
1070 return false; 1052 return false;
1100 if (!op->parse_kv (f)) 1082 if (!op->parse_kv (f))
1101 { 1083 {
1102 op->destroy (); 1084 op->destroy ();
1103 return 0; 1085 return 0;
1104 } 1086 }
1087
1088 // the loader reverses the ordering of kv-pairs, so we reverse it again after loading
1089 // that greatly simplifies the loading code.
1090 op->kv.reverse ();
1105 1091
1106 op->post_load_check (); 1092 op->post_load_check ();
1107 return op; 1093 return op;
1108} 1094}
1109 1095
1276 } flagmask; 1262 } flagmask;
1277 1263
1278 /* This saves the key/value lists. We do it first so that any 1264 /* This saves the key/value lists. We do it first so that any
1279 * keys that match field names will be overwritten by the loader. 1265 * keys that match field names will be overwritten by the loader.
1280 */ 1266 */
1281 for (key_value *kv = op->key_values; kv; kv = kv->next) 1267 for (key_value *kv = op->kv.first; kv; kv = kv->next)
1282 if (!arch->key_values || arch->kv (kv->key) != kv->value) 1268 if (arch->kv.empty () || arch->kv [kv->key] != kv->value)
1283 f.put (kv->key, kv->value); 1269 f.put (kv->key, kv->value);
1284 1270
1285 if (op->uuid) 1271 if (op->uuid)
1286 { 1272 {
1287 // highly optimised - this is often 25% of all data written 1273 // highly optimised - this is often 25% of all data written

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines