ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/setup.ext
Revision: 1.5
Committed: Fri Aug 17 21:18:01 2007 UTC (16 years, 9 months ago) by root
Branch: MAIN
Changes since 1.4: +1 -1 lines
Log Message:
- optimise widget protocol a bit (incompatible change).
- implement well-known-widgets on server and client side,
  marginally test.
- add "title" parameter for infobox.

File Contents

# User Rev Content
1 root 1.1 #! perl # mandatory
2    
3     # the setup command
4    
5     use List::Util qw(min max);
6    
7     sub send_capabilities {
8     my ($ns) = @_;
9    
10     return unless $ns->extcmd;
11    
12 root 1.3 $ns->ext_msg (capabilities =>
13 root 1.1 # id, name, flags (1 == 2d), edge length
14     tileset => [[1, "default 64x64 faceset", 1, 64], [0, "default 32x32 faceset", 1, 32]],
15     );
16     }
17    
18     cf::client->attach (on_setup => sub {
19     my ($ns, $args) = @_;
20    
21     # run through the cmds of setup
22     # syntax is setup <cmdname1> <parameter> <cmdname2> <parameter> ...
23     #
24     # we send the status of the cmd back, or a FALSE is the cmd is the server unknown
25     # The client then must sort this out
26    
27     my %setup = split / +/, $args;
28     while (my ($k, $v) = each %setup) {
29     if ($k eq "sound") {
30     $ns->sound ($v);
31    
32     } elsif ($k eq "exp64") {
33     $setup{$k} = 1;
34    
35     } elsif ($k eq "spellmon") {
36     $ns->monitor_spells ($v);
37    
38     } elsif ($k eq "darkness") {
39     $ns->darkness ($v);
40    
41     } elsif ($k eq "map1cmd") {
42     $ns->mapmode (cf::Map1Cmd) if $v > 0;
43    
44     } elsif ($k eq "map1acmd") {
45     $ns->mapmode (cf::Map1aCmd) if $v > 0;
46    
47     } elsif ($k eq "map2cmd") {
48     # gcfclient bug, map1acmd is sent too late
49     $ns->mapmode (cf::Map1aCmd);
50     $setup{$k} = "FALSE";
51    
52     } elsif ($k eq "newmapcmd") {
53     $ns->newmapcmd ($v);
54    
55     } elsif ($k eq "mapinfocmd") {
56     $ns->mapinfocmd ($v);
57    
58     } elsif ($k eq "extcmd") {
59 root 1.3 $ns->extcmd (min 2, $v);
60 root 1.1 send_capabilities $ns;
61    
62     } elsif ($k eq "extmap") {
63     $ns->extmap ($v);
64    
65     } elsif ($k eq "facecache") {
66     if (!$v) {
67     $v = 1;
68     $setup{$k} = $v;
69     $ns->send_drawinfo ("(trying to forcefully enable facecaching)", cf::NDI_RED);
70     }
71    
72     $ns->facecache ($v);
73    
74     } elsif ($k eq "faceset") {
75     $ns->faceset (0);
76     $setup{$k} = 0;
77     # $ns->image2 (1)
78    
79     } elsif ($k eq "tileset") {
80     $setup{$k} = $ns->faceset ($v & 1);
81    
82     } elsif ($k eq "itemcmd") {
83     # Version of the item protocol command to use. Currently,
84     # only supported versions are 1 and 2. Using a numeric
85     # value will make it very easy to extend this in the future.
86     $ns->itemcmd ($v) if $v >= 1 && $v <= 2;
87    
88     $setup{$k} = $ns->itemcmd;
89    
90     } elsif ($k eq "mapsize") {
91     my ($x, $y) = split /x/, $v;
92    
93     $ns->mapx ($x = max 9, min cf::MAP_CLIENT_X, ($x - 1) | 1);
94     $ns->mapy ($y = max 9, min cf::MAP_CLIENT_Y, ($y - 1) | 1);
95    
96     $setup{$k} = "${x}x${y}";
97    
98     } elsif ($k eq "extendedMapInfos") {
99     $ns->ext_mapinfos ($v);
100    
101     } elsif ($k eq "extendedTextInfos") {
102     $ns->has_readable_type ($v);
103    
104     } elsif ($k eq "smoothing") { # cfplus-style smoothing
105     $ns->smoothing ($v);
106    
107     } elsif ($k eq "fxix") {
108 root 1.4 $ns->fxix ($setup{$k} = min 3, $v);
109 root 1.1
110     } elsif ($k eq "msg") {
111     $ns->can_msg ($setup{$k} = min 2, $v);
112    
113 root 1.5 } elsif ($k eq "xwidget1") {
114 root 1.1 # eXperimental server-side widgets
115     $ns->{can_widget} = 1;
116    
117     } elsif ($k eq "excmd") {
118     # we support it
119    
120     } else {
121     # other commands:
122     # sexp: no idea, probably for oudated servers
123     # tick: more stupidity, server should send a tick per tick
124    
125     $setup{$k} = "FALSE";
126     }
127     }
128    
129     $ns->send_packet (join " ", setup => %setup);
130    
131     cf::datalog setup =>
132     request => $args,
133     reply => \%setup,
134     client => $ns->version,
135     ;
136     });
137    
138