simple_list resets itself

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
1 year 8 months ago - 1 year 8 months ago #6467 by JTP
simple_list resets itself was created by JTP
To give the fly spell more meaning, what are the different places to look, if i wanted to try add half move cost when affected by fly, moving through the different terrain types ?


Also i would like a certain class to every 5 levels automatic gain hitroll/damroll and ac without wearring gear ? Where could that be done ?
Last edit: 1 year 8 months ago by JTP.

Please Log in or Create an account to join the conversation.

More
1 year 8 months ago - 1 year 8 months ago #6468 by Liko
Replied by Liko on topic simple_list resets itself

JTP wrote: To give the fly spell more meaning, what are the different places to look, if i wanted to try add half move cost when affected by fly, moving through the different terrain types ?


Also i would like a certain class to every 5 levels automatic gain hitroll/damroll and ac without wearring gear ? Where could that be done ?


Open act.movement.c and search need_movement. Under need_movement add:
        if (AFF_FLAGGED(ch, AFF_FLYING)) {
                need_movement  /= 2;
        }

2. class.c is where leveling is handled. I would program something like that in advance_level

DragonBall: Tournament (1.2.0)
Owner/Developer
Last edit: 1 year 8 months ago by Liko.

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
1 year 8 months ago - 1 year 8 months ago #6469 by JTP
Replied by JTP on topic simple_list resets itself
Ok i tried adding it here under advance_level, it Works when leveling up, BUT it sets the numbers to a number, then when people have eq on that also adds hitroll/damroll/ac while leveling from 6-7 and remove it, they suddently have -3 damroll, and mess it all up.

Any thoughts on what i need to do better ? Cant keep walking around naked for it to Work :)
  case CLASS_*****:
    add_hp += rand_number(8, 14);
    add_mana = 0;
    add_move = rand_number(1, 3);
  if (GET_LEVEL(ch) >=1 && GET_LEVEL(ch) <= 6) {
    GET_HITROLL(ch) = 1;
    GET_AC(ch) = 95;
  }
  if (GET_LEVEL(ch) >=7 && GET_LEVEL(ch) <= 12) {
    GET_HITROLL(ch) = 1;
    GET_DAMROLL(ch) = 1;
    GET_AC(ch) = 90;
  }
    break;
Last edit: 1 year 8 months ago by JTP.

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
1 year 8 months ago - 1 year 8 months ago #6470 by JTP
Replied by JTP on topic simple_list resets itself
I also tried:
{
  if (GET_LEVEL(ch) >=1 && GET_LEVEL(ch) <= 6) {
    GET_HITROLL(ch) = 1;
  }
  if (GET_LEVEL(ch) >=7 && GET_LEVEL(ch) <= 12) {
    GET_DAMROLL(ch) += 1;
  }
  if (GET_LEVEL(ch) >=13 && GET_LEVEL(ch) <= 18) {
    GET_HITROLL(ch) += 1;
  }
  if (GET_LEVEL(ch) >=19 && GET_LEVEL(ch) <= 24) {
    GET_DAMROLL(ch) += 1;
  }
  if (GET_LEVEL(ch) >=25 && GET_LEVEL(ch) <= 30) {
    GET_HITROLL(ch) += 1;
  }
  if (GET_LEVEL(ch) >=31 && GET_LEVEL(ch) <= 36) {
    GET_DAMROLL(ch) += 1;
  }
  if (GET_LEVEL(ch) >=37 && GET_LEVEL(ch) <= 42) {
    GET_HITROLL(ch) += 1;
  }
  if (GET_LEVEL(ch) >=43 && GET_LEVEL(ch) <= 48) {
    GET_DAMROLL(ch) += 1;
  }
  if (GET_LEVEL(ch) >=49 && GET_LEVEL(ch) <= 50) {
    GET_HITROLL(ch) += 1;
  }
}

This seems to Work for the hitroll and damroll...but if i try lower AC it is messed after having gear on and leveling and then removing gear, ends up with ac of 108.

Only problems with above code for hitroll and damroll is if i advance the test char, then it adds for every level. Ending up with ALOT haha.

But leveling up on its own it Works.


Ideas welcome to improve it and also add lowering AC
Last edit: 1 year 8 months ago by JTP.

Please Log in or Create an account to join the conversation.

More
1 year 8 months ago #6471 by thomas
Replied by thomas on topic simple_list resets itself
You are onto something. Avoid directly setting the AC, hitroll and damroll, ie. don't use "GET_HITROLL(ch) = 1" because this is what's getting you into trouble.

Some things to note up front:
You might not want to give bonuses on every level up - this will eventually lead to some really OP characters.
Hitroll and damroll bonuses are better when getting higher.
AC is better when getting lower.


