Server Help

ASSS Custom Projects - controllable doors

Smong - Sun Aug 07, 2005 7:37 am
Post subject: controllable doors
Here's a module that use regions to open doors for 5 seconds.

The module is usable as is, but is quite basic. Adding more functionality such as closing doors when entering a region, or restricting to certain ships/freqs shouldn't be too hard to add.

It does write to arena.conf every time a door is toggled, I did try the temporary setting thing but it didn't seem to work.
Bak - Sun Aug 07, 2005 8:53 am
Post subject:
I didn't know you could pass arena parameters to the timer, good work.
50% Packetloss - Sun Aug 07, 2005 4:17 pm
Post subject:
mainloop.h
Code: Show/Hide

   /** Starts a timed event.
    * @param func the TimerFunc to call
    * @param initialdelay how long to wait from now until the first
    * call (in ticks)
    * @param interval how long to wait between calls (in ticks)
    * @param param a closure argument that will get passed to the timer
    * function
    * @param key a key that can be used to selectively cancel timers
    */
   void (*SetTimer)(TimerFunc func, int initialdelay, int interval,
         void *param, void *key);

/** timer functions must be of this type.
* @param param is a closure argument
* @return true if the timer wants to continue running, false if it
* wants to be cancelled
*/
typedef int (*TimerFunc)(void *param);


Why did you use cfg->FlushDirtyValues();? Was the server not updating it fast enough? I think it does it every 500 ticks?
Smong - Sun Aug 07, 2005 6:15 pm
Post subject:
The door only opens for 5 seconds anyway, plus it would look better if it opened as soon as the player triggered it.
Grelminar - Wed Aug 10, 2005 7:55 pm
Post subject:
I didn't actually look at the source, but your comments indicate that you're using cfg->SetInt. Much better would be to use clientset->ArenaOverride, and then clientset->SendClientSettings on each player (and if it's a common pattern, I can add a utility function to do that second part). That will avoid going through the config system entirely, so you won't have to worry about conf files, and you have control over when the packets are sent.

I am curious why the temporary thing wasn't working, though.
Smong - Thu Aug 11, 2005 1:17 pm
Post subject:
It seemed the temporary settings only got sent to clients when a permanent setting was written to disk during the dirty status check.

I don't think the temporary settings were marked as dirty, but when settings are written to disk it thens calls a settings change callback which I suspect causes another module to send the necessary packets.
Grelminar - Thu Aug 11, 2005 4:41 pm
Post subject:
Oh, I see. There are various ways to fix that, although none of them is really satisfactory. It would be bad, for example, to do the config changed callback after every temporary settings change, because that would lead to bad behavior if you're doing 100 of them in a row. It might be possible to have temporary changes get marked as dirty, so the periodic file updater would see them and do the callback, but not write them to disk. Another solution might be to add a function to clientset to reload all settings and send the packets if necessary, just like the config changed callback does.

But I'm more inclined to do nothing, and instead have people use the clientset override functions, which are the better solution.
Elnino - Thu Aug 17, 2006 3:21 pm
Post subject:
What if I crontab a cp command to overwrite the arena.conf ?
like "cp arena.ok arena.conf"
that's a little dirty but anyone else found something ... ?

sry for waking this old thread up biggrin.gif

Thx
Elnino
D1st0rt - Sun Aug 27, 2006 1:32 pm
Post subject:
The best way to do it is clientset overrides, don't use crontab. The Hyperspace racing module uses overrides and they're just dandy.
Elnino - Tue Aug 29, 2006 10:38 am
Post subject:
Thx D1st0rt

You have some code snipplet or some doc to help a newbie ?

or you can just post the line Ill figure the stuff all by myself biggrin.gif
D1st0rt - Tue Aug 29, 2006 9:39 pm
Post subject:
Here's how it's set up in the race module:

at the top you have to include a header
Code: Show/Hide
#include "clientset.h"

Then you need to declare a variable for the clientset module and your setting
Code: Show/Hide
local Iclientset *cs;
local override_key_t ok_DoorMode;

In MM_LOAD, you need to initialize your override key
Code: Show/Hide
ok_DoorMode = cs->GetOverrideKey("door", "doormode");

In the arena settings I had the door mode defaulted to have them open so I overrided it to close and then removed the override it to open them again.
Code: Show/Hide
local void closeDoors(Arena *a)
{
   Player *p;
   Link *link;

   cs->ArenaOverride(a, ok_DoorMode, 255);

   pd->Lock();
   FOR_EACH_PLAYER(p)
   {
      if(p->arena == a)
         cs->SendClientSettings(p);
   }
   pd->Unlock();
}

local void openDoors(Arena *a)
{
   Player *p;
   Link *link;

   cs->ArenaUnoverride(a, ok_DoorMode);

   pd->Lock();
   FOR_EACH_PLAYER(p)
   {
      if(p->arena == a)
         cs->SendClientSettings(p);
   }
   pd->Unlock();
}

Alternatively you could do something like have a function that takes door mode as a parameter.

In MM_DETACH I call the openDoors function to remove the override, I don't know if this is necessary but it's probably still a good idea.
Elnino - Wed Aug 30, 2006 10:46 am
Post subject:
Godly !
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group