Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
Random values from PDATA

 
Post new topic   Reply to topic Printable version
 View previous topic  Generic event handler? Post :: Post Debugging deadlocks  View next topic  
Author Message
the_snake
Guest


Offline

PostPosted: Wed Feb 16, 2011 6:39 am    Post subject: Random values from PDATA Reply to topic Reply with quote

Hey,

I have this weird problem:
I load data onto a pdata struct
after it loads the output is this, which is correct:
Warbird: Level - 1, EXP - 200
Javelin: Level - 0, EXP - 0
Spider: Level - 0, EXP - 0
Leviathan: Level - 0, EXP - 0
Terrier: Level - 0, EXP - 0
Weasel: Level - 0, EXP - 0
Lancaster: Level - 0, EXP - 0
Shark: Level - 0, EXP - 0

Then I want to confirm the output by displaying it once more using a command ?mystats:
snake> ?mystats
Level - 1
Level - 0
Level - 15
Level - 1
Level - 0
Level - 0
Level - 0
Level - 0
then i wait a while(10 secs), doing nothing in the zone:
snake> ?mystats
Level - 1
Level - 0
Level - 77
Level - 97
Level - 11
Level - 1
Level - 0
Level - 0

and once more:
snake> ?mystats
Level - 1
Level - 0
Level - 77
Level - 164
Level - 36
Level - 1
Level - 0
Level - 0


the values seem to increase for some reason....

any idea why?

the struct is typedef struct MyPlayerData
{
int level[8];
int exp[8];
int oldship;
} MyPlayerData;


and i access it with:

Code: Show/Hide

local void ShowStats(const char *command, const char *params, Player *p, const Target *target)
{
   MyPlayerData* pdata = PPDATA(p, playerKey);
   if (pdata)
   {
      int i;
      for (i=0;i<8;i++)
      {
         //if (pdata->level[i] > (start_level[i]))
         chat->SendArenaMessage(p->arena,"Level - %i", pdata->level[i]);
      }
   }
   
}



thanks
Back to top
Dr Brain
Flip-flopping like a wind surfer


Age:32
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Wed Feb 16, 2011 7:07 am    Post subject: Reply to topic Reply with quote

Do you allocate the memory with amalloc? Make sure you use the size of the struct and not the size of a pointer to the struct.

Your access code looks fine to me, so lets see the init code.
_________________
Hyperspace Owner

Smong> so long as 99% deaths feel lame it will always be hyperspace to me
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
the_snake
Guest


Offline

PostPosted: Wed Feb 16, 2011 7:34 am    Post subject: Reply to topic Reply with quote

this is embarrassing, but apparently while i was cleaning up my code, i had accidently deleted


playerKey = pd->AllocatePlayerData(sizeof(MyPlayerData));

thanks anyhow lol
Back to top
Arnk Kilo Dylie
Seasoned Helper


Age:31
Gender:Gender:Male
Joined: Jul 14 2006
Posts: 108
Offline

PostPosted: Wed Feb 16, 2011 4:41 pm    Post subject: Reply to topic Reply with quote

If you learn ACE, you can save yourself worrying about a lot of the init/deinit details like that. </shamelessplug> icon_wink.gif
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> ASSS Questions All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 203 page(s) served in previous 5 minutes.

phpBB Created this page in 0.106012 seconds : 28 queries executed (71.2%): GZIP compression disabled