Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
tintin++ ogg sound player script for linux
Author: Robert Smith
Submitted by: Vladaar
6Dragons ogg Soundpack
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.4
Author: Vladaar
Submitted by: Vladaar
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
Users Online
CommonCrawl, Yandex

Members: 0
Guests: 10
Stats
Files
Topics
Posts
Members
Newest Member
481
3,735
19,370
618
Micheal64X
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Bugfix Lists » AFKMud Bugfix List » AFKMud Bug Archive » [Bug] Value settings on some ...
Forum Rules | Mark all | Recent Posts

[Bug] Value settings on some items causes a crash when the item is stat'd
< Newer Topic :: Older Topic > AFKMud 1.64

Pages:<< prev 1 next >>
Post is unread #1 Feb 27, 2005, 11:57 am   Last edited Nov 13, 2005, 11:55 am by Samson
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,643
JoinedJan 1, 2002

Bug: Value settings on some items causes a crash when the item is stat'd
Discovered in: AFKMud 1.64
Danger: High - Crash bug
Found by: Celestria
Fixed by: Celestria and Samson

---

build.c

In the includes list, add: #include "treasure.h"

Function do_oset,

Find:

   if( !str_cmp( arg2, "value3" ) || !str_cmp( arg2, "v3" ) )
    {
	obj->value[3] = value;

	if( IS_OBJ_FLAG( obj, ITEM_PROTOTYPE ) )
	  obj->pIndexData->value[3] = value;


Replace with:

   if( !str_cmp( arg2, "value3" ) || !str_cmp( arg2, "v3" ) )
   {
      if( obj->item_type == ITEM_ARMOR && ( value = TATP_MAX ) )
      {
         ch_printf( ch, "Value is out of range for armor type. Range is 0 to %d\n\r", TATP_MAX );
         return;
      }

      obj->value[3] = value;

      if( IS_OBJ_FLAG( obj, ITEM_PROTOTYPE ) )
         obj->pIndexData->value[3] = value;


Find:

   if( !str_cmp( arg2, "value4" ) || !str_cmp( arg2, "v4" ) )
    {
	obj->value[4] = value;

	if( IS_OBJ_FLAG( obj, ITEM_PROTOTYPE ) )
	  obj->pIndexData->value[4] = value;


Replace with:

   if( !str_cmp( arg2, "value4" ) || !str_cmp( arg2, "v4" ) )
   {
      if( obj->item_type == ITEM_ARMOR && ( value = TMAT_MAX ) )
      {
         ch_printf( ch, "Value is out of range for material type. Range is 0 to %d\n\r", TMAT_MAX );
         return;
      }

      obj->value[4] = value;

      if( IS_OBJ_FLAG( obj, ITEM_PROTOTYPE ) )
         obj->pIndexData->value[4] = value;


Find:

   if( !str_cmp( arg2, "value8" ) || !str_cmp( arg2, "v8" ) )
    {
	obj->value[8] = value;
	if( IS_OBJ_FLAG( obj, ITEM_PROTOTYPE ) )
	  obj->pIndexData->value[8] = value;


Replace with:

   if( !str_cmp( arg2, "value8" ) || !str_cmp( arg2, "v8" ) )
   {
      if( obj->item_type == ITEM_WEAPON && ( value = TWTP_MAX ) )
      {
         ch_printf( ch, "Value is out of range for weapon type. Range is 0 to %d\n\r", TWTP_MAX );
         return;
      }

      obj->value[8] = value;
      if( IS_OBJ_FLAG( obj, ITEM_PROTOTYPE ) )
         obj->pIndexData->value[8] = value;


Find:

   if( !str_cmp( arg2, "value9" ) || !str_cmp( arg2, "v9" ) )
    {
	obj->value[9] = value;
	if( IS_OBJ_FLAG( obj, ITEM_PROTOTYPE ) )
	  obj->pIndexData->value[9] = value;


Replace with:

   if( !str_cmp( arg2, "value9" ) || !str_cmp( arg2, "v9" ) )
   {
      if( obj->item_type == ITEM_WEAPON && ( value = TMAT_MAX ) )
      {
         ch_printf( ch, "Value is out of range for material type. Range is 0 to %d\n\r", TMAT_MAX );
         return;
      }

      obj->value[9] = value;
      if( IS_OBJ_FLAG( obj, ITEM_PROTOTYPE ) )
         obj->pIndexData->value[9] = value;


Find:

   if( !str_cmp( arg2, "value10" ) || !str_cmp( arg2, "v10" ) )
    {
	obj->value[10] = value;
	if( IS_OBJ_FLAG( obj, ITEM_PROTOTYPE ) )
	  obj->pIndexData->value[10] = value;


Replace with:

   if( !str_cmp( arg2, "value10" ) || !str_cmp( arg2, "v10" ) )
   {
      if( obj->item_type == ITEM_WEAPON && ( value = TQUAL_MAX ) )
      {
         ch_printf( ch, "Value is out of range for quality type. Range is 0 to %d\n\r", TQUAL_MAX );
         return;
      }

      obj->value[10] = value;
      if( IS_OBJ_FLAG( obj, ITEM_PROTOTYPE ) )
         obj->pIndexData->value[10] = value;


treasure.c: function armorgen,

Find:

   if( obj->value[3] > 16 )
   {
	bug( "Improper armor type passed to armorgen for %s", obj->name );
	obj->value[3] = 0;
	return;
   }

   if( obj->value[4] > 13 )
   {
	bug( "Improper material passed to armorgen for %s", obj->name );
	obj->value[4] = 0;
	return;
   }


Replace with:

   if( obj->value[3] >= TATP_MAX )
   {
      bug( "Improper armor type passed to armorgen for %s", obj->name );
      obj->value[3] = 0;
      return;
   }

   if( obj->value[4] >= TMAT_MAX )
   {
      bug( "Improper material passed to armorgen for %s", obj->name );
      obj->value[4] = 0;
      return;
   }


Function weapongen,

Find:

   if( obj->value[8] > 12 )
   {
	bug( "Improper weapon type passed to weapongen for %s", obj->name );
	obj->value[8] = 0;
	return;
   }

   if( obj->value[9] > 13 )
   {
	bug( "Improper material passed to weapongen for %s", obj->name );
	obj->value[9] = 0;
	return;
   }

   if( obj->value[10] > 4 )
   {
	bug( "Improper quality passed to weapongen for %s", obj->name );
	obj->value[10] = 0;
	return;
   }


Replace with:

   if( obj->value[8] >= TWTP_MAX )
   {
	bug( "Improper weapon type passed to weapongen for %s", obj->name );
	obj->value[8] = 0;
	return;
   }

   if( obj->value[9] >= TMAT_MAX )
   {
	bug( "Improper material passed to weapongen for %s", obj->name );
	obj->value[9] = 0;
	return;
   }

   if( obj->value[10] >= TQUAL_MAX )
   {
	bug( "Improper quality passed to weapongen for %s", obj->name );
	obj->value[10] = 0;
	return;
   }


The problem here stemmed from how the treasure tables are stored in the structs. Exceeding the bounds of the struct would cause any reads of that memory to be unpredicatble, usually resulting in a crash. Also, while implementing this fix it was noticed that the code was not using the assigned definition values to check against in treasure.c and was simply using hardcoded values. Obviously if the table is adjusted and the values were corrected, hardcoded values have no way to know this.

This fix cannot protect you against changing an item from another type into a weapon or armor and having leftover values cause you grief - so you'll need to be careful about that.
       
Pages:<< prev 1 next >>