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.12 by root, Mon Aug 28 07:07:41 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.12 2006/08/28 07:07:41 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
1409 * be reset. 1409 * be reset.
1410 * 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)
1411 * 1411 *
1412 */ 1412 */
1413 1413
1414int 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) {
1415 int retval; 1415 int retval;
1416 char inbuf[MAX_BUF]; 1416 char inbuf[MAX_BUF];
1417 1417
1418 strcpy(msgbuf, ""); 1418 strcpy(msgbuf, "");
1419 strcpy(lorebuf, ""); 1419 strcpy(lorebuf, "");
1425 } 1425 }
1426 if (bufstate==LO_LINEMODE) { 1426 if (bufstate==LO_LINEMODE) {
1427 YY_BUFFER_STATE yybufstate; 1427 YY_BUFFER_STATE yybufstate;
1428 while (fgets(inbuf, MAX_BUF-3, fp)) { 1428 while (fgets(inbuf, MAX_BUF-3, fp)) {
1429 yybufstate=yy_scan_string(inbuf); 1429 yybufstate=yy_scan_string(inbuf);
1430 retval=lex_load(op, thawer, map_flags); 1430 retval=lex_load(op, fp, map_flags);
1431 yy_delete_buffer(yybufstate); 1431 yy_delete_buffer(yybufstate);
1432 if (retval==LL_NORMAL) return retval; 1432 if (retval==LL_NORMAL) return retval;
1433 } 1433 }
1434 LOG(llevDebug,"Got eof while scanning strings\n"); 1434 LOG(llevDebug,"Got eof while scanning strings\n");
1435 return LL_EOF; 1435 return LL_EOF;
1436 } 1436 }
1437 1437
1438 retval=lex_load(op, thawer, map_flags); 1438 retval=lex_load(op, fp, map_flags);
1439 if (op->current_weapon_script != NULL) 1439 if (op->current_weapon_script != NULL)
1440 { 1440 {
1441 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);
1442 LOG(llevDebug, "CurrentWeapon Loaded !\n"); 1442 LOG(llevDebug, "CurrentWeapon Loaded !\n");
1443 }; 1443 };
1454 * override values and in c_wiz to mutate values. 1454 * override values and in c_wiz to mutate values.
1455 */ 1455 */
1456int set_variable(object *op,char *buf) { 1456int set_variable(object *op,char *buf) {
1457 YY_BUFFER_STATE yybufstate,yycurbuf=YY_CURRENT_BUFFER; 1457 YY_BUFFER_STATE yybufstate,yycurbuf=YY_CURRENT_BUFFER;
1458 int retval; 1458 int retval;
1459 object_thawer thawer; 1459 object_thawer thawer (0);
1460 1460
1461 strcpy(msgbuf, ""); 1461 strcpy(msgbuf, "");
1462 strcpy(lorebuf, ""); 1462 strcpy(lorebuf, "");
1463 yy_push_state(INITIAL); 1463 yy_push_state(INITIAL);
1464 yybufstate=yy_scan_string(buf); 1464 yybufstate=yy_scan_string(buf);
2037 * 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.
2038 * 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,
2039 * all of the callers are setting this. 2039 * all of the callers are setting this.
2040 */ 2040 */
2041 2041
2042void save_object(FILE *fp,object_freezer &freezer,object *op, int flag) { 2042void save_object(object_freezer &fp,object *op, int flag) {
2043 archetype *at; 2043 archetype *at;
2044 char *cp; 2044 char *cp;
2045 object *tmp,*old; 2045 object *tmp,*old;
2046 2046
2047 /* 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
2065 2065
2066 old=NULL; 2066 old=NULL;
2067 2067
2068 if (flag & 2 ) 2068 if (flag & 2 )
2069 for(tmp=op->inv;tmp!=NULL;tmp=tmp->below) 2069 for(tmp=op->inv;tmp!=NULL;tmp=tmp->below)
2070 save_object(fp,freezer,tmp,flag); 2070 save_object(fp,tmp,flag);
2071 2071
2072 /* Slightly different logic because tmp/op will be removed by 2072 /* Slightly different logic because tmp/op will be removed by
2073 * 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
2074 * until there is nothing left. In theory, the variable old 2074 * until there is nothing left. In theory, the variable old
2075 * should not be needed, as recursive loops shouldn't happen. 2075 * should not be needed, as recursive loops shouldn't happen.
2077 else while ((tmp=op->inv)!=NULL) { 2077 else while ((tmp=op->inv)!=NULL) {
2078 if(old==tmp) { 2078 if(old==tmp) {
2079 LOG(llevError," Recursive loop in inventory\n"); 2079 LOG(llevError," Recursive loop in inventory\n");
2080 break; 2080 break;
2081 } 2081 }
2082 save_object(fp,freezer,tmp,flag); 2082 save_object(fp,tmp,flag);
2083 old=tmp; 2083 old=tmp;
2084 } 2084 }
2085 2085
2086 if (!(flag&2)) { 2086 if (!(flag&2)) {
2087 remove_ob(op); 2087 remove_ob(op);
2088 free_object (op); 2088 free_object (op);
2089 } 2089 }
2090 2090
2091 freezer.put (fp, op); 2091 fp.put (op);
2092 fprintf(fp,"end\n"); 2092 fprintf(fp,"end\n");
2093} 2093}
2094 2094
2095void 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)
2096{ 2096{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines