Help with object saving problem.

Posted by Gtr on Thu 17 Jun 2004 08:00 AM — 21 posts, 63,288 views.

#0
Hey guys, heres my problem, I have everything set up for some new object varibles. I added acc, ra, di, fi, they work fine, but they just dont save, oset it and it shows on the ostat, I foldarea, reboot and it sets back to 0. I have the folda code dealing with objects below. I have such a headache over this..well thanks for helping if you can.

    

               /* save objects */
    fprintf( fpout, "#OBJECTS\n" );
    for ( vnum = tarea->low_o_vnum; vnum <= tarea->hi_o_vnum; vnum++ )
    {
	if ( (pObjIndex = get_obj_index( vnum )) == NULL )
	  continue;
	if ( install )
	  xREMOVE_BIT( pObjIndex->extra_flags, ITEM_PROTOTYPE );
	fprintf( fpout, "#%d\n",	vnum				);
	fprintf( fpout, "%s~\n",	pObjIndex->name			);
	fprintf( fpout, "%s~\n",	pObjIndex->short_descr		);
	fprintf( fpout, "%s~\n",	pObjIndex->description		);
	fprintf( fpout, "%s~\n",	pObjIndex->action_desc		);
	if ( pObjIndex->layers )
	  fprintf( fpout, "%d %s %d %d\n",	pObjIndex->item_type,
				print_bitvector(&pObjIndex->extra_flags),
						pObjIndex->wear_flags,
						pObjIndex->layers	);
	else
	  fprintf( fpout, "%d %s %d\n",	pObjIndex->item_type,
			print_bitvector(&pObjIndex->extra_flags),
					pObjIndex->wear_flags		);

	val0 = pObjIndex->value[0];
	val1 = pObjIndex->value[1];
	val2 = pObjIndex->value[2];
	val3 = pObjIndex->value[3];
	val4 = pObjIndex->value[4];
	val5 = pObjIndex->value[5];
	switch ( pObjIndex->item_type )
	{
	case ITEM_PILL:
	case ITEM_POTION:
	case ITEM_SCROLL:
	    if ( IS_VALID_SN(val1) ) 
          {
		if ( AREA_VERSION_WRITE == 0 ) val1 = skill_table[val1]->slot;
		else	val1 = HAS_SPELL_INDEX;
          }
	    if ( IS_VALID_SN(val2) ) 
          {
		if ( AREA_VERSION_WRITE == 0 ) val2 = skill_table[val2]->slot;
		else	val2 = HAS_SPELL_INDEX;
          }
	    if ( IS_VALID_SN(val3) ) 
          {
		if ( AREA_VERSION_WRITE == 0 ) val3 = skill_table[val3]->slot;
		else	val3 = HAS_SPELL_INDEX;
          }
	    break;
	case ITEM_STAFF:
	case ITEM_WAND:
	    if ( IS_VALID_SN(val3) ) 
          {
		if ( AREA_VERSION_WRITE == 0 ) val3 = skill_table[val3]->slot;
		else  val3 = HAS_SPELL_INDEX;
          }
	    break;
	case ITEM_SALVE:
	    if ( IS_VALID_SN(val4) ) 
          {
		if ( AREA_VERSION_WRITE == 0 ) val4 = skill_table[val4]->slot;
		else  val4 = HAS_SPELL_INDEX;
          }
	    if ( IS_VALID_SN(val5) ) 
          {
		if ( AREA_VERSION_WRITE == 0 ) val5 = skill_table[val5]->slot;
		else  val5 = HAS_SPELL_INDEX;
          }
	    break;
	}
	if ( val4 || val5 )
	  fprintf( fpout, "%d %d %d %d %d %d\n",val0, 
						val1,
						val2,
						val3,
						val4,
						val5 );
	else
	fprintf( fpout, "%d %d %d %d\n",	val0,
						val1,
						val2,
						val3 );

  fprintf( fpout, "%d %d %d %d\n",  pObjIndex->acc,
           pObjIndex->ra,
           pObjIndex->da,
           pObjIndex->fi    );
	fprintf( fpout, "%d %d %d\n",	pObjIndex->weight,
					pObjIndex->cost,
					pObjIndex->rent ? pObjIndex->rent :
				 (int) (pObjIndex->cost / 10)		);

        if ( AREA_VERSION_WRITE > 0 )
    	switch ( pObjIndex->item_type )
    	{
    	case ITEM_PILL: 
    	case ITEM_POTION:
    	case ITEM_SCROLL:
           	fprintf( fpout, "'%s' '%s' '%s'\n",
                	IS_VALID_SN(pObjIndex->value[1])?
			skill_table[pObjIndex->value[1]]->name:"NONE",
			IS_VALID_SN(pObjIndex->value[2])?
			skill_table[pObjIndex->value[2]]->name :"NONE",
			IS_VALID_SN(pObjIndex->value[3])? 
			skill_table[pObjIndex->value[3]]->name:"NONE" );
        	break;
    	case ITEM_STAFF:
    	case ITEM_WAND:
            	fprintf( fpout, "'%s'\n",
                        IS_VALID_SN(pObjIndex->value[3])?  
                	skill_table[pObjIndex->value[3]]->name:"NONE" );
	
        	break;
    	case ITEM_SALVE:
            	fprintf( fpout, "'%s' '%s'\n",
                        IS_VALID_SN(pObjIndex->value[4])?  
                	skill_table[pObjIndex->value[4]]->name:"NONE",
			IS_VALID_SN(pObjIndex->value[5])?
                	skill_table[pObjIndex->value[5]]->name:"NONE" );
        break;
    	}

	for ( ed = pObjIndex->first_extradesc; ed; ed = ed->next )
	   fprintf( fpout, "E\n%s~\n%s~\n",
			ed->keyword, strip_cr( ed->description )	);

	for ( paf = pObjIndex->first_affect; paf; paf = paf->next )
	   fprintf( fpout, "A\n%d %d\n", paf->location,
	     ((paf->location == APPLY_WEAPONSPELL
	    || paf->location == APPLY_WEARSPELL
	    || paf->location == APPLY_REMOVESPELL
	    || paf->location == APPLY_STRIPSN
	    || paf->location == APPLY_RECURRINGSPELL)
	    && IS_VALID_SN(paf->modifier))
	    ? skill_table[paf->modifier]->slot : paf->modifier		);

	if ( pObjIndex->mudprogs )
	{
	  for ( mprog = pObjIndex->mudprogs; mprog; mprog = mprog->next )
		fprintf( fpout, "> %s %s~\n%s~\n",
				mprog_type_to_name( mprog->type ),
				mprog->arglist, strip_cr(mprog->comlist) );
	  fprintf( fpout, "|\n" );	  
	}
    }
    fprintf( fpout, "#0\n\n\n" );
    if ( install && vnum < tarea->hi_o_vnum )
      tarea->hi_o_vnum = vnum - 1; 
Amended on Thu 17 Jun 2004 08:10 AM by Gtr
USA #1
Did you remember to add it to fread_obj? (Or something of that sort of function)
Canada #2
Don't forget to add it to create_object as well. This set the values on the object index onto the specific instances of those objects. This is often forgotten when people add new variables.

You also want to add it to make_object if your copying vnums through "ocreate <name> <vnum> <copyvnum>".
#3
I added it to fread_ob, create_ob, and make_ob, and it still doesnt save when I folda and reboot. Stressing heh.
Canada #4
Ok, well, check this: Is it writing it to the area files or not? If it is, we can rule that part of it out, if not, we know where to look.
#5
It's not writing to the file.
Canada #6
K, well that narrows it down. Are other changes to that same object being saved?
#7
Yes just not the varibles I added.
Amended on Fri 18 Jun 2004 06:07 AM by Gtr
Canada #8
Ummm, did you recompile? Try a "make clean" then "make". Were there any errors or warnings?
#9
I did both a few times since the changes, and I have no errors, or warnings.
Amended on Fri 18 Jun 2004 06:32 AM by Gtr
Canada #10
Can you maybe show a complete sequence of what your doing? Is ther area assigned to you? Is the object set with the prototype flag when your setting it? Is the objects vnum within the boundries that area? do you have a specific instance on your character, or are you targetting it globally? When you foldarea, do you get the log message saying that it was saved? If you modify that specific objects weight with the prototype flag on, then foldarea and reboot, does the change to thte weight stick?
#11
Ok, I loadup the object I created in the area I assign my self, and set it to prototype, I change the new values to 50 50 50 50, and I change a few other things just to see if they save I take the prototype flag off and foldarea then reboot. All the other options on the item that I set are still there except for the new ones. So the weight I changed and some of the v's that I changed all saved..but my new varibles didnt..


