Code path debug: Difference between revisions
Created page with "== call player;query_level() always shows 1 == <pre>/std/user.c :: query_level()</pre> This function simply returns the object variable "level", which is only modified through..." |
No edit summary |
||
| (3 intermediate revisions by 2 users not shown) | |||
| Line 2: | Line 2: | ||
<pre>/std/user.c :: query_level()</pre> | <pre>/std/user.c :: query_level()</pre> | ||
This function simply returns the object variable "level", which is only modified through set_level(). set_level() does a check to see whether the previous_object() is wizardp(), or if the euid of the previous_object() is UID_ADVANCE. If not, it returns. This appears to be the root of the issue, as functions which call set_level() (such as the _improve.c command) defer setting levels by calling set_level(1). set_level(1) then 'returns' with no integer (presumably 0 by default) and I believe the player's level remains what it was, 1. | This function simply returns the object variable "level", which is only modified through set_level(). set_level() does a check to see whether the previous_object() is wizardp(), or if the euid of the previous_object() is UID_ADVANCE. If not, it returns. This appears to be the root of the issue, as functions which call set_level() (such as the _improve.c command) defer setting levels by calling set_level(1). set_level(1) then 'returns' with no integer (presumably 0 by default) and I believe the player's level remains what it was, 1. | ||
<ol> | |||
<li><pre>/cmds/mortal/_improve.c :: cmd_improve() | |||
... | |||
STAT_D->do_improvement(str, this_player()); | |||
...</pre> | |||
<li><pre>/daemon/stat_d.c :: do_improvement() | |||
... | |||
/* set_stats() for me is inherited from living.c */ | |||
me->set_stats(str, current + 1); | |||
...</pre> | |||
<li><pre>/std/living.c :: set_stats() | |||
... | |||
if(!wizardp(this_object()) && this_object()->is_player()){ | |||
seteuid(UID_ADVANCE); // This should be enough to satisfy living.c::set_level() | |||
this_object()->set_level(1); | |||
seteuid(getuid()); | |||
} | |||
...</pre> | |||
</ol> | |||
The current fix (probably will want to fine tune this, if this causes other bugs. | |||
<ol> | |||
<li><strike><pre>/std/living.c :: init_living() | |||
... | |||
{ | |||
// Added the following. However, I am not sure this is actually needed. | |||
seteuid(UID_ADVANCE); | |||
} | |||
...</pre></strike> | |||
<li><pre>/daemon/stat_d.c :: do_improve() | |||
... | |||
{ | |||
// Added the following. This set the correct UID for the previous_object(). Also added UID_ADVANCE to this file in privs.db | |||
seteuid(UID_ADVANCE); | |||
me->set_stats(str, current + 1); | |||
seteuid(getuid()); | |||
} | |||
...</pre> | |||
</ol> | |||
== Training skills does not raise level == | |||
<pre>/std/train_rm.c</pre> | |||
Does not currently contain a set_level(1) like /adm/daemon/skills_d.c which will trigger setting appropriate level. Fix is to figure out where to plug a set_level(1) for a successful change in ability. | |||
<pre>/std/living/skills.c</pre> | |||
<ol> | |||
<li>Added at line 44: void init() { set_euid("Advance"); } | |||
</ol> | |||
Latest revision as of 15:29, 9 July 2020
call player;query_level() always shows 1
[edit | edit source]/std/user.c :: query_level()
This function simply returns the object variable "level", which is only modified through set_level(). set_level() does a check to see whether the previous_object() is wizardp(), or if the euid of the previous_object() is UID_ADVANCE. If not, it returns. This appears to be the root of the issue, as functions which call set_level() (such as the _improve.c command) defer setting levels by calling set_level(1). set_level(1) then 'returns' with no integer (presumably 0 by default) and I believe the player's level remains what it was, 1.
/cmds/mortal/_improve.c :: cmd_improve() ... STAT_D->do_improvement(str, this_player()); .../daemon/stat_d.c :: do_improvement() ... /* set_stats() for me is inherited from living.c */ me->set_stats(str, current + 1); .../std/living.c :: set_stats() ... if(!wizardp(this_object()) && this_object()->is_player()){ seteuid(UID_ADVANCE); // This should be enough to satisfy living.c::set_level() this_object()->set_level(1); seteuid(getuid()); } ...
The current fix (probably will want to fine tune this, if this causes other bugs.
/std/living.c :: init_living() ... { // Added the following. However, I am not sure this is actually needed. seteuid(UID_ADVANCE); } .../daemon/stat_d.c :: do_improve() ... { // Added the following. This set the correct UID for the previous_object(). Also added UID_ADVANCE to this file in privs.db seteuid(UID_ADVANCE); me->set_stats(str, current + 1); seteuid(getuid()); } ...
Training skills does not raise level
[edit | edit source]/std/train_rm.c
Does not currently contain a set_level(1) like /adm/daemon/skills_d.c which will trigger setting appropriate level. Fix is to figure out where to plug a set_level(1) for a successful change in ability.
/std/living/skills.c
- Added at line 44: void init() { set_euid("Advance"); }
