ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/socket/request.C
(Generate patch)

Comparing deliantra/server/socket/request.C (file contents):
Revision 1.34 by root, Thu Dec 14 01:59:10 2006 UTC vs.
Revision 1.35 by root, Thu Dec 14 02:37:37 2006 UTC

93 -1, /* life stealing */ 93 -1, /* life stealing */
94 -1 /* Disease - not fully done yet */ 94 -1 /* Disease - not fully done yet */
95}; 95};
96 96
97static void 97static void
98socket_map_scroll (NewSocket * ns, int dx, int dy) 98socket_map_scroll (client_socket * ns, int dx, int dy)
99{ 99{
100 struct Map newmap; 100 struct Map newmap;
101 int x, y, mx, my; 101 int x, y, mx, my;
102 102
103 { 103 {
153} 153}
154 154
155static void 155static void
156clear_map (player *pl) 156clear_map (player *pl)
157{ 157{
158 NewSocket & socket = pl->socket; 158 client_socket & socket = pl->socket;
159 159
160 memset (&socket.lastmap, 0, sizeof (socket.lastmap)); 160 memset (&socket.lastmap, 0, sizeof (socket.lastmap));
161 161
162 if (socket.newmapcmd == 1) 162 if (socket.newmapcmd == 1)
163 socket.send_packet ("newmap"); 163 socket.send_packet ("newmap");
168 168
169/** check for map change and send new map data */ 169/** check for map change and send new map data */
170static void 170static void
171check_map_change (player *pl) 171check_map_change (player *pl)
172{ 172{
173 NewSocket & socket = pl->socket; 173 client_socket & socket = pl->socket;
174 object *ob = pl->ob; 174 object *ob = pl->ob;
175 char buf[MAX_BUF]; /* eauugggh */ 175 char buf[MAX_BUF]; /* eauugggh */
176 176
177 if (socket.current_map != ob->map) 177 if (socket.current_map != ob->map)
178 { 178 {
316 pl->socket.send_packet (bigbuf); 316 pl->socket.send_packet (bigbuf);
317} 317}
318 318
319/** This is the Setup cmd - easy first implementation */ 319/** This is the Setup cmd - easy first implementation */
320void 320void
321SetUp (char *buf, int len, NewSocket * ns) 321SetUp (char *buf, int len, client_socket * ns)
322{ 322{
323 int s, slen; 323 int s, slen;
324 char *cmd, *param, cmdback[HUGE_BUF]; 324 char *cmd, *param, cmdback[HUGE_BUF];
325 325
326 /* run through the cmds of setup 326 /* run through the cmds of setup
536 * This is what takes care of it. We tell the client how things worked out. 536 * This is what takes care of it. We tell the client how things worked out.
537 * I am not sure if this file is the best place for this function. however, 537 * I am not sure if this file is the best place for this function. however,
538 * it either has to be here or init_sockets needs to be exported. 538 * it either has to be here or init_sockets needs to be exported.
539 */ 539 */
540void 540void
541AddMeCmd (char *buf, int len, NewSocket * ns) 541AddMeCmd (char *buf, int len, client_socket * ns)
542{ 542{
543 Settings oldsettings; 543 Settings oldsettings;
544 544
545 oldsettings = settings; 545 oldsettings = settings;
546 if (ns->status != Ns_Add || add_player (ns)) 546 if (ns->status != Ns_Add || add_player (ns))
560 settings = oldsettings; 560 settings = oldsettings;
561} 561}
562 562
563/** Reply to ExtendedInfos command */ 563/** Reply to ExtendedInfos command */
564void 564void
565ToggleExtendedInfos (char *buf, int len, NewSocket * ns) 565ToggleExtendedInfos (char *buf, int len, client_socket * ns)
566{ 566{
567 char cmdback[MAX_BUF]; 567 char cmdback[MAX_BUF];
568 char command[50]; 568 char command[50];
569 int info, nextinfo; 569 int info, nextinfo;
570 570
621#define MSG_TYPE_MONUMENT 5 621#define MSG_TYPE_MONUMENT 5
622#define MSG_TYPE_SCRIPTED_DIALOG 6*/ 622#define MSG_TYPE_SCRIPTED_DIALOG 6*/
623 623
624/** Reply to ExtendedInfos command */ 624/** Reply to ExtendedInfos command */
625void 625void
626ToggleExtendedText (char *buf, int len, NewSocket * ns) 626ToggleExtendedText (char *buf, int len, client_socket * ns)
627{ 627{
628 char cmdback[MAX_BUF]; 628 char cmdback[MAX_BUF];
629 char temp[10]; 629 char temp[10];
630 char command[50]; 630 char command[50];
631 int info, nextinfo, i, flag; 631 int info, nextinfo, i, flag;
682 * a piece of data from us that we know the client wants. So 682 * a piece of data from us that we know the client wants. So
683 * if we know the client wants it, might as well push it to the 683 * if we know the client wants it, might as well push it to the
684 * client. 684 * client.
685 */ 685 */
686static void 686static void
687SendSmooth (NewSocket * ns, uint16 face) 687SendSmooth (client_socket * ns, uint16 face)
688{ 688{
689 uint16 smoothface; 689 uint16 smoothface;
690 690
691 /* If we can't find a face, return and set it so we won't try to send this 691 /* If we can't find a face, return and set it so we won't try to send this
692 * again. 692 * again.
716 /** 716 /**
717 * Tells client the picture it has to use 717 * Tells client the picture it has to use
718 * to smooth a picture number given as argument. 718 * to smooth a picture number given as argument.
719 */ 719 */
720void 720void
721AskSmooth (char *buf, int len, NewSocket * ns) 721AskSmooth (char *buf, int len, client_socket * ns)
722{ 722{
723 uint16 facenbr; 723 uint16 facenbr;
724 724
725 facenbr = atoi (buf); 725 facenbr = atoi (buf);
726 SendSmooth (ns, facenbr); 726 SendSmooth (ns, facenbr);
918 * something older than the server. If we assume the client will be 918 * something older than the server. If we assume the client will be
919 * backwards compatible, having it be a later version should not be a 919 * backwards compatible, having it be a later version should not be a
920 * problem. 920 * problem.
921 */ 921 */
922void 922void
923VersionCmd (char *buf, int len, NewSocket * ns) 923VersionCmd (char *buf, int len, client_socket * ns)
924{ 924{
925 char *cp; 925 char *cp;
926 char version_warning[256]; 926 char version_warning[256];
927 927
928 if (!buf) 928 if (!buf)
976} 976}
977 977
978/** sound related functions. */ 978/** sound related functions. */
979 979
980void 980void
981SetSound (char *buf, int len, NewSocket * ns) 981SetSound (char *buf, int len, client_socket * ns)
982{ 982{
983 ns->sound = atoi (buf); 983 ns->sound = atoi (buf);
984} 984}
985 985
986/** client wants the map resent */ 986/** client wants the map resent */
1044/** 1044/**
1045 * Asks the client to query the user. This way, the client knows 1045 * Asks the client to query the user. This way, the client knows
1046 * it needs to send something back (vs just printing out a message) 1046 * it needs to send something back (vs just printing out a message)
1047 */ 1047 */
1048void 1048void
1049send_query (NewSocket * ns, uint8 flags, char *text) 1049send_query (client_socket * ns, uint8 flags, char *text)
1050{ 1050{
1051 char buf[MAX_BUF]; 1051 char buf[MAX_BUF];
1052 1052
1053 sprintf (buf, "query %d %s", flags, text ? text : ""); 1053 sprintf (buf, "query %d %s", flags, text ? text : "");
1054 ns->send_packet (buf); 1054 ns->send_packet (buf);
1213 * sent them the face yet (this can become quite costly in terms of 1213 * sent them the face yet (this can become quite costly in terms of
1214 * how much we are sending - on the other hand, this should only happen 1214 * how much we are sending - on the other hand, this should only happen
1215 * when the player logs in and picks stuff up. 1215 * when the player logs in and picks stuff up.
1216 */ 1216 */
1217void 1217void
1218esrv_send_animation (NewSocket * ns, short anim_num) 1218esrv_send_animation (client_socket * ns, short anim_num)
1219{ 1219{
1220 int i; 1220 int i;
1221 1221
1222 /* Do some checking on the anim_num we got. Note that the animations 1222 /* Do some checking on the anim_num we got. Note that the animations
1223 * are added in contigous order, so if the number is in the valid 1223 * are added in contigous order, so if the number is in the valid
1260/** 1260/**
1261 * This adds face_num to a map cell at x,y. If the client doesn't have 1261 * This adds face_num to a map cell at x,y. If the client doesn't have
1262 * the face yet, we will also send it. 1262 * the face yet, we will also send it.
1263 */ 1263 */
1264static void 1264static void
1265esrv_map_setbelow (NewSocket * ns, int x, int y, short face_num, struct Map *newmap) 1265esrv_map_setbelow (client_socket * ns, int x, int y, short face_num, struct Map *newmap)
1266{ 1266{
1267 if (newmap->cells[x][y].count >= MAP_LAYERS) 1267 if (newmap->cells[x][y].count >= MAP_LAYERS)
1268 { 1268 {
1269 LOG (llevError, "Too many faces in map cell %d %d\n", x, y); 1269 LOG (llevError, "Too many faces in map cell %d %d\n", x, y);
1270 return; 1270 return;
1290 struct LayerCell lcells[MAP_CLIENT_X * MAP_CLIENT_Y]; 1290 struct LayerCell lcells[MAP_CLIENT_X * MAP_CLIENT_Y];
1291}; 1291};
1292 1292
1293/** Checkes if map cells have changed */ 1293/** Checkes if map cells have changed */
1294static int 1294static int
1295mapcellchanged (NewSocket * ns, int i, int j, struct Map *newmap) 1295mapcellchanged (client_socket * ns, int i, int j, struct Map *newmap)
1296{ 1296{
1297 int k; 1297 int k;
1298 1298
1299 if (ns->lastmap.cells[i][j].count != newmap->cells[i][j].count) 1299 if (ns->lastmap.cells[i][j].count != newmap->cells[i][j].count)
1300 return 1; 1300 return 1;
1313 * cnum is the client number, cur is the the buffer we put all of 1313 * cnum is the client number, cur is the the buffer we put all of
1314 * this data into. we return the end of the data. layers is 1314 * this data into. we return the end of the data. layers is
1315 * how many layers of data we should back. 1315 * how many layers of data we should back.
1316 */ 1316 */
1317static uint8 * 1317static uint8 *
1318compactlayer (NewSocket * ns, unsigned char *cur, int numlayers, struct Map *newmap) 1318compactlayer (client_socket * ns, unsigned char *cur, int numlayers, struct Map *newmap)
1319{ 1319{
1320 int x, y, k; 1320 int x, y, k;
1321 int face; 1321 int face;
1322 unsigned char *fcur; 1322 unsigned char *fcur;
1323 struct MapLayer layers[MAP_LAYERS]; 1323 struct MapLayer layers[MAP_LAYERS];
1431 * needs to get sent - if so, it adds the data, sending the head 1431 * needs to get sent - if so, it adds the data, sending the head
1432 * if needed, and returning 1. If this no data needs to get 1432 * if needed, and returning 1. If this no data needs to get
1433 * sent, it returns zero. 1433 * sent, it returns zero.
1434 */ 1434 */
1435static int 1435static int
1436check_head (packet &sl, NewSocket &ns, int ax, int ay, int layer) 1436check_head (packet &sl, client_socket &ns, int ax, int ay, int layer)
1437{ 1437{
1438 short face_num; 1438 short face_num;
1439 1439
1440 if (heads[(ay * MAX_HEAD_POS + ax) * MAX_LAYERS + layer]) 1440 if (heads[(ay * MAX_HEAD_POS + ax) * MAX_LAYERS + layer])
1441 face_num = heads[(ay * MAX_HEAD_POS + ax) * MAX_LAYERS + layer]->face->number; 1441 face_num = heads[(ay * MAX_HEAD_POS + ax) * MAX_LAYERS + layer]->face->number;
1475 * the case, it seems to make more sense to have these layer values 1475 * the case, it seems to make more sense to have these layer values
1476 * actually match. 1476 * actually match.
1477 */ 1477 */
1478 1478
1479static int 1479static int
1480update_space (packet &sl, NewSocket &ns, maptile *mp, int mx, int my, int sx, int sy, int layer) 1480update_space (packet &sl, client_socket &ns, maptile *mp, int mx, int my, int sx, int sy, int layer)
1481{ 1481{
1482 object *ob, *head; 1482 object *ob, *head;
1483 uint16 face_num; 1483 uint16 face_num;
1484 int bx, by, i; 1484 int bx, by, i;
1485 1485
1698 * top layer (this matches what the GET_MAP_FACE and GET_MAP_FACE_OBJ 1698 * top layer (this matches what the GET_MAP_FACE and GET_MAP_FACE_OBJ
1699 * take. 1699 * take.
1700 */ 1700 */
1701 1701
1702static inline int 1702static inline int
1703update_smooth (packet &sl, NewSocket &ns, maptile *mp, int mx, int my, int sx, int sy, int layer) 1703update_smooth (packet &sl, client_socket &ns, maptile *mp, int mx, int my, int sx, int sy, int layer)
1704{ 1704{
1705 object *ob; 1705 object *ob;
1706 int smoothlevel; /* old face_num; */ 1706 int smoothlevel; /* old face_num; */
1707 1707
1708 ob = GET_MAP_FACE_OBJ (mp, mx, my, layer); 1708 ob = GET_MAP_FACE_OBJ (mp, mx, my, layer);
1742 * Returns the size of a data for a map square as returned by 1742 * Returns the size of a data for a map square as returned by
1743 * mapextended. There are CLIENTMAPX*CLIENTMAPY*LAYERS entries 1743 * mapextended. There are CLIENTMAPX*CLIENTMAPY*LAYERS entries
1744 * available. 1744 * available.
1745 */ 1745 */
1746int 1746int
1747getExtendedMapInfoSize (NewSocket * ns) 1747getExtendedMapInfoSize (client_socket * ns)
1748{ 1748{
1749 int result = 0; 1749 int result = 0;
1750 1750
1751 if (ns->ext_mapinfos) 1751 if (ns->ext_mapinfos)
1752 { 1752 {
1788 uint8 eentrysize; 1788 uint8 eentrysize;
1789 uint16 ewhatstart, ewhatflag; 1789 uint16 ewhatstart, ewhatflag;
1790 uint8 extendedinfos; 1790 uint8 extendedinfos;
1791 maptile *m; 1791 maptile *m;
1792 1792
1793 NewSocket &socket = pl->contr->socket; 1793 client_socket &socket = pl->contr->socket;
1794 1794
1795 check_map_change (pl->contr); 1795 check_map_change (pl->contr);
1796 1796
1797 packet sl; 1797 packet sl;
1798 packet esl; 1798 packet esl;
2241/** 2241/**
2242 * This sends the skill number to name mapping. We ignore 2242 * This sends the skill number to name mapping. We ignore
2243 * the params - we always send the same info no matter what. 2243 * the params - we always send the same info no matter what.
2244 */ 2244 */
2245void 2245void
2246send_skill_info (NewSocket *ns, char *params) 2246send_skill_info (client_socket *ns, char *params)
2247{ 2247{
2248 packet sl; 2248 packet sl;
2249 sl << "replyinfo skill_info\n"; 2249 sl << "replyinfo skill_info\n";
2250 2250
2251 for (int i = 1; i < NUM_SKILLS; i++) 2251 for (int i = 1; i < NUM_SKILLS; i++)
2263/** 2263/**
2264 * This sends the spell path to name mapping. We ignore 2264 * This sends the spell path to name mapping. We ignore
2265 * the params - we always send the same info no matter what. 2265 * the params - we always send the same info no matter what.
2266 */ 2266 */
2267void 2267void
2268send_spell_paths (NewSocket * ns, char *params) 2268send_spell_paths (client_socket * ns, char *params)
2269{ 2269{
2270 packet sl; 2270 packet sl;
2271 2271
2272 sl << "replyinfo spell_paths\n"; 2272 sl << "replyinfo spell_paths\n";
2273 2273

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines