code


We are not going to be able to take relay message outside of game server very easily for several reasons:

  1. Game server level information associating character/player ids with sockets to preform a relay
  2. Relaying is an input only event. We receive input messages and send them to a different source.
  3. Routing and multi-casting needs to be done and this is also game server level information

I propose we keep it where it is but expand it to work on all messages that have a destination rather this be a character or a channel. We can simply look for the presence of a dst field in the input message (if just client to server there should be no dst the client just write the message down the socket) or if there is a chan field defined. These two conditions tell us the client wishes to relay this message to some other client on the server. I can think of a couple ways to implement this:

  • Have the server check if dst and chan exist in the message if so run RelayMessage on it. Then if you want to filter by command have it check if that command has relay perms.
  • Keep the structure much like it is and add explict calls in each cmd_X() to RelayMessage this way would be quicker but take up a bit more code bulk. This is of course its disadvantage it is not as flexible and needs to be rigidly defined.

Got a new class, JSONSocket to work last night, along with the MessageEvent helper event.

Basically:

var sock:JSONSocket = new JSONSocket(”localhost”,8500);
sock.addEventListener(MessageEvent.MESSAGE,msghandler);
sock.writeJSON({ type: ‘login’, name: ‘oizys’, auth: authstring });

function msghandler(e:MessageEvent):void { trace(e.message.text); }

I’m going to further abstract it to a GameSocket class and tail some message-specific code off of it, and a smarter Event registration, but then we’re ready to roll.

I recently purchased this book: ActionScript 3 Cookbook and it’s been an awesome investment. Since so much of AS3 is still badly documented/exampled, this has been a livesaver on some things. The book agrees with me that Flash’s startDrag() and stopDrag() are fundamentally broken, and provides a simple replacement that I’m going to base my code on.

I’ve started doing some widget coding since flash could definitely use some of these. The last example (the color picker) uses a RibbonWidget (basically something that updates or triggers on first mouse down or anytime mouse is down while you’re over it).
It has to use my MouseState utility class which I had to write (along with KeyboardState and KeyboardMap). It’s truly a travesty that I have to write these at all, but AS3 seems to turn a deaf eye to stateful programming in favor of completely loopy event-only coding. Using those singleton classes as a base instead of Keyboard and Mouse in AS3, I can treat them as button matrixes and just poll them at event time to see what their state is.

I’ve got a lot of new year’s resolutions surrounding Gemini, so I’ll definitely be posting more often.

Gamasutra.com - Binary Triangle Trees for Terrain Tile Index Buffer Generation

This is a well described algorithm. There needs to be more descriptions like this.

Just some quick thoughts on paper.


class Proposal
{
   protected $id;
   protected $name;
   protected $description;
   protected $creator; // character
   protected $onsuccess; // script
   protected $onfail; // script
   protected $oncancel; // script
   protected $faction; // faction
   protected $yesvotes;
   protected $novotes;
   protected $votepool; // number or null
   protected $type; // base ruleset for proposal, int
   protected $flags; // proposal options for rules
   protected $parent; // counterproposal to
   protected $created; // date
   protected $expires; // date
   protected $status;
}

class ProposalVote
{
   protected $id;
   protected $proposal;
   protected $created;
   protected $creator;
   protected $value;
   protected $comment;
}

Flow chart pseudo for a promotion proposal:

  • Click “promote” (script to promote with parameters prepared)
  • Check permissions in faction to do this
  • $proposal = $faction->proposals[’promote’][rank] contains nothing or a default proposal for creating that proposal at that rank
  • $proposal->type might be ‘instantaneous’ in which case, script is immediately ran
  • Otherwise, $proposal->Create() after filling in unique info creates the proposal
  • Based on type, events (expire, max votes filled, supermajority reached, etc) can cause a proposal to close with a ’success’, ‘fail’ or ‘cancel’ result.
  • If a script is attached to the appropriate handle for the proposal result, it is executed.
  • Proposal status is set to ‘closed’

Well, now that I finally know about MTASC, there is no need to fear pure ActionScript driven flash projects.

Some chat message types that we will need:

  • msg - sends a message to a channel
  • join - joins a channel
  • part - leaves a channel
  • mode - changes channel mode
  • kick - kicks another member from a channel
  • who - request list of members in a channel or by match
  • roll - request a random number reply in a channel
  • list - request list of public channels

There are probably 10x the number of client-side commands, but these are the message types to send to the server, and reply via.

I think most message types can be reused as return messages, since the server->client or client->server distinction will be obvious.