[Freeciv-Dev] Re: notify_player rewrite
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
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
[Freeciv-Dev] Re: notify_player rewrite,
Lauri Tarkkala <=
- [Freeciv-Dev] Re: notify_player rewrite, Per I. Mathisen, 2000/08/09
- [Freeciv-Dev] Re: notify_player rewrite, Lauri Tarkkala, 2000/08/09
- [Freeciv-Dev] Re: notify_player rewrite, Per I. Mathisen, 2000/08/09
- [Freeciv-Dev] Re: notify_player rewrite, Jed Davis, 2000/08/09
- [Freeciv-Dev] Re: notify_player rewrite, Dmitriy Genzel, 2000/08/09
- [Freeciv-Dev] Re: notify_player rewrite, Reinier Post, 2000/08/10
[Freeciv-Dev] Re: notify_player rewrite, Reinier Post, 2000/08/10
|
|