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
PlayerData

 
Post new topic   Reply to topic Printable version
 View previous topic  timer Post :: Post help with as3  View next topic  
Author Message
Guest



Offline

PostPosted: Mon Jul 02, 2007 9:54 am    Post subject: PlayerData Reply to topic Reply with quote

I have module which has player data which needs initialization.

So I am using PA_ENTERGAME in the PlayerAction Callback to initialize the variable.

However this seems to crash asss

Code: Show/Hide

local void PlayerAction (Player *p, int action, Arena *arena)
{
   if (action == PA_ENTERGAME) //Also crashes with PA_ENTERARENA
   {
      playerData* pdata = PPDATA(p, playerKey); //No crash if commented out
      pdata->blah = -1;
   }
}

The first time I enter nothing happens, but if I gotp a subarena, then come back to the public arena where it is attached, asss crashes.

There is nothing on the console and asss isn't entirely crashed (some things still work), I just get a windows error message box telling me a read/write operation on the memory failed.


Is it correct to initialize player data this way? Do I need to use a different callback?
Back to top
Animate Dreams
Gotta buy them all!
(Consumer whore)


Age:37
Gender:Gender:Male
Joined: May 01 2004
Posts: 821
Location: Middle Tennessee
Offline

PostPosted: Mon Jul 02, 2007 3:29 pm    Post subject: Reply to topic Reply with quote

I think it's perfectly fine to do it inside of PlayerAction, and both PA_ENTERGAME and PA_ENTERARENA. The only thing I can think of... you sure blah is a valid variable inside playerData? Also, I'd double-check your caps, to make sure they're all the same. It'd be nice to see your declaration of the playerData struct, too.
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address MSN Messenger
JoWie
Server Help Squatter


Gender:Gender:Male
Joined: Feb 25 2004
Posts: 215
Offline

PostPosted: Mon Jul 02, 2007 4:16 pm    Post subject: Reply to topic Reply with quote

here is the entire source



pershiplvz.c - 4.33 KB
File downloaded or viewed 27 time(s)
Back to top
View users profile Send private message Add User to Ignore List
Animate Dreams
Gotta buy them all!
(Consumer whore)


Age:37
Gender:Gender:Male
Joined: May 01 2004
Posts: 821
Location: Middle Tennessee
Offline

PostPosted: Mon Jul 02, 2007 4:40 pm    Post subject: Reply to topic Reply with quote

Well, since all you're doing is freeing your playerdata if it fails to load(line 75 for example), you really have no way of knowing if it ever loaded successfully. Also, why do you initialize your playerKey to be -1? I don't think you have to do that. Though, I'm pretty sure it gets written over, so that shouldn't be the problem. Anyway, you could rewrite the part, under MM_LOAD, to send an error message to the console when it wasn't allocating data properly, that way you'd know if the error was in allocation.

I also don't understand the oldship = -1. I didn't know that was valid, either. It might be, though. I'm no expert. I suppose you could try messing with it anyway. I'd try it myself, but I'm at work, and I forgot my IP so I can't ssh to my computer at home. icon_sad.gif
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address MSN Messenger
JoWie
Server Help Squatter


Gender:Gender:Male
Joined: Feb 25 2004
Posts: 215
Offline

PostPosted: Mon Jul 02, 2007 4:53 pm    Post subject: Reply to topic Reply with quote

If the player data fails to load, MM_FAIL is returned which means the module fails to load (and you get a message on your console IIRC). MM_ATTACH is then never called, this means the PlayerAction callback never gets registered.

Ship 0 is warbird
I set oldShip to -1 so the LVZ gets shown if your first ship is a warbird.

The reason why I use oldShip is to turn of the old LVZ object
Back to top
View users profile Send private message Add User to Ignore List
tcsoccerman
Server Help Squatter


Age:33
Gender:Gender:Male
Joined: Jan 15 2007
Posts: 694
Location: Atlantis
Offline

PostPosted: Tue Jul 03, 2007 10:19 am    Post subject: Reply to topic Reply with quote

