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
<C> ASSS RPG Module

 
Post new topic   Reply to topic Printable version
 View previous topic  <C> Sqlite Post :: Post UBill 0.2 Biller Beta Release  View next topic  
Author Message
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Sun Sep 27, 2009 1:57 am    Post subject: <C> ASSS RPG Module Reply to topic Reply with quote

The RPG Module is simple:
It allows any zone to have permanent ships, saved across logouts and zone crashes.
The ships are saved in 2 tables in a mySQL database.
This module only remembers ships and players, you must write a module to make changes to the ships, using the interface.
Module produces no output. (besides log)
No powers are available.
Source attached.

For Global.conf:
Code: Show/Hide

[RPG]
Autosave=600 //in seconds


For Arena.conf
Code: Show/Hide

[Kill]
EnterDelay=500 //in centiseconds, uses this value
//be sure to have this in arena.conf, not arena.cfg


To create database tables:
Code: Show/Hide

CREATE TABLE `rpgplayer` (
  `UserId` int(10) unsigned NOT NULL auto_increment,
  `UserName` varchar(20) NOT NULL,
  `ShipID0` int(10) NOT NULL default '-1',
  `ShipID1` int(10) NOT NULL default '-1',
  `ShipID2` int(10) NOT NULL default '-1',
  `ShipID3` int(10) NOT NULL default '-1',
  `ShipID4` int(10) NOT NULL default '-1',
  `ShipID5` int(10) NOT NULL default '-1',
  `ShipID6` int(10) NOT NULL default '-1',
  `ShipID7` int(10) NOT NULL default '-1',
  PRIMARY KEY  (`UserId`),
  UNIQUE KEY `UserName` (`UserName`),
  UNIQUE KEY `UserName_2` (`UserName`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1

CREATE TABLE `rpgship` (
  `Ship` int(10) unsigned NOT NULL,
  `ShipId` int(10) unsigned NOT NULL auto_increment,
  `UserId` int(10) unsigned NOT NULL,
  `ROT` int(10) unsigned NOT NULL default '0',
  `THR` int(10) unsigned NOT NULL default '0',
  `SPD` int(10) unsigned NOT NULL default '0',
  `NRG` int(10) unsigned NOT NULL default '0',
  `RECH` int(10) unsigned NOT NULL default '0',
  `Gun` int(10) unsigned NOT NULL default '0',
  `Bomb` int(10) unsigned NOT NULL default '0',
  `Shrap` int(10) unsigned NOT NULL default '0',
  `Prox` int(10) unsigned NOT NULL default '0',
  `Multi` int(10) unsigned NOT NULL default '0',
  `Bounce` int(10) unsigned NOT NULL default '0',
  `Stealth` int(10) unsigned NOT NULL default '0',
  `Cloak` int(10) unsigned NOT NULL default '0',
  `Xradar` int(10) unsigned NOT NULL default '0',
  `Anti` int(10) unsigned NOT NULL default '0',
  `Rep` int(10) unsigned NOT NULL default '0',
  `Burst` int(10) unsigned NOT NULL default '0',
  `Decoy` int(10) unsigned NOT NULL default '0',
  `Thor` int(10) unsigned NOT NULL default '0',
  `Brick` int(10) unsigned NOT NULL default '0',
  `Rocket` int(10) unsigned NOT NULL default '0',
  `Portal` int(10) unsigned NOT NULL default '0',
  PRIMARY KEY  (`ShipId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1


Known limitations:
Database tables must be originally created before module use, else crash.
Only 1 arena can be attached at a time, as data is saved under 1 name. (might change later)
Avoid loading in game, any entered players can cause instability.
Database crashes should cause the module to suicide, not crash.
Quick changing produces no prizing, instead of crash.

to-do list:
table auto-create
multiple tables/arenas
replace suicide with db check+iface
_________________
SSC Distension Owner
SSCU Trench Wars Developer




RPG Module
By Cheese

rpg.zip - 16.65 KB
File downloaded or viewed 68 time(s)


Last edited by Cheese on Mon Sep 28, 2009 9:47 pm, edited 3 times in total
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
Cheese?
Guest


Offline

PostPosted: Sun Sep 27, 2009 2:06 am    Post subject: Reply to topic Reply with quote

made sample module that makes use of the interface.

this is a sneeze away from working properly.
however, i am terrible with pointers and memory allocation.

currently crashes, need someone to take a look at why...
crash is reached just before check 3.



-edit-
anonymous posting is now a pain in the ass




RPG Interface Test

rpg2.zip - 5.42 KB
File downloaded or viewed 63 time(s)
Back to top
Cheese?
Guest


Offline

PostPosted: Sun Sep 27, 2009 2:08 am    Post subject: Reply to topic Reply with quote

and i see that mgb still has yet to fix my signature...
Back to top
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Mon Sep 28, 2009 12:22 am    Post subject: Reply to topic Reply with quote

i have no debugger, so i have to add log messages and recompile...

its wierd, its looking like function is called, but the zone crashes before it ever actually gets to the content, does anyone know why that might happen?
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
Dr Brain
Flip-flopping like a wind surfer


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

PostPosted: Mon Sep 28, 2009 6:28 am    Post subject: Reply to topic Reply with quote

Get a debugger. Hobbyist or professional, you need to learn how to use one.
_________________
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
Doc Flabby
Server Help Squatter


Joined: Feb 26 2006
Posts: 636
Offline

PostPosted: Mon Sep 28, 2009 7:32 am    Post subject: Reply to topic Reply with quote

Is there an easy way to debug ASSS i've stuggled on windows to find a good way of doing it (short of recompiling the whole thing in visual studio, which itself has a number of problems.) Whats the recommended way of debugging a ASSS module.
_________________
Rediscover online gaming. Get Subspace | STF The future...prehaps
Back to top
View users profile Send private message Add User to Ignore List
Dr Brain
Flip-flopping like a wind surfer


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

PostPosted: Mon Sep 28, 2009 10:33 am    Post subject: Reply to topic Reply with quote

I just tried the mingw gdb on my windows laptop. I didn't put it through its paces, but it did start and run asss (compiled with mingw).
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Mon Sep 28, 2009 4:39 pm    Post subject: Reply to topic Reply with quote

gdb backtrace:

Code: Show/Hide

Program received signal SIGSEGV, Segmentation fault.
[Switching to thread 1092.0x1748]
0x6b901213 in FreqChange (p=0x199be20, newfreq=12) at rpg2.c:28
28                      ship=rpg->GetPlayerShip(p,shipnum);
(gdb) bt
#0  0x6b901213 in FreqChange (p=0x199be20, newfreq=12) at rpg2.c:28
#1  0x0041e1df in ?? ()
#2  0x0041e3af in ?? ()
#3  0x0040eb91 in ?? ()
#4  0x0040e974 in ?? ()
#5  0x6118132a in ptw32_threadStart@4 ()
#6  0x77c3a3b0 in _libmsvcrt_a_iname ()
#7  0x7c80b713 in _libmsvcrt_a_iname ()



^after you attempt freq change


Last edited by Cheese on Mon Sep 28, 2009 5:42 pm, edited 1 time in total
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
JoWie
Server Help Squatter


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

PostPosted: Mon Sep 28, 2009 4:41 pm    Post subject: Reply to topic Reply with quote

recompile your module with debugging symbols ( -g3 ) and post backtrace again
Back to top
View users profile Send private message Add User to Ignore List
JoWie
Server Help Squatter


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

PostPosted: Mon Sep 28, 2009 4:48 pm    Post subject: Reply to topic Reply with quote

Also, I have done debugging with gdb on windows and it works. But 10% of the crashes end up with a corrupt stack. Which is VERY annoying.

I tried to compile my modules in Visual Studio, but last i checked it does not support C99, so that requires to rewrite a LOT of stuff (variable declarations not at the start of functions)

Best way is to run linux in a virtual machine like VirtualBox (supports port forwarding)
Back to top
View users profile Send private message Add User to Ignore List
Dr Brain
Flip-flopping like a wind surfer


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

PostPosted: Mon Sep 28, 2009 6:10 pm    Post subject: Reply to topic Reply with quote

You're missing checks to make sure you got the modules from mm->GetInterface. You never register your interface. If you had the checks (like every other asss module), you'd have notice almost immediately.

See how much easier it is with a debugger? icon_smile.gif
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Hakaku
Server Help Squatter


Joined: Apr 07 2006
Posts: 299
Location: Canada
Offline

PostPosted: Mon Sep 28, 2009 6:20 pm    Post subject: Reply to topic Reply with quote

One thing I noticed which you still have yet to fix in your color module, is this:
Code: Show/Hide
   else if (action == MM_UNLOAD)
   {
      mm->ReleaseInterface(chat);
      mm->ReleaseInterface(game);
      mm->ReleaseInterface(lm);
      mm->ReleaseInterface(pd);
      mm->ReleaseInterface(rpg);

      lm->Log(L_ERROR,"<rpg> Module has been unloaded.");

      return MM_OK;
   }

You shouldn't be using the log interface after you just finished releasing it.

Also, why are you committing suicide / unloading the entire module if you can't connect to the database a single time? The problem with this is that if another module is using your interface, it won't unload properly and may cause instability in the module using it, potentially causing the zone to crash. (that or you'll have to forcebly ?shutdown -r to have them removed)
Back to top
View users profile Send private message Add User to Ignore List Send email
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Mon Sep 28, 2009 6:44 pm    Post subject: Reply to topic Reply with quote

i do have the interface checks, i never use/need them, but since this was being a huge pain in the ass, i did.
additionally, i already knew the error line:
ship=rpg->GetPlayerShip(p,shipnum);
meaning an interface error, still requiring no use of a debugger.

the interface is never registered, despite attempts to register it to one or all arenas...
Cheese!> and since reginterface doesnt return anything, i dont know if its being created


@hakaku
thanks for noticing, i originally had it at the beginning of the unload process, but decided to report the module as unloaded after it actually unloaded.
im guessing that error is now in everything i have made to date.
i suppose from now on itll just signal the beginning of the unload process...

also, having this registering works:
Code: Show/Hide

mm->RegInterface(&iface,ALLARENAS);
      local Irpg *rpg;
      rpg=mm->GetInterface(I_RPG,ALLARENAS);
      if (!rpg)
      {
           lm->Log(L_ERROR,"interface not registered");
      }
      else
      {
           lm->Log(L_ERROR,"interface is good");//always this
      }
      mm->ReleaseInterface(rpg);


yet while loading the second module to get the interface always fails:
Code: Show/Hide


      local Irpg *rpg;
...
rpg=mm->GetInterface(I_RPG,ALLARENAS);
      if (!rpg)
      {
           lm->Log(L_ERROR,"no interface");//always this
      }
      else
      {
           lm->Log(L_ERROR,"interface good");
      }


Last edited by Cheese on Mon Sep 28, 2009 6:57 pm, edited 2 times in total
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
Dr Brain
Flip-flopping like a wind surfer


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

PostPosted: Mon Sep 28, 2009 6:52 pm    Post subject: Reply to topic Reply with quote

Your code says you don't have interface checks.

It's not an interface error. Your pointer to rpg is NULL, because you never acquired the interface. If you had checks, you'd have noticed.

You don't call RegInterface. I don't see any attempts to register it to one or all arenas.
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Mon Sep 28, 2009 7:04 pm    Post subject: Reply to topic Reply with quote

heres updated files (similarly nonworking), with more debug messages.
rpg2 was compiled with -g3

Cheese!> ill worry about stability after it works
Cheese!> no need for brakes on a nonmoving car, imo

heres where you say 'no need for a parachute until you realize youre falling', amirite?


Last edited by Cheese on Mon Sep 28, 2009 8:05 pm, edited 1 time in total
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
Dr Brain
Flip-flopping like a wind surfer


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

PostPosted: Mon Sep 28, 2009 7:30 pm    Post subject: Reply to topic Reply with quote

Your code actually looks like this:

Code: Show/Hide
   if (action == MM_LOAD)
   {
      lm=mm->GetInterface(I_LOGMAN,ALLARENAS);
      game=mm->GetInterface(I_GAME,ALLARENAS);
      chat=mm->GetInterface(I_CHAT,ALLARENAS);
      pd=mm->GetInterface(I_PLAYERDATA,ALLARENAS);
      local Irpg *rpg2;
      rpg2=mm->GetInterface(I_RPG,ALLARENAS);
      if (!rpg)
      {
           lm->Log(L_ERROR,"no interface");
      }
      else
      {
           lm->Log(L_ERROR,"interface good");
      }
      mm->ReleaseInterface(rpg2);
      
      lm->Log(L_ERROR,"<rpg2> Module has been loaded.");
       
      return MM_OK;




Unlike the snippet you posted, the actual code does not initialize rpg. It only sets rpg2.

Still think checks are stupid?
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Mon Sep 28, 2009 8:05 pm    Post subject: Reply to topic Reply with quote

id personally like to thank you all for your help, everything works nicely now.

it seems my code was fine, the interface just wasnt being initialized properly.

the files have been updated.
i think ill make it possible to have multiple arenas with multiple db tables later...
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
Bak
?ls -s
0 in


Age:24
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Mon Sep 28, 2009 9:44 pm    Post subject: Reply to topic Reply with quote

why not use persist?
_________________
SubSpace Discretion: A Third Generation SubSpace Client
Back to top
View users profile Send private message Add User to Ignore List AIM Address
JoWie
Server Help Squatter


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

PostPosted: Tue Sep 29, 2009 5:03 am    Post subject: Reply to topic Reply with quote

I told you all of this yesterday...
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 Custom Projects 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: 427 page(s) served in previous 5 minutes.

phpBB Created this page in 1.167652 seconds : 45 queries executed (87.3%): GZIP compression disabled