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

Comparing deliantra/server/common/loader.l (file contents):
Revision 1.11 by root, Sun Aug 27 17:59:25 2006 UTC vs.
Revision 1.13 by root, Mon Aug 28 14:05:23 2006 UTC

1%{ 1%{
2/* 2/*
3 * static char *rcsid_object_c = 3 * static char *rcsid_object_c =
4 * "$Id: loader.l,v 1.11 2006/08/27 17:59:25 root Exp $"; 4 * "$Id: loader.l,v 1.13 2006/08/28 14:05:23 root Exp $";
5 */ 5 */
6 6
7/* 7/*
8 CrossFire, A Multiplayer game for X-windows 8 CrossFire, A Multiplayer game for X-windows
9 9
767^more{WS}$ { /* We need to record that this is a multipart object, 767^more{WS}$ { /* We need to record that this is a multipart object,
768 * so the calling function can glue things back together 768 * so the calling function can glue things back together
769 */ 769 */
770 ismore=1; 770 ismore=1;
771 } 771 }
772
773^end{WS}$ { check_loaded_object(op); 772^end{WS}$ { check_loaded_object(op);
774 773
775 if (!arch_init) 774 if (!arch_init)
776 {
777 thawer.get (op);
778 op->instantiate (); 775 op->instantiate ();
779 }
780 776
781 if (ismore) return LL_MORE; 777 if (ismore) return LL_MORE;
782 else return LL_NORMAL; 778 else return LL_NORMAL;
783 } 779 }
780^oid{S} {
781 thawer.get (op, IVAL);
782 }
784^last_heal{S} op->last_heal = IVAL; 783^last_heal{S} op->last_heal = IVAL;
785^last_sp{S} op->last_sp = IVAL; 784^last_sp{S} op->last_sp = IVAL;
786^last_grace{S} op->last_grace = IVAL; 785^last_grace{S} op->last_grace = IVAL;
787^last_eat{S} op->last_eat = IVAL; 786^last_eat{S} op->last_eat = IVAL;
788^speed{S} { op->speed = FVAL; 787^speed{S} { op->speed = FVAL;
1410 * be reset. 1409 * be reset.
1411 * LO_NOREAD (3): Reset the buffers, but don't read from it. (op can be null) 1410 * LO_NOREAD (3): Reset the buffers, but don't read from it. (op can be null)
1412 * 1411 *
1413 */ 1412 */
1414 1413
1415int load_object(FILE *fp, object_thawer &thawer, object *op, int bufstate, int map_flags) { 1414int load_object(object_thawer &fp, object *op, int bufstate, int map_flags) {
1416 int retval; 1415 int retval;
1417 char inbuf[MAX_BUF]; 1416 char inbuf[MAX_BUF];
1418 1417
1419 strcpy(msgbuf, ""); 1418 strcpy(msgbuf, "");
1420 strcpy(lorebuf, ""); 1419 strcpy(lorebuf, "");
1426 } 1425 }
1427 if (bufstate==LO_LINEMODE) { 1426 if (bufstate==LO_LINEMODE) {
1428 YY_BUFFER_STATE yybufstate; 1427 YY_BUFFER_STATE yybufstate;
1429 while (fgets(inbuf, MAX_BUF-3, fp)) { 1428 while (fgets(inbuf, MAX_BUF-3, fp)) {
1430 yybufstate=yy_scan_string(inbuf); 1429 yybufstate=yy_scan_string(inbuf);
1431 retval=lex_load(op, thawer, map_flags); 1430 retval=lex_load(op, fp, map_flags);
1432 yy_delete_buffer(yybufstate); 1431 yy_delete_buffer(yybufstate);
1433 if (retval==LL_NORMAL) return retval; 1432 if (retval==LL_NORMAL) return retval;
1434 } 1433 }
1435 LOG(llevDebug,"Got eof while scanning strings\n"); 1434 LOG(llevDebug,"Got eof while scanning strings\n");
1436 return LL_EOF; 1435 return LL_EOF;
1437 } 1436 }
1438 1437
1439 retval=lex_load(op, thawer, map_flags); 1438 retval=lex_load(op, fp, map_flags);
1440 if (op->current_weapon_script != NULL) 1439 if (op->current_weapon_script != NULL)
1441 { 1440 {
1442 op->current_weapon = find_best_weapon_used_match(op, op->current_weapon_script); 1441 op->current_weapon = find_best_weapon_used_match(op, op->current_weapon_script);
1443 LOG(llevDebug, "CurrentWeapon Loaded !\n"); 1442 LOG(llevDebug, "CurrentWeapon Loaded !\n");
1444 }; 1443 };
1455 * override values and in c_wiz to mutate values. 1454 * override values and in c_wiz to mutate values.
1456 */ 1455 */
1457int set_variable(object *op,char *buf) { 1456int set_variable(object *op,char *buf) {
1458 YY_BUFFER_STATE yybufstate,yycurbuf=YY_CURRENT_BUFFER; 1457 YY_BUFFER_STATE yybufstate,yycurbuf=YY_CURRENT_BUFFER;
1459 int retval; 1458 int retval;
1460 object_thawer thawer; 1459 object_thawer thawer (0);
1461 1460
1462 strcpy(msgbuf, ""); 1461 strcpy(msgbuf, "");
1463 strcpy(lorebuf, ""); 1462 strcpy(lorebuf, "");
1464 yy_push_state(INITIAL); 1463 yy_push_state(INITIAL);
1465 yybufstate=yy_scan_string(buf); 1464 yybufstate=yy_scan_string(buf);
2038 * the only place this is not set is when saving the player. 2037 * the only place this is not set is when saving the player.
2039 * If bit 1 of flag is set, don't remove the object after save. As of now, 2038 * If bit 1 of flag is set, don't remove the object after save. As of now,
2040 * all of the callers are setting this. 2039 * all of the callers are setting this.
2041 */ 2040 */
2042 2041
2043void save_object(FILE *fp,object_freezer &freezer,object *op, int flag) { 2042void save_object(object_freezer &fp,object *op, int flag) {
2044 archetype *at; 2043 archetype *at;
2045 char *cp; 2044 char *cp;
2046 object *tmp,*old; 2045 object *tmp,*old;
2047 2046
2048 /* Even if the object does have an owner, it would seem that we should 2047 /* Even if the object does have an owner, it would seem that we should
2066 2065
2067 old=NULL; 2066 old=NULL;
2068 2067
2069 if (flag & 2 ) 2068 if (flag & 2 )
2070 for(tmp=op->inv;tmp!=NULL;tmp=tmp->below) 2069 for(tmp=op->inv;tmp!=NULL;tmp=tmp->below)
2071 save_object(fp,freezer,tmp,flag); 2070 save_object(fp,tmp,flag);
2072 2071
2073 /* Slightly different logic because tmp/op will be removed by 2072 /* Slightly different logic because tmp/op will be removed by
2074 * the save_object we call. So we just keep looking at op->inv 2073 * the save_object we call. So we just keep looking at op->inv
2075 * until there is nothing left. In theory, the variable old 2074 * until there is nothing left. In theory, the variable old
2076 * should not be needed, as recursive loops shouldn't happen. 2075 * should not be needed, as recursive loops shouldn't happen.
2078 else while ((tmp=op->inv)!=NULL) { 2077 else while ((tmp=op->inv)!=NULL) {
2079 if(old==tmp) { 2078 if(old==tmp) {
2080 LOG(llevError," Recursive loop in inventory\n"); 2079 LOG(llevError," Recursive loop in inventory\n");
2081 break; 2080 break;
2082 } 2081 }
2083 save_object(fp,freezer,tmp,flag); 2082 save_object(fp,tmp,flag);
2084 old=tmp; 2083 old=tmp;
2085 } 2084 }
2086 2085
2087 if (!(flag&2)) { 2086 if (!(flag&2)) {
2088 remove_ob(op); 2087 remove_ob(op);
2089 free_object (op); 2088 free_object (op);
2090 } 2089 }
2091 2090
2091 fp.put (op);
2092 fprintf(fp,"end\n"); 2092 fprintf(fp,"end\n");
2093 freezer.put (op);
2094} 2093}
2095 2094
2096void insert_event(object* op, int etype, char *ehook, char *eplug, char *eoptions) 2095void insert_event(object* op, int etype, char *ehook, char *eplug, char *eoptions)
2097{ 2096{
2098 event *evt; 2097 event *evt;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines