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
Persistant Data Problem

 
Post new topic   Reply to topic Printable version
 View previous topic  Brand new AS3 installation on brand ne... Post :: Post Downloading  View next topic  
Author Message
.:IceRabbit:.
Newbie


Gender:Gender:Male
Joined: Aug 14 2006
Posts: 15
Offline

PostPosted: Tue Aug 22, 2006 2:57 am    Post subject: Persistant Data Problem Reply to topic Reply with quote

I have searched all over these forums, the A3S wiki, and the A3S homepage (including the guides) and I found very little on the Persistant Data feature of A3S. Using the turf module and alot of help from a fellow C/C++ programmer, I was able to get a module to compile. The problem is, is that while the "getdata" function works perfectly (from what I can tell on the terminal) the "setdata" and "cleardata" functions are never called. I even added a printf() in each just to be sure.

Nvm what I said before, here is the whole thing.




Here ya go.

blah.c - 15.51 KB
File downloaded or viewed 18 time(s)
Back to top
View users profile Send private message Add User to Ignore List
Grelminar
Creator of Asss


Joined: Feb 26 2003
Posts: 378
Offline

PostPosted: Wed Aug 23, 2006 3:27 am    Post subject: Reply to topic Reply with quote

Your clear_zone function is wrong: it should clear the data associated with p. The parameter v should be ignored. I'm very surprised that it doesn't just crash.
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website
.:IceRabbit:.
Newbie


Gender:Gender:Male
Joined: Aug 14 2006
Posts: 15
Offline

PostPosted: Wed Aug 23, 2006 4:20 am    Post subject: Reply to topic Reply with quote

Ah, ok. Thanks. I didn't see another void *data so I went with the other void param.

You mean like this?

Code: Show/Hide

local void clear_zone(Player *p, void *v)
{
   printf("\nClear\n");
    struct PersistentZoneData *d;
    d = PPDATA(p, pdkey);
   
    // Stats
   d->exp = 0;
   d->lvl = 0;
   d->neg = 0;
   d->race = 0;
   
   // Money
   d->money = 0;
   
   // Inventory
   d->burst = 0;
}


Edit: I changed the code, but the same thing happens, neither "Clear" nor "Set" are called. Here is the log:




asss.log - 6.43 KB
File downloaded or viewed 8 time(s)
Back to top
View users profile Send private message Add User to Ignore List
Grelminar
Creator of Asss


Joined: Feb 26 2003
Posts: 378
Offline

PostPosted: Wed Aug 23, 2006 4:21 pm    Post subject: Reply to topic Reply with quote

You're registering the persistent data from your arena attach event. That makes no sense, since the data is declared to be global (shared across arenas). And even if it was per-arena, persistent data isn't designed to be registered per-arena without doing a lot of extra work. What ends up happening is that the arena isn't created until after you finish logging in, so the pd isn't registered until that time. But clear/set for global data happens during login.

Move the registration into MM_LOAD/MM_UNLOAD.
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website
.:IceRabbit:.
Newbie


Gender:Gender:Male
Joined: Aug 14 2006
Posts: 15
Offline

PostPosted: Wed Aug 23, 2006 6:07 pm    Post subject: Reply to topic Reply with quote

Wow... I feel SOOO stupid right now... I mean I know its my first module... but wow.

If it wasn't obvious, it works now.
Back to top
View users profile Send private message Add User to Ignore List
.:IceRabbit:.
Newbie


Gender:Gender:Male
Joined: Aug 14 2006
Posts: 15
Offline

PostPosted: Sun Oct 29, 2006 5:01 pm    Post subject: Reply to topic Reply with quote

Ok, back again with another problem. I believe it fits under the same topic.

I'm trying to split my module into a number of different modules, so I can easily disable features in some arenas while the player's data stays global.

I had problems with my own module so I made a new barebones one that only has one variable per player. It has the main module and the secondary module. The main one edits the variable "value" and the secondary should then read it and display it using ?second.

