It is currently Mon Dec 01, 2008 11:24 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: SetAttributeBaseValue()
PostPosted: Mon Aug 21, 2006 3:19 am 
Offline

Joined: Sat Jul 22, 2006 8:25 am
Posts: 29
Location: Italy
In attributes.inc when the function SetAttributeBaseValue() is used the code check before value:

Code:
  if(intelligence < 10)
    intelligence := 10;
  elseif(intelligence > CORE_SETTINGS_MAX_ATTRIBUTE)
    intelligence := CORE_SETTINGS_MAX_ATTRIBUTE;
  endif
  var ret := SetAttributeBaseValue(who, ATTRIBUTEID_INTELLIGENCE, intelligence);


What can happen if I use directly SetAttributeBaseValue() and I do not check CORE_SETTINGS_MAX_ATTRIBUTE?

Core crashes or only fails the command?

_________________
--------------------------
ZuluHotelItalia Admin


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 21, 2006 9:13 pm 
Offline
Certified POL Expert
User avatar

Joined: Thu Feb 02, 2006 1:41 pm
Posts: 1219
Location: Southern Central USA
CORE_SETTINGS_MAX_ATTRIBUTE is a constant used as a reference for the maximum value any attribute can attain. To my knowledge the POL server will suffer no adverse effects if you go above this value. However depending on what format attributes are stored at there may be a maximum hard coded value. For example if attributes are a double-integer the max value will be 65535.

_________________
Sincerely,
Yukiko

I know you think you understand what you thought I said but what you heard is not exactly what I meant.

Titus 2:13


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 22, 2006 1:26 am 
Offline

Joined: Sat Jul 22, 2006 8:25 am
Posts: 29
Location: Italy
I am rewriting all my scripts not using functions in attributes.inc like
GetStamina() or GetHp()

I don't know if it is the case also to substituite also SetBaseIntelligence() for exampe.
The code is:
Code:
function SetBaseIntelligence(who, intelligence)
  intelligence := Cint(intelligence * 10);
  if(intelligence < 10)
    intelligence := 10;
  elseif(intelligence > CORE_SETTINGS_MAX_ATTRIBUTE)
    intelligence := CORE_SETTINGS_MAX_ATTRIBUTE;
  endif
  var ret := SetAttributeBaseValue(who, ATTRIBUTEID_INTELLIGENCE, intelligence);
  if(ret)
    DoRecalcVitals(who);
  endif
  return ret;
endfunction


If I don't' check
if(intelligence < 10)
for exampe
SetAttributeBaseValue(who, ATTRIBUTEID_INTELLIGENCE, intelligence)
do not report error to script if intelligence < 0 ?

_________________
--------------------------
ZuluHotelItalia Admin


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 22, 2006 9:13 am 
Offline
Certified POL Expert
User avatar

Joined: Sat Feb 04, 2006 5:49 pm
Posts: 796
Location: Chicago, IL USA
The core shouldnt suffer at all from your changes. Its not the core that checks the max values, its the scripts. Its up to you where you want this all checked if you want it checked at all but also it comes as a warning that if you dont have something checking that somewhere in your scripts, your players can just keep gaining until the core's hardcoded max is reached which I'm sure is far above any cap you want.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl