| 
			
				|  | Server Help Community forums for Subgame, ASSS, and bots
 
 |  
 
	
	
		| Author | Message |  
		| Cheese Wow Cheese is so helpful!
 
  
 Joined: Mar 18 2007
 Posts: 1017
 Offline
 
 | 
			
			  | 
				
					|  Posted: Sun Sep 27, 2009 1:57 am     Post subject: <C> ASSS RPG Module |  |   |  |  
				| 
 |  
				| 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:
 
 	| 
[RPG]
 Autosave=600 //in seconds
 
 | 
 
 For Arena.conf
 
 	| 
[Kill]
 EnterDelay=500 //in centiseconds, uses this value
 //be sure to have this in arena.conf, not arena.cfg
 
 | 
 
 To create database tables:
 
 	| 
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 134 time(s)
 
 
 Last edited by Cheese on Mon Sep 28, 2009 9:47 pm, edited 3 times in total
 |  |  
		| Back to top |  |  
		|  |  
		| Cheese? Guest
 
 
 Offline
 
 | 
			
			  | 
				
					|  Posted: Sun Sep 27, 2009 2:06 am     Post subject: |  |   |  |  
				| 
 |  
				| 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 141 time(s)
 
 |  |  
		| Back to top |  |  
		|  |  
		| Cheese? Guest
 
 
 Offline
 
 | 
			
			  | 
				
					|  Posted: Sun Sep 27, 2009 2:08 am     Post subject: |  |   |  |  
				| 
 |  
				| 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
 
 | 
			
			  | 
				
					|  Posted: Mon Sep 28, 2009 12:22 am     Post subject: |  |   |  |  
				| 
 |  
				| 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 |  |  
		|  |  
		| Dr Brain Flip-flopping like a wind surfer
 
  
 Age:39
 Gender:
  Joined: Dec 01 2002
 Posts: 3502
 Location: Hyperspace
 Offline
 
 | 
			
			  | 
				
					|  Posted: Mon Sep 28, 2009 6:28 am     Post subject: |  |   |  |  
				| 
 |  
				| 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 |  |  
		|  |  
		| Doc Flabby Server Help Squatter
 
  
 Joined: Feb 26 2006
 Posts: 636
 Offline
 
 | 
			
			  | 
				
					|  Posted: Mon Sep 28, 2009 7:32 am     Post subject: |  |   |  |  
				| 
 |  
				| 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 |  |  
		|  |  
		| Dr Brain Flip-flopping like a wind surfer
 
  
 Age:39
 Gender:
  Joined: Dec 01 2002
 Posts: 3502
 Location: Hyperspace
 Offline
 
 | 
			
			  | 
				
					|  Posted: Mon Sep 28, 2009 10:33 am     Post subject: |  |   |  |  
				| 
 |  
				| 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 |  |  
		|  |  
		| Cheese Wow Cheese is so helpful!
 
  
 Joined: Mar 18 2007
 Posts: 1017
 Offline
 
 |  |  
		| Back to top |  |  
		|  |  
		| JoWie Server Help Squatter
 
 
 Gender:
  Joined: Feb 25 2004
 Posts: 215
 Offline
 
 | 
			
			  | 
				
					|  Posted: Mon Sep 28, 2009 4:41 pm     Post subject: |  |   |  |  
				| 
 |  
				| recompile your module with debugging symbols ( -g3 ) and post backtrace again |  |  
		| Back to top |  |  
		|  |  
		| JoWie Server Help Squatter
 
 
 Gender:
  Joined: Feb 25 2004
 Posts: 215
 Offline
 
 | 
			
			  | 
				
					|  Posted: Mon Sep 28, 2009 4:48 pm     Post subject: |  |   |  |  
				| 
 |  
				| 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 |  |  
		|  |  
		| Dr Brain Flip-flopping like a wind surfer
 
  
 Age:39
 Gender:
  Joined: Dec 01 2002
 Posts: 3502
 Location: Hyperspace
 Offline
 
 | 
			
			  | 
				
					|  Posted: Mon Sep 28, 2009 6:10 pm     Post subject: |  |   |  |  
				| 
 |  
				| 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?
   |  |  
		| Back to top |  |  
		|  |  
		| Hakaku Server Help Squatter
 
  
 Joined: Apr 07 2006
 Posts: 299
 Location: Canada
 Offline
 
 |  |  
		| Back to top |  |  
		|  |  
		| Cheese Wow Cheese is so helpful!
 
  
 Joined: Mar 18 2007
 Posts: 1017
 Offline
 
 | 
			
			  | 
				
					|  Posted: Mon Sep 28, 2009 6:44 pm     Post subject: |  |   |  |  
				| 
 |  
				| 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:
 
 	| 
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:
 
 	| 
 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 |  |  
		|  |  
		| Dr Brain Flip-flopping like a wind surfer
 
  
 Age:39
 Gender:
  Joined: Dec 01 2002
 Posts: 3502
 Location: Hyperspace
 Offline
 
 | 
			
			  | 
				
					|  Posted: Mon Sep 28, 2009 6:52 pm     Post subject: |  |   |  |  
				| 
 |  
				| 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 |  |  
		|  |  
		| Cheese Wow Cheese is so helpful!
 
  
 Joined: Mar 18 2007
 Posts: 1017
 Offline
 
 | 
			
			  | 
				
					|  Posted: Mon Sep 28, 2009 7:04 pm     Post subject: |  |   |  |  
				| 
 |  
				| 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 |  |  
		|  |  
		| Dr Brain Flip-flopping like a wind surfer
 
  
 Age:39
 Gender:
  Joined: Dec 01 2002
 Posts: 3502
 Location: Hyperspace
 Offline
 
 | 
			
			  | 
				
					|  Posted: Mon Sep 28, 2009 7:30 pm     Post subject: |  |   |  |  
				| 
 |  
				| Your code actually looks like this: 
 
 	|    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 |  |  
		|  |  
		| Cheese Wow Cheese is so helpful!
 
  
 Joined: Mar 18 2007
 Posts: 1017
 Offline
 
 | 
			
			  | 
				
					|  Posted: Mon Sep 28, 2009 8:05 pm     Post subject: |  |   |  |  
				| 
 |  
				| 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 |  |  
		|  |  
		| Bak ?ls -s
 0 in
 
  
 Age:26
 Gender:
  Joined: Jun 11 2004
 Posts: 1826
 Location: USA
 Offline
 
 |  |  
		| Back to top |  |  
		|  |  
		| JoWie Server Help Squatter
 
 
 Gender:
  Joined: Feb 25 2004
 Posts: 215
 Offline
 
 | 
			
			  | 
				
					|  Posted: Tue Sep 29, 2009 5:03 am     Post subject: |  |   |  |  
				| 
 |  
				| I told you all of this yesterday... |  |  
		| Back to top |  |  
		|  |  
		|  |  
  
	| 
 
 | 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
 
 |  
 Software by php BB © php BB Group
 Server Load: 33 page(s) served in previous 5 minutes.
 |