Code: Show/Hide
local void PlayerAction (Player *p, int action, Arena *arena)
{
   if (p->action == PA_ENTERGAME)
   {
      playerData* pdata = PPDATA(p, playerKey); //No crash if commented out
      pdata->blah = -1;
   }
}

my attempt. just added "p->" in if statement
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
Animate Dreams
Gotta buy them all!
(Consumer whore)


Age:37
Gender:Gender:Male
Joined: May 01 2004
Posts: 821
Location: Middle Tennessee
Offline

PostPosted: Tue Jul 03, 2007 4:59 pm    Post subject: Reply to topic Reply with quote

Um, action is an int passed in by the function, PlayerAction, as you can see on line 1.
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address MSN Messenger
tcsoccerman
Server Help Squatter


Age:33
Gender:Gender:Male
Joined: Jan 15 2007
Posts: 694
Location: Atlantis
Offline

PostPosted: Tue Jul 03, 2007 5:02 pm    Post subject: Reply to topic Reply with quote

which means look in players.h or something to see what that is equal to in #'s.
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Tue Jul 03, 2007 5:27 pm    Post subject: Reply to topic Reply with quote

What? Animate is right, that's definitely not going to fix anything. (It will break things, instead.)
_________________
This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
tcsoccerman
Server Help Squatter


Age:33
Gender:Gender:Male
Joined: Jan 15 2007
Posts: 694
Location: Atlantis
Offline

PostPosted: Tue Jul 03, 2007 5:39 pm    Post subject: Reply to topic Reply with quote

nvm. i thought it would be similiar to mapdata, for example NO_TILE = 0, TILE_END = 1. and so on. i guess they're not the same.
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
Animate Dreams
Gotta buy them all!
(Consumer whore)


Age:37
Gender:Gender:Male
Joined: May 01 2004
Posts: 821
Location: Middle Tennessee
Offline

PostPosted: Tue Jul 03, 2007 5:59 pm    Post subject: Reply to topic Reply with quote

My point is, action isn't a variable in the Player struct. It is passed in, right there, in that function, on line 1. So simply checking "action" is correct. Even if there was a variable named action in the player struct, I'm pretty sure you'd still be expected to use the action passed in by the function. After all, that's why it's passed in.
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address MSN Messenger
JoWie
Server Help Squatter


Gender:Gender:Male
Joined: Feb 25 2004
Posts: 215
Offline

PostPosted: Tue Jul 03, 2007 6:28 pm    Post subject: Reply to topic Reply with quote

Getting back to the original problem, any idea why it crashes when requesting per player data in PA_ENTERGAME?
Back to top
View users profile Send private message Add User to Ignore List
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Wed Jul 04, 2007 11:41 am    Post subject: Reply to topic Reply with quote

I looked at it and couldn't get it to crash under linux. Under windows I can't tell if it's this module or another one causing it (I have so much custom stuff loaded). Maybe it's conflicting with another module? Although I would have thought pdkey would equal -1 if asss couldn't allocate space for it.
_________________
ss news
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
JoWie
Server Help Squatter


Gender:Gender:Male
Joined: Feb 25 2004
Posts: 215
Offline

PostPosted: Mon Jul 16, 2007 9:41 am    Post subject: Reply to topic Reply with quote

I have solved it. I added a few checks, I am not 100% sure which check solved the crashing but here is what I changed:

Code: Show/Hide

local void PlayerAction (Player *p, int action, Arena *arena)
{
   if (!p->arena || p->arena != arena || playerKey == -1) return; //Added, kind of an overkill

   if (action == PA_ENTERGAME)   {
      playerData* pdata = PPDATA(p, playerKey);
      if (!pdata) return; //Added
      pdata->oldShip = -1;
   }
}


I think the culprit was p->arena, since that can be NULL (see player.h)
Back to top
View users profile Send private message Add User to Ignore List
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: 207 page(s) served in previous 5 minutes.

phpBB Created this page in 0.525627 seconds : 40 queries executed (81.2%): GZIP compression disabled