I would perhaps do something like this:
+int class_xxx_level_bonus[][3] = {
+// HR, DR, AC
+  {1, 0, 0},
+  {0, 0, -5},
+  {0, 1, 0},
+  {1, 0, 0},
+  {0, 0, -5},
+  {0, 1, 0},
+  {1, 0, 0},
+  {0, 0, -5},
+  {0, 1, 0},
+  {1, 0, 0},
+  {0, 0, -5},
+  {0, 1, 0},
+  {1, 0, 0},
+  {0, 0, -5},
+  {0, 1, 0},
+  {1, 0, 0},
+  {0, 0, -5},
+  {0, 1, 0} // expand until you have MAX_LEVEL lines. 
+};

/* This function controls the change to maxmove, maxmana, and maxhp for each
 * class every time they gain a level. */
void advance_level(struct char_data *ch)
{
  int add_hp, add_mana = 0, add_move = 0, i;

  add_hp = con_app[GET_CON(ch)].hitp;

  switch (GET_CLASS(ch)) {
+  case CLASS_XXX:
+    add_hp += rand_number(10, 15);
+    add_mana = 0;
+    add_move = rand_number(1, 3);

+    GET_HITROLL(ch) += class_xxx_level_bonus[GET_LEVEL(ch)][0];
+    GET_DAMROLL(ch) += class_xxx_level_bonus[GET_LEVEL(ch)][1];
+    GET_AC(ch) += class_xxx_level_bonus[GET_LEVEL(ch)][2];
+    break;

  case CLASS_MAGIC_USER:
note how this uses += everywhere? This means that the correct value will be saved in the player files, after subtracting/adding anything the player is wearing or affected by.

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
1 year 8 months ago - 1 year 8 months ago #6472 by JTP
Replied by JTP on topic simple_list resets itself
Just tested it, max character ended up with ac 55 and hitroll 4 and damroll 5

Should have been 50 +5 +5...ponder ponder, just double checked over the levels it adds +1 hitroll 5 times, and +1 damroll 5 times...for ac -5 10 times.


Though the good news is that it Works with gear on when advancing, then removed gear and it was still ac 55 +4 +5

Just dunno why its not 50 +5 +5



// HR, DR, AC
{1, 0, -5}, <<<---maybe first line is regarded as lvl 0 ? and is not added ? It would explain the missing +1 hitroll and -5 ac. Or any other idea ?
Last edit: 1 year 8 months ago by JTP.

Please Log in or Create an account to join the conversation.

More
1 year 8 months ago #6473 by Liko
Replied by Liko on topic simple_list resets itself

JTP wrote: Just tested it, max character ended up with ac 55 and hitroll 4 and damroll 5

Should have been 50 +5 +5...ponder ponder, just double checked over the levels it adds +1 hitroll 5 times, and +1 damroll 5 times...for ac -5 10 times.


Though the good news is that it Works with gear on when advancing, then removed gear and it was still ac 55 +4 +5

Just dunno why its not 50 +5 +5



// HR, DR, AC
{1, 0, -5}, <<<---maybe first line is regarded as lvl 0 ? and is not added ? It would explain the missing +1 hitroll and -5 ac. Or any other idea ?


I've been sitting thinking about your solution, wouldn't it be easier to use a for loop?
for(int i = 0; i < MAX_LEVEL; i++) {
   if(i % 5) {
    //do stuff here
   }
}

Above code should work, may need some tweaking. I would define a MAX_LEVEL for mortals.

DragonBall: Tournament (1.2.0)
Owner/Developer

Please Log in or Create an account to join the conversation.

More
1 year 8 months ago #6475 by thomas
Replied by thomas on topic simple_list resets itself
Yes, first line is level 0. You could just add a "no-op" line like {0, 0, 0} there.

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
1 year 8 months ago - 1 year 8 months ago #6476 by JTP
Replied by JTP on topic simple_list resets itself
Thanks that made it work.



On a side note: syserr simple_list() forced to reset itself

Whats the deal with that ? Picture is from file error.
Attachments:
Last edit: 1 year 8 months ago by JTP.

Please Log in or Create an account to join the conversation.

More
1 year 8 months ago #6477 by thomas
Replied by thomas on topic simple_list resets itself
Good question. Somewhere, one of the lists assigned with simple_list() attempts to loop too far.

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
1 year 8 months ago #6478 by JTP
Replied by JTP on topic simple_list resets itself
grep of simple_list

act.other.c:  while ((k = (struct char_data *) simple_list(ch->group->members)) != NULL)
act.other.c:    while ((group = (struct group_data *) simple_list(group_list)) != NULL) {
act.other.c:      while ((k = (struct char_data *) simple_list(GROUP(ch)->members)) != NULL)
act.other.c:    while ((k = (struct char_data *) simple_list(GROUP(ch)->members)) != NULL)
Binary file act.other.o matches
comm.c:    while ((pEvent = simple_list(d->events)) != NULL)
comm.c:  while ((tch = simple_list(group->members)) != NULL) {
Binary file comm.o matches
db.c:           while ((pEvent = simple_list(world[cnt].events)) != NULL)
db.c:           while ((pEvent = simple_list(ch->events)) != NULL)
Binary file db.o matches
fight.c:  while ((k = (struct char_data *) simple_list(GROUP(ch)->members)) != NULL)
fight.c:  while ((k = (struct char_data *) simple_list(GROUP(ch)->members)) != NULL)
fight.c:      while ((tch = (struct char_data *) simple_list(GROUP(ch)->members)) != NULL) {
Binary file fight.o matches
genwld.c:               while ((pEvent = simple_list(room->events)) != NULL)
Binary file genwld.o matches
handler.c:              while ((pEvent = simple_list(obj->events)) != NULL)
Binary file handler.o matches
lists.c:  clear_simple_list();
lists.c:    while ((pContent = simple_list(pList)))
lists.c:void clear_simple_list(void)
lists.c: * while ((var = (struct XXX_data *) simple_list(XXX_list))) {
lists.c:void * simple_list(struct list_data * pList)
lists.c:    clear_simple_list();
lists.c:      mudlog(CMP, LVL_GRGOD, TRUE, "SYSERR: simple_list() forced to reset itself.");
lists.h:void * simple_list(struct list_data * pList);
lists.h:void clear_simple_list(void);
Binary file lists.o matches
magic.c:  while ((tch = (struct char_data *) simple_list(GROUP(ch)->members)) != NULL) {
Binary file magic.o matches
mud_event.c:  clear_simple_list();
mud_event.c:  while ((pEvent = (struct event *) simple_list(ch->events)) != NULL) {
mud_event.c:  clear_simple_list();
mud_event.c:  while ((pEvent = (struct event *) simple_list(ch->events)) != NULL) {
mud_event.c:  clear_simple_list();
mud_event.c:  while ((pEvent = (struct event *) simple_list(ch->events)) != NULL) {
Binary file mud_event.o matches

Please Log in or Create an account to join the conversation.

More
1 year 8 months ago #6479 by WhiskyTest
Replied by WhiskyTest on topic simple_list resets itself
I've had the simple_list reset itself when using lists inside lists, an example of what that might be:

list all players, for each player list their equipment
so it makes a list of the players equipment while already listing all players.. something like that?

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
1 year 8 months ago #6480 by JTP
Replied by JTP on topic simple_list resets itself
I havent added anything to simple_list or added additional usage of lists. I only have what was in the the code.

So i have no idea, what command causes it.

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
1 year 8 months ago #6492 by JTP
Replied by JTP on topic simple_list resets itself
Anyone with an idea why simple_list resets itself ? Seems it has something todo with the Group system...atleast my best guess..


tba 3.64

Please Log in or Create an account to join the conversation.

More
1 year 8 months ago #6493 by thomas
Replied by thomas on topic simple_list resets itself
It happens if two places in the code uses simple_list within each other because the simple_list holds internal state. In such cases, one should use the iterator solution instead (have a look in simple_list() in lists.c for how it's done).

Apparently it doesn't happen often - you will always have two hits close to each other (one when the outer loop is surpassed by the inner, and one when the inner loop is done).

I don't think it is related to your crashes.

However, if you really want to find out what's happening (and who doesn't ;) you can get some debugging info by dumping core when it happens:
  if (!loop || pLastList != pList) {
-    if (loop && pLastList != pList) 
+    if (loop && pLastList != pList) {
      mudlog(CMP, LVL_GRGOD, TRUE, "SYSERR: simple_list() forced to reset itself.");
+     core_dump();
+     }
  
    pContent = merge_iterator(&Iterator, pList);
This will give you a core dump to let you see a backtrace.

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
1 year 8 months ago - 1 year 8 months ago #6494 by JTP
Replied by JTP on topic simple_list resets itself
Nope it doesnt seem to crash anything, just appears in log some times 2-3 times, other times maybe 7-8 times.

And most of what i can grep that uses simple_list is Group related.



Also Thomas did you have any ideas on what im missing in 3.64 with those crashes where i posted core info ?
Last edit: 1 year 8 months ago by JTP.

Please Log in or Create an account to join the conversation.

More
1 year 8 months ago #6497 by thomas
Replied by thomas on topic simple_list resets itself
Many things have changed. See here for the full list:

github.com/tbamud/tbamud/compare/238a6d1...801bf118029...master

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
1 year 8 months ago #6499 by JTP
Replied by JTP on topic simple_list resets itself
Nothing seems to have enything to do with group like my greb search further up this thread. So maybe it isnt fixed, anyone try fiddle around with a 3-4 characters in a group for a few hours. And see if logs show reset after reboot.

Please Log in or Create an account to join the conversation.

Time to create page: 1.905 seconds