Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2000:
[Freeciv-Dev] Re: notify_player rewrite
Home

[Freeciv-Dev] Re: notify_player rewrite

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: "Per I. Mathisen" <Per.Inge.Mathisen@xxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: notify_player rewrite
From: Lauri Tarkkala <ltarkkal@xxxxxxxxxxxxxxx>
Date: Wed, 9 Aug 2000 10:56:46 +0300

On Wed, Aug 09, 2000 at 09:38:49AM +0200, Per I. Mathisen wrote:
> Doing it this way is advantageous for client side AI and necessary
> for sound support (needs the extra information) and for proper and

Theoretically there would be no extrra information present, it would
just be encoded differently. 

As I see it, using a method based on natural english is not bad as per
se, it just needs to be "standardized" enough, so an AI or sound fx
machine can recognize the different events. This could be done
via say using pre-processor defined macros as templates
and messages.

For example instead of defining a new packet type
for "Player a conquered city London", you could use
the string MSG_PLAYER_CONQ_CITY("London"). The
receiving party would then have to iterate in a
loop something like below..

for(i=0;i<templates;i++) 
if ( sscanf(inputstring,templates[i],foobar1,foobar2,foobar3))
 {
  got match;
 }

the templates[i] array would then contain all the msgs
relevant to the AI.

As shown above the system is not as efficient as possible, it could
be shortened for example by finding a "proper subset" of templates[i]
from a hash of a prefix of the MSG_, or the event type, or
something else...

This keeps the flexibility, and allows new stuff to be added
which the AI and sound fx engine could safely ignore. Th

I feel that a better idea is simply define a structure on the messages
passed to notify_player(). This may not from certain view-points
look clean, but it feels like a very workable.

I hope my idea came out across properly?

> There are nearly 300 calls to the various notify_player routines. Many of
> these use a generic event type, which means I will have to make lots of 
> new event types to cover them all.

Exactly for this reason I felt I ought to post this idea. If you

> So, I could add new a new packet for each event type... this would
> probably triple the number of network packets in freeciv. It is a simple
> solution, but the packet code would become messy with so many packets.
> 
> I could encapsulate an "event packet" inside the chat packet, but then I
> would have to duplicate packet handling code to deal with the "event
> packet"... not a good solution.
> 
> Or, I could try to force all notify_player types to use only four ints as
> variables (no notify_player call uses more than four variables), making
> chat packets into something like
>       int E_EVENT, x, y, var1, var2, var3, var4
> but I do not know if all notify_player variables (most of which are
> strings today) can be expressed as integers, and it would probably be hell
> to rewrite them all.

I do not know how this aligns with what I propse.

Lauri

-- 
"The credit belongs to the man in the arena whose face is marred by dust and
sweat and blood, who strives valiantly, who errs, and who comes up short again
and again, who knows the great enthusiasms, the great devotions, and spends
himself in a worthy cause. The man who at best knows the triumph of high
achievement and who at worst, if he fails, fails while daring greatly, so that
his place will never be with those cold timid souls who never knew victory or
defeat." - Theodore Roosevelt



[Prev in Thread] Current Thread [Next in Thread]