So then I tried this, I had the object while not in prototype mode, and changed the indivigual objects weight, and one of my created values. Then I saved my idivigual charecter and rebooted. The weight was still changed when it started up again but the new value didnt save.
Canada #12
Can you paste the object that you saved and are changing from the area file?
#13
#101
&wA Test~
&wA Test~
&wA Test has been left here.~
~
65 0 8192
20 0 20 0 0 1
10 10 10 10
1 0 0
Canada #14
Is this not the appropriate lines?

#101
&wA Test~
&wA Test~
&wA Test has been left here.~
~
65 0 8192
20 0 20 0 0 1
10 10 10 10
1 0 0

Looks like its being written... can you paste your oset code appropriate to these values?
Amended on Fri 18 Jun 2004 07:31 AM by Greven
#15
if ( !str_cmp( arg2, "acc" ) )
{
if ( !can_omodify( ch, obj ) )
return;
obj->acc = value;
if ( IS_OBJ_STAT(obj, ITEM_PROTOTYPE) )
obj->pIndexData->acc = value;
return;
}
if ( !str_cmp( arg2, "ra" ) )
{
if ( !can_omodify( ch, obj ) )
return;
obj->ra = value;
if ( IS_OBJ_STAT(obj, ITEM_PROTOTYPE) )
obj->pIndexData->ra = value;
return;
}
if ( !str_cmp( arg2, "da" ) )
{
if ( !can_omodify( ch, obj ) )
return;
obj->da_level = value;
if ( IS_OBJ_STAT(obj, ITEM_PROTOTYPE) )
obj->pIndexData->da_level = value;
return;
}
if ( !str_cmp( arg2, "fi" ) )
{
if ( !can_omodify( ch, obj ) )
return;
obj->fi_rate = value;
if ( IS_OBJ_STAT(obj, ITEM_PROTOTYPE) )
obj->pIndexData->fi_rate = value;
return;
}
Canada #16
Well... I notice that your writing fi and da, but saving to fi_rate and da_level.

Try putting in ostat something to show you obj->ra and obj->pObjIndex-ra as well, make sure both as changed when setting them, and that both revert 10 afterwards.
#17
Heh I added that to ostat when I first installed the new values, that was how I orignaly noticed they dont save and revert to 0.
#18
Whoa I just noticed.
Statistics:
Acc: 0
Ra: 0
Da: 0 Test Da: 10
Fi: 0

Da is the normal value, and test da is the index. Apprently the index saves..but the other doesnt. I noticed even when I logout, the non-index values resets to 0.

Anyone have any ideas why this might be? I assume I'm missing code somewhere but dont know where to start.

Amended on Sat 19 Jun 2004 05:56 AM by Gtr
#19
Oh god, I shouldnt stay up coding so late...I figured out my problem(s). I guess this thread is pretty useless, wouldnt hurt if it was deleted. Thanks for trying to help grev.
Amended on Sat 19 Jun 2004 08:48 AM by Gtr
USA #20
Nah, always keep topics, just in case someone has the same problem, then they can come back and look it over.