Heres the src and module.




Pesistent test.rar - 13.58 KB
File downloaded or viewed 7 time(s)
Back to top
View users profile Send private message Add User to Ignore List
.:IceRabbit:.
Newbie


Gender:Gender:Male
Joined: Aug 14 2006
Posts: 15
Offline

PostPosted: Sat Nov 04, 2006 1:46 pm    Post subject: Reply to topic Reply with quote

Um, sorry for being a pain but its been six days since I posted and I really need a solution so I can continue working on the rest of my module which works around this part.
Back to top
View users profile Send private message Add User to Ignore List
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Sat Nov 04, 2006 5:08 pm    Post subject: Reply to topic Reply with quote

Generally speaking persist get/set functions are only called when players enter/leave. What you are doing is keeping a local copy of the persistent data in per-player memory for both modules. However this mem is private to each module, so if you write to it in main then second won't see the changes. Even worse when the player leaves the last module loaded, lets say second, gets the final say at what is saved back to the persistent storage.

I see you made an attempt at sharing the per-player mem by sticking pdkey in a header file. You also put "local" infront of it, which is the same as "static", meaning it's not visible outside the current file. You are also allocating per-player data in both modules, when I think you only want to do it in main and then somehow pass the value of pdkey to second.

Solutions:
- Create a new interface for the main module with get/set methods on all the fields you plan to save.
- Create a new interface for the main module with a getPdkey method.
- Remove the "local" keyword infront of pdkey in the header file. Although the simplest, this may not be such a good idea. To make it safer rename pdkey to something like mymodulename_pdkey, that way it is less likely to conflict with other modules not written by you should they have a variable of the same name.
Note: All these solutions require you to stop calling AllocatePlayerData in second.

I think the first solution will be the best in the long run, since it doesn't require all modules to know the internal layout of the data.
_________________
ss news
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
.:IceRabbit:.
Newbie


Gender:Gender:Male
Joined: Aug 14 2006
Posts: 15
Offline

PostPosted: Sun Nov 05, 2006 10:39 pm    Post subject: Reply to topic Reply with quote

Ok I'm using your first method and using the developer's guide, I made a interface out of main.c called "mine". Everything compiled but the server won't load it. icon_confused.gif I'm sure its something retarded I'm not picking up on but what else is new? Here is the src and module if you don't mind looking though it.



Pesistent test.rar - 14.01 KB
File downloaded or viewed 7 time(s)
Back to top
View users profile Send private message Add User to Ignore List
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Mon Nov 06, 2006 12:32 pm    Post subject: Reply to topic Reply with quote

Ok this is just missing one thing, you need to register your interface inside MM_LOAD and unregister it in MM_UNLOAD.

Using ap_multipub.c as an example:
Code: Show/Hide
local Iarenaplace myint =
{
   INTERFACE_HEAD_INIT(I_ARENAPLACE, "ap-multipub")
   Place
};

Code: Show/Hide
   if (action == MM_LOAD)
   {
...
      mm->RegInterface(&myint, arena);

Code: Show/Hide
   else if (action == MM_UNLOAD)
   {
      if (mm->UnregInterface(&myint, arena))
         return MM_FAIL;
...

Two things I suggest for your module 1) rename data to myint, 2) move "typedef struct PersistentData" from the header file to main.c.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
.:IceRabbit:.
Newbie


Gender:Gender:Male
Joined: Aug 14 2006
Posts: 15
Offline

PostPosted: Mon Nov 06, 2006 8:18 pm    Post subject: Reply to topic Reply with quote

Yay! It works! (Of course, Smong was involved! tongue.gif)

Here is the src if it will help anyone else.




Pesistent Data.rar - 13.36 KB
File downloaded or viewed 12 time(s)
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: 45 page(s) served in previous 5 minutes.

phpBB Created this page in 0.475623 seconds : 38 queries executed (92.9%): GZIP compression disabled