1 /* 2 * Include file for socket I/O xtrek. 3 * 4 * Kevin P. Smith 1/29/89 5 */ 6 #include "copyright2.h" 7 8 #define STATUS_TOKEN "\t@@@" /* ATM */ 9 10 /* 11 * TCP and UDP use identical packet formats; the only difference is that, 12 * when in UDP mode, all packets sent from server to client have a sequence 13 * number appended to them. 14 * 15 * (note: ALL packets, whether sent on the TCP or UDP channel, will have 16 * the sequence number. Thus it's important that client & server agree on 17 * when to switch. This was done to keep critical and non-critical data 18 * in sync.) 19 */ 20 21 /* 22 general protocol state outline 23 24 starting state 25 26 CP_SOCKET 27 CP_FEATURE, optional, to indicate feature packets are known 28 SP_MOTD 29 SP_FEATURE, only if CP_FEATURE was seen 30 SP_QUEUE, optional, repeats until slot is available 31 SP_YOU, indicates slot number assigned 32 33 login state, player slot status is POUTFIT 34 client shows name and password prompt and accepts input 35 36 CP_LOGIN 37 CP_FEATURE 38 SP_LOGIN 39 SP_YOU 40 SP_PLAYER_INFO 41 various other server packets 42 43 outfit state, player slot status is POUTFIT 44 client shows team selection window 45 46 SP_MASK, sent regularly during outfit 47 48 client accepts team selection input 49 CP_OUTFIT 50 SP_PICKOK, signals server acceptance of alive state 51 52 alive state, 53 server places ship in game and play begins 54 55 SP_PSTATUS, indicates PDEAD state 56 client animates explosion 57 58 SP_PSTATUS, indicates POUTFIT state 59 clients returns to team selection window 60 61 CP_QUIT 62 CP_BYE 63 */ 64 65 /* When making an index of a recording, if we need to save this packet. */ 66 #define PB_CONTEXT(p) (\ 67 p == 60 || /* handleFeature */ \ 68 p == 14 || /* handleStatus */ \ 69 p == 24 || /* handlePlyrLogin */ \ 70 p == 2 || /* handlePlyrInfo */ \ 71 p == 20 || /* handlePStatus */ \ 72 p == 58 || /* handleVKills */ \ 73 p == 15 || /* handlePlanet */ \ 74 p == 26 || /* handlePlanetLoc */ \ 75 p == 59 || /* handle_s_Stats */ \ 76 p == 50 || /* handleVPlanet */ \ 77 p == 3) /* handleKills */ 78 79 #define RECORDPACKET(p) (\ 80 p==SP_MESSAGE ||\ 81 p==SP_PLAYER_INFO ||\ 82 p==SP_KILLS ||\ 83 p==SP_PLAYER ||\ 84 p==SP_YOU ||\ 85 p==SP_STATUS ||\ 86 p==SP_PLANET ||\ 87 p==SP_LOGIN ||\ 88 p==SP_FLAGS ||\ 89 p==SP_MASK ||\ 90 p==SP_PSTATUS ||\ 91 p==SP_BADVERSION ||\ 92 p==SP_HOSTILE ||\ 93 p==SP_STATS ||\ 94 p==SP_PL_LOGIN ||\ 95 p==SP_RESERVED ||\ 96 p==SP_PLANET_LOC) 97 98 /* packets sent from xtrek server to remote client */ 99 #define SP_MESSAGE 1 100 #define SP_PLAYER_INFO 2 /* general player info not * 101 * 102 * * elsewhere */ 103 #define SP_KILLS 3 /* # kills a player has */ 104 #define SP_PLAYER 4 /* x,y for player */ 105 #define SP_TORP_INFO 5 /* torp status */ 106 #define SP_TORP 6 /* torp location */ 107 #define SP_PHASER 7 /* phaser status and * * 108 * direction */ 109 #define SP_PLASMA_INFO 8 /* player login information */ 110 #define SP_PLASMA 9 /* like SP_TORP */ 111 #define SP_WARNING 10 /* like SP_MESG */ 112 #define SP_MOTD 11 /* line from .motd screen */ 113 #define SP_YOU 12 /* info on you? */ 114 #define SP_QUEUE 13 /* estimated loc in queue? */ 115 #define SP_STATUS 14 /* galaxy status numbers */ 116 #define SP_PLANET 15 /* planet armies & * * 117 * facilities */ 118 #define SP_PICKOK 16 /* your team & ship was * * 119 * accepted */ 120 #define SP_LOGIN 17 /* login response */ 121 #define SP_FLAGS 18 /* give flags for a player */ 122 #define SP_MASK 19 /* tournament mode mask */ 123 #define SP_PSTATUS 20 /* give status for a player */ 124 #define SP_BADVERSION 21 /* invalid version number */ 125 #define SP_HOSTILE 22 /* hostility settings for a 126 * * * player */ 127 #define SP_STATS 23 /* a player's statistics */ 128 #define SP_PL_LOGIN 24 /* new player logs in */ 129 #define SP_RESERVED 25 /* for future use */ 130 #define SP_PLANET_LOC 26 /* planet name, x, y */ 131 132 /* NOTE: not implemented */ 133 #define SP_SCAN 27 /* ATM: results of player * 134 * * scan */ 135 136 #define SP_UDP_REPLY 28 /* notify client of UDP * * 137 * status */ 138 #define SP_SEQUENCE 29 /* sequence # packet */ 139 #define SP_SC_SEQUENCE 30 /* this trans is * * 140 * semi-critical info */ 141 142 #ifdef RSA 143 #define SP_RSA_KEY 31 /* handles binary */ 144 #endif 145 146 #define SP_GENERIC_32 32 147 148 #define SP_SHIP_CAP 39 /* Handles server ship mods */ 149 150 #ifdef SHORT_PACKETS 151 #define SP_S_REPLY 40 /* reply to send-short * * 152 * request */ 153 #define SP_S_MESSAGE 41 /* var. Message Packet */ 154 #define SP_S_WARNING 42 /* Warnings with 4 Bytes */ 155 #define SP_S_YOU 43 /* hostile,armies,whydead,etc 156 * * * .. */ 157 #define SP_S_YOU_SS 44 /* your ship status */ 158 #define SP_S_PLAYER 45 /* variable length player * 159 * * packet */ 160 #endif 161 162 #ifdef PING 163 #define SP_PING 46 /* ping packet */ 164 #endif 165 166 #ifdef SHORT_PACKETS 167 #define SP_S_TORP 47 /* variable length torp * * 168 * packet */ 169 #define SP_S_TORP_INFO 48 /* SP_S_TORP with TorpInfo */ 170 #define SP_S_8_TORP 49 /* optimized SP_S_TORP */ 171 #define SP_S_PLANET 50 /* see SP_PLANET */ 172 173 /* S_P2 */ 174 #define SP_S_SEQUENCE 56 /* SP_SEQUENCE for * * 175 * compressed packets */ 176 #define SP_S_PHASER 57 /* see struct */ 177 #define SP_S_KILLS 58 /* # of kills player have */ 178 #define SP_S_STATS 59 /* see SP_STATS */ 179 180 #ifdef FEATURE_PACKETS 181 #define CP_FEATURE 60 182 #define SP_FEATURE 60 183 #endif 184 185 #define SP_RANK 61 186 #define SP_LTD 62 /* LTD stats for character */ 187 188 /* variable length packets */ 189 #define VPLAYER_SIZE 4 190 #define SHORTVERSION 11 /* other number blocks, like 191 * * * UDP Version */ 192 #define OLDSHORTVERSION 10 /* S_P2 */ 193 #endif 194 195 196 /* packets sent from remote client to xtrek server */ 197 #define CP_MESSAGE 1 /* send a message */ 198 #define CP_SPEED 2 /* set speed */ 199 #define CP_DIRECTION 3 /* change direction */ 200 #define CP_PHASER 4 /* phaser in a direction */ 201 #define CP_PLASMA 5 /* plasma (in a direction) */ 202 #define CP_TORP 6 /* fire torp in a direction */ 203 #define CP_QUIT 7 /* self destruct */ 204 #define CP_LOGIN 8 /* log in (name, password) */ 205 #define CP_OUTFIT 9 /* outfit to new ship */ 206 #define CP_WAR 10 /* change war status */ 207 #define CP_PRACTR 11 /* create practice robot? */ 208 #define CP_SHIELD 12 /* raise/lower sheilds */ 209 #define CP_REPAIR 13 /* enter repair mode */ 210 #define CP_ORBIT 14 /* orbit planet/starbase */ 211 #define CP_PLANLOCK 15 /* lock on planet */ 212 #define CP_PLAYLOCK 16 /* lock on player */ 213 #define CP_BOMB 17 /* bomb a planet */ 214 #define CP_BEAM 18 /* beam armies up/down */ 215 #define CP_CLOAK 19 /* cloak on/off */ 216 #define CP_DET_TORPS 20 /* detonate enemy torps */ 217 #define CP_DET_MYTORP 21 /* detonate one of my torps */ 218 #define CP_COPILOT 22 /* toggle copilot mode */ 219 #define CP_REFIT 23 /* refit to different ship * 220 * 221 * * type */ 222 #define CP_TRACTOR 24 /* tractor on/off */ 223 #define CP_REPRESS 25 /* pressor on/off */ 224 #define CP_COUP 26 /* coup home planet */ 225 #define CP_SOCKET 27 /* new socket for * * 226 * reconnection */ 227 #define CP_OPTIONS 28 /* send my options to be * * 228 * saved */ 229 #define CP_BYE 29 /* I'm done! */ 230 #define CP_DOCKPERM 30 /* set docking permissions */ 231 #define CP_UPDATES 31 /* set number of usecs per * 232 * 233 * * update */ 234 #define CP_RESETSTATS 32 /* reset my stats packet */ 235 #define CP_RESERVED 33 /* for future use */ 236 237 /* NOTE: not implemented. */ 238 #define CP_SCAN 34 /* ATM: request for player * 239 * 240 * * scan */ 241 242 #define CP_UDP_REQ 35 /* request UDP on/off */ 243 #define CP_SEQUENCE 36 /* sequence # packet */ 244 245 #ifdef RSA 246 #define CP_RSA_KEY 37 /* handles binary * * 247 * verification */ 248 #endif 249 250 #define CP_PING_RESPONSE 42 /* client response */ 251 252 #ifdef SHORT_PACKETS 253 #define CP_S_REQ 43 254 #define CP_S_THRS 44 255 #define CP_S_MESSAGE 45 /* vari. Message Packet */ 256 #define CP_S_RESERVED 46 257 #define CP_S_DUMMY 47 258 #endif 259 260 #define SOCKVERSION 4 261 262 #define UDPVERSION 10 263 264 struct packet_handler 265 { 266 int size; 267 void (*handler) (); 268 }; 269 270 struct mesg_spacket 271 { 272 char type; /* SP_MESSAGE */ 273 unsigned char m_flags; 274 unsigned char m_recpt; 275 unsigned char m_from; 276 char mesg[80]; 277 }; 278 279 struct plyr_info_spacket 280 { 281 char type; /* SP_PLAYER_INFO */ 282 char pnum; 283 char shiptype; 284 char team; 285 }; 286 287 struct plyr_login_spacket 288 { 289 char type; /* SP_PL_LOGIN */ 290 char pnum; 291 char rank; 292 char pad1; 293 char name[16]; 294 char monitor[16]; 295 char login[16]; 296 }; 297 298 struct hostile_spacket 299 { 300 char type; /* SP_HOSTILE */ 301 char pnum; 302 char war; 303 char hostile; 304 }; 305 306 struct stats_spacket 307 { 308 char type; /* SP_STATS */ 309 char pnum; 310 char pad1; 311 char pad2; 312 LONG tkills; /* Tournament kills */ 313 LONG tlosses; /* Tournament losses */ 314 LONG kills; /* overall */ 315 LONG losses; /* overall */ 316 LONG tticks; /* ticks of tournament play 317 * * * time */ 318 LONG tplanets; /* Tournament planets */ 319 LONG tarmies; /* Tournament armies */ 320 LONG sbkills; /* Starbase kills */ 321 LONG sblosses; /* Starbase losses */ 322 LONG armies; /* non-tourn armies */ 323 LONG planets; /* non-tourn planets */ 324 LONG maxkills; /* max kills as player * 100 325 * 326 */ 327 LONG sbmaxkills; /* max kills as sb * 100 */ 328 }; 329 330 struct flags_spacket 331 { 332 char type; /* SP_FLAGS */ 333 char pnum; /* whose flags are they? */ 334 char tractor; 335 char pad2; 336 unsigned flags; 337 }; 338 339 struct kills_spacket 340 { 341 char type; /* SP_KILLS */ 342 char pnum; 343 char pad1; 344 char pad2; 345 unsigned kills; /* where 1234=12.34 kills * 346 * * and 0=0.00 kills */ 347 }; 348 349 struct player_spacket 350 { 351 char type; /* SP_PLAYER */ 352 char pnum; 353 unsigned char dir; 354 char speed; 355 LONG x, y; 356 }; 357 358 struct torp_info_spacket 359 { 360 char type; /* SP_TORP_INFO */ 361 char war; 362 char status; /* TFREE, TDET, etc... */ 363 char pad1; /* pad needed for cross cpu 364 * * * compatibility */ 365 unsigned short tnum; 366 unsigned short pad2; 367 }; 368 369 struct torp_spacket 370 { 371 char type; /* SP_TORP */ 372 unsigned char dir; 373 unsigned short tnum; 374 LONG x, y; 375 }; 376 377 struct phaser_spacket 378 { 379 char type; /* SP_PHASER */ 380 char pnum; 381 char status; /* PH_HIT, etc... */ 382 unsigned char dir; 383 LONG x, y; 384 LONG target; 385 }; 386 387 struct you_spacket 388 { 389 char type; /* SP_YOU */ 390 char pnum; /* Guy needs to know this... 391 * 392 */ 393 char hostile; 394 char swar; 395 char armies; 396 char tractor; 397 char pad2; 398 char pad3; 399 unsigned flags; 400 LONG damage; 401 LONG shield; 402 LONG fuel; 403 unsigned short etemp; 404 unsigned short wtemp; 405 unsigned short whydead; 406 unsigned short whodead; 407 }; 408 409 struct status_spacket 410 { 411 char type; /* SP_STATUS */ 412 char tourn; 413 char pad1; 414 char pad2; 415 unsigned armsbomb; 416 unsigned planets; 417 unsigned kills; 418 unsigned losses; 419 unsigned time; 420 unsigned LONG timeprod; 421 }; 422 423 struct warning_spacket 424 { 425 char type; /* SP_WARNING */ 426 char pad1; 427 char pad2; 428 char pad3; 429 char mesg[80]; 430 }; 431 432 struct planet_spacket 433 { 434 char type; /* SP_PLANET */ 435 char pnum; 436 char owner; 437 char info; 438 unsigned short flags; 439 unsigned short pad2; 440 LONG armies; 441 }; 442 443 struct torp_cpacket 444 { 445 char type; /* CP_TORP */ 446 unsigned char dir; /* direction to fire torp */ 447 char pad1; 448 char pad2; 449 }; 450 451 struct phaser_cpacket 452 { 453 char type; /* CP_PHASER */ 454 unsigned char dir; 455 char pad1; 456 char pad2; 457 }; 458 459 struct speed_cpacket 460 { 461 char type; /* CP_SPEED */ 462 char speed; 463 char pad1; 464 char pad2; 465 }; 466 467 struct dir_cpacket 468 { 469 char type; /* CP_DIRECTION */ 470 unsigned char dir; 471 char pad1; 472 char pad2; 473 }; 474 475 struct shield_cpacket 476 { 477 char type; /* CP_SHIELD */ 478 char state; /* up/down */ 479 char pad1; 480 char pad2; 481 }; 482 483 struct repair_cpacket 484 { 485 char type; /* CP_REPAIR */ 486 char state; /* on/off */ 487 char pad1; 488 char pad2; 489 }; 490 491 struct orbit_cpacket 492 { 493 char type; /* CP_ORBIT */ 494 char state; /* on/off */ 495 char pad1; 496 char pad2; 497 }; 498 499 struct practr_cpacket 500 { 501 char type; /* CP_PRACTR */ 502 char pad1; 503 char pad2; 504 char pad3; 505 }; 506 507 struct bomb_cpacket 508 { 509 char type; /* CP_BOMB */ 510 char state; 511 char pad1; 512 char pad2; 513 }; 514 515 struct beam_cpacket 516 { 517 char type; /* CP_BEAM */ 518 char state; 519 char pad1; 520 char pad2; 521 }; 522 523 struct cloak_cpacket 524 { 525 char type; /* CP_CLOAK */ 526 char state; 527 char pad1; 528 char pad2; 529 }; 530 531 struct det_torps_cpacket 532 { 533 char type; /* CP_DET_TORPS */ 534 char pad1; 535 char pad2; 536 char pad3; 537 }; 538 539 struct copilot_cpacket 540 { 541 char type; /* CP_COPLIOT */ 542 char state; 543 char pad1; 544 char pad2; 545 }; 546 547 struct queue_spacket 548 { 549 char type; /* SP_QUEUE */ 550 char pad1; 551 unsigned short pos; 552 }; 553 554 struct outfit_cpacket 555 { 556 char type; /* CP_OUTFIT */ 557 char team; 558 char ship; 559 char pad1; 560 }; 561 562 struct pickok_spacket 563 { 564 char type; /* SP_PICKOK */ 565 char state; 566 char pad2; 567 char pad3; 568 }; 569 570 struct login_cpacket 571 { 572 char type; /* CP_LOGIN */ 573 char query; 574 char pad2; 575 char pad3; 576 char name[16]; 577 char password[16]; 578 char login[16]; 579 }; 580 581 struct login_spacket 582 { 583 char type; /* SP_LOGIN */ 584 char accept; /* 1/0 */ 585 char pad2; 586 char pad3; 587 LONG flags; 588 char keymap[96]; 589 }; 590 591 struct tractor_cpacket 592 { 593 char type; /* CP_TRACTOR */ 594 char state; 595 char pnum; 596 char pad2; 597 }; 598 599 struct repress_cpacket 600 { 601 char type; /* CP_REPRESS */ 602 char state; 603 char pnum; 604 char pad2; 605 }; 606 607 struct det_mytorp_cpacket 608 { 609 char type; /* CP_DET_MYTORP */ 610 char pad1; 611 unsigned short tnum; 612 }; 613 614 struct war_cpacket 615 { 616 char type; /* CP_WAR */ 617 char newmask; 618 char pad1; 619 char pad2; 620 }; 621 622 struct refit_cpacket 623 { 624 char type; /* CP_REFIT */ 625 char ship; 626 char pad1; 627 char pad2; 628 }; 629 630 struct plasma_cpacket 631 { 632 char type; /* CP_PLASMA */ 633 unsigned char dir; 634 char pad1; 635 char pad2; 636 }; 637 638 struct plasma_info_spacket 639 { 640 char type; /* SP_PLASMA_INFO */ 641 char war; 642 char status; /* TFREE, TDET, etc... */ 643 char pad1; /* pad needed for cross cpu 644 * * * compatibility */ 645 unsigned short pnum; 646 unsigned short pad2; 647 }; 648 649 struct plasma_spacket 650 { 651 char type; /* SP_PLASMA */ 652 char pad1; 653 unsigned short pnum; 654 LONG x, y; 655 }; 656 657 struct playlock_cpacket 658 { 659 char type; /* CP_PLAYLOCK */ 660 char pnum; 661 char pad1; 662 char pad2; 663 }; 664 665 struct planlock_cpacket 666 { 667 char type; /* CP_PLANLOCK */ 668 char pnum; 669 char pad1; 670 char pad2; 671 }; 672 673 struct coup_cpacket 674 { 675 char type; /* CP_COUP */ 676 char pad1; 677 char pad2; 678 char pad3; 679 }; 680 681 struct pstatus_spacket 682 { 683 char type; /* SP_PSTATUS */ 684 char pnum; 685 char status; 686 char pad1; 687 }; 688 689 struct motd_spacket 690 { 691 char type; /* SP_MOTD */ 692 char pad1; 693 char pad2; 694 char pad3; 695 char line[80]; 696 }; 697 698 struct quit_cpacket 699 { 700 char type; /* CP_QUIT */ 701 char pad1; 702 char pad2; 703 char pad3; 704 }; 705 706 struct mesg_cpacket 707 { 708 char type; /* CP_MESSAGE */ 709 char group; 710 char indiv; 711 char pad1; 712 char mesg[80]; 713 }; 714 715 struct mask_spacket 716 { 717 char type; /* SP_MASK */ 718 char mask; 719 char pad1; 720 char pad2; 721 }; 722 723 struct socket_cpacket 724 { 725 char type; /* CP_SOCKET */ 726 char version; 727 char udp_version; /* was pad2 */ 728 char pad3; 729 unsigned socket; 730 }; 731 732 struct options_cpacket 733 { 734 char type; /* CP_OPTIONS */ 735 char pad1; 736 char pad2; 737 char pad3; 738 unsigned flags; 739 char keymap[96]; 740 }; 741 742 struct bye_cpacket 743 { 744 char type; /* CP_BYE */ 745 char pad1; 746 char pad2; 747 char pad3; 748 }; 749 750 struct badversion_spacket 751 { 752 char type; /* SP_BADVERSION */ 753 char why; 754 char pad2; 755 char pad3; 756 }; 757 758 struct dockperm_cpacket 759 { 760 char type; /* CP_DOCKPERM */ 761 char state; 762 char pad2; 763 char pad3; 764 }; 765 766 struct updates_cpacket 767 { 768 char type; /* CP_UPDATES */ 769 char pad1; 770 char pad2; 771 char pad3; 772 unsigned usecs; 773 }; 774 775 struct resetstats_cpacket 776 { 777 char type; /* CP_RESETSTATS */ 778 char verify; /* 'Y' - just to make sure * 779 * 780 * * he meant it */ 781 char pad2; 782 char pad3; 783 }; 784 785 struct reserved_spacket 786 { 787 char type; /* SP_RESERVED */ 788 char pad1; 789 char pad2; 790 char pad3; 791 char data[16]; 792 }; 793 794 struct reserved_cpacket 795 { 796 char type; /* CP_RESERVED */ 797 char pad1; 798 char pad2; 799 char pad3; 800 char data[16]; 801 char resp[16]; 802 }; 803 804 struct udp_req_cpacket 805 { /* UDP */ 806 char type; /* CP_UDP_REQ */ 807 char request; 808 char connmode; /* respond with port # or * 809 * * just send UDP packet? */ 810 char pad2; 811 int port; /* compensate for hosed * * 812 * recvfrom() */ 813 }; 814 struct ping_cpacket 815 { 816 char type; /* CP_PING_RESPONSE */ 817 unsigned char number; /* id */ 818 char pingme; /* if client wants server to 819 * * * ping */ 820 char pad1; 821 822 LONG cp_sent; /* # packets sent to server */ 823 LONG cp_recv; /* # packets recv from * * 824 * server */ 825 }; 826 struct ping_spacket 827 { 828 char type; /* SP_PING */ 829 unsigned char number; /* id (ok to wrap) */ 830 unsigned short lag; /* delay of last ping in ms */ 831 832 unsigned char tloss_sc; /* total loss server-client 833 * * * 0-100% */ 834 unsigned char tloss_cs; /* total loss client-server 835 * * * 0-100% */ 836 837 unsigned char iloss_sc; /* inc. loss server-client * 838 * 839 * * 0-100% */ 840 unsigned char iloss_cs; /* inc. loss client-server * 841 * 842 * * 0-100% */ 843 }; 844 struct sequence_cpacket 845 { /* UDP */ 846 char type; /* CP_SEQUENCE */ 847 char pad1; 848 unsigned short sequence; 849 }; 850 851 852 struct sc_sequence_spacket 853 { /* UDP */ 854 char type; /* SP_CP_SEQUENCE */ 855 char pad1; 856 unsigned short sequence; 857 }; 858 859 struct udp_reply_spacket 860 { /* UDP */ 861 char type; /* SP_UDP_REPLY */ 862 char reply; 863 char pad1; 864 char pad2; 865 int port; 866 }; 867 868 struct sequence_spacket 869 { /* UDP */ 870 char type; /* SP_SEQUENCE */ 871 unsigned char flag16; 872 unsigned short sequence; 873 }; 874 875 876 struct planet_loc_spacket 877 { 878 char type; /* SP_PLANET_LOC */ 879 char pnum; 880 char pad2; 881 char pad3; 882 LONG x; 883 LONG y; 884 char name[16]; 885 }; 886 887 #ifdef FEATURE_PACKETS 888 struct feature_cpacket 889 { 890 char type; 891 char feature_type; 892 char arg1, arg2; 893 int value; 894 char name[80]; 895 }; 896 897 #endif 898 899 struct rank_spacket { /* SP_RANK py-struct pending #61 */ 900 char type; 901 char rnum; /* rank number */ 902 char rmax; /* rank number maximum */ 903 char pad; 904 char name[NAME_LEN]; /* full rank name */ 905 int hours; /* hundredths of hours required */ 906 int ratings; /* hundredths of ratings required */ 907 int offense; /* hundredths of offense required */ 908 char cname[8]; /* short 'curt' rank name */ 909 }; 910 911 #define LTD_VERSION 'a' /* version for SP_LTD packet */ 912 913 struct ltd_spacket { /* SP_LTD py-struct pending #62 */ 914 char type; 915 char version; 916 char pad[2]; 917 unsigned int kt; /* kills total, kills.total */ 918 unsigned int kmax; /* kills max, kills.max */ 919 unsigned int k1; /* kills first, kills.first */ 920 unsigned int k1p; /* kills first potential, kills.first_potential */ 921 unsigned int k1c; /* kills first converted, kills.first_converted */ 922 unsigned int k2; /* kills second, kills.second */ 923 unsigned int k2p; /* kills second potential, kills.second_potential */ 924 unsigned int k2c; /* kills second converted, kills.second_converted */ 925 unsigned int kbp; /* kills by phaser, kills.phasered */ 926 unsigned int kbt; /* kills by torp, kills.torped */ 927 unsigned int kbs; /* kills by smack, kills.plasmaed */ 928 unsigned int dt; /* deaths total, deaths.total */ 929 unsigned int dpc; /* deaths as potential carrier, deaths.potential */ 930 unsigned int dcc; /* deaths as converted carrier, deaths.converted */ 931 unsigned int ddc; /* deaths as dooshed carrier, deaths.dooshed */ 932 unsigned int dbp; /* deaths by phaser, deaths.phasered */ 933 unsigned int dbt; /* deaths by torp, deaths.torped */ 934 unsigned int dbs; /* deaths by smack, deaths.plasmaed */ 935 unsigned int acc; /* actual carriers created, deaths.acc */ 936 unsigned int ptt; /* planets taken total, planets.taken */ 937 unsigned int pdt; /* planets destroyed total, planets.destroyed */ 938 unsigned int bpt; /* bombed planets total, bomb.planets */ 939 unsigned int bp8; /* bombed planets <=8, bomb.planets_8 */ 940 unsigned int bpc; /* bombed planets core, bomb.planets_core */ 941 unsigned int bat; /* bombed armies total, bomb.armies */ 942 unsigned int ba8; /* bombed_armies <= 8, bomb.armies_8 */ 943 unsigned int bac; /* bombed armies core, bomb.armies_core */ 944 unsigned int oat; /* ogged armies total, ogged.armies */ 945 unsigned int odc; /* ogged dooshed carrier, ogged.dooshed */ 946 unsigned int occ; /* ogged converted carrier, ogged.converted */ 947 unsigned int opc; /* ogged potential carrier, ogged.potential */ 948 unsigned int ogc; /* ogged bigger carrier, ogged.bigger_ship */ 949 unsigned int oec; /* ogged same carrier, ogged.same_ship */ 950 unsigned int olc; /* ogger smaller carrier, ogged.smaller_ship */ 951 unsigned int osba; /* ogged sb armies, ogged.sb_armies */ 952 unsigned int ofc; /* ogged friendly carrier, ogged.friendly */ 953 unsigned int ofa; /* ogged friendly armies, ogged.friendly_armies */ 954 unsigned int at; /* armies carried total, armies.total */ 955 unsigned int aa; /* armies used to attack, armies.attack */ 956 unsigned int ar; /* armies used to reinforce, armies.reinforce */ 957 unsigned int af; /* armies ferried, armies.ferries */ 958 unsigned int ak; /* armies killed, armies.killed */ 959 unsigned int ct; /* carries total, carries.total */ 960 unsigned int cp; /* carries partial, carries.partial */ 961 unsigned int cc; /* carries completed, carries.completed */ 962 unsigned int ca; /* carries to attack, carries.attack */ 963 unsigned int cr; /* carries to reinforce, carries.reinforce */ 964 unsigned int cf; /* carries to ferry, carries.ferries */ 965 unsigned int tt; /* ticks total, ticks.total */ 966 unsigned int tyel; /* ticks in yellow, ticks.yellow */ 967 unsigned int tred; /* ticks in red, ticks.red */ 968 unsigned int tz0; /* ticks in zone 0, ticks.zone[0] */ 969 unsigned int tz1; /* ticks in zone 1, ticks.zone[1] */ 970 unsigned int tz2; /* ticks in zone 2, ticks.zone[2] */ 971 unsigned int tz3; /* ticks in zone 3, ticks.zone[3] */ 972 unsigned int tz4; /* ticks in zone 4, ticks.zone[4] */ 973 unsigned int tz5; /* ticks in zone 5, ticks.zone[5] */ 974 unsigned int tz6; /* ticks in zone 6, ticks.zone[6] */ 975 unsigned int tz7; /* ticks in zone 7, ticks.zone[7] */ 976 unsigned int tpc; /* ticks as potential carrier, ticks.potential */ 977 unsigned int tcc; /* ticks as carrier++, ticks.carrier */ 978 unsigned int tr; /* ticks in repair, ticks.repair */ 979 unsigned int dr; /* damage repaired, damage_repaired */ 980 unsigned int wpf; /* weap phaser fired, weapons.phaser.fired */ 981 unsigned int wph; /* weap phaser hit, weapons.phaser.hit */ 982 unsigned int wpdi; /* weap phaser damage inflicted, weapons.phaser.damage.inflicted */ 983 unsigned int wpdt; /* weap phaser damage taken, weapons.phaser.damage.taken */ 984 unsigned int wtf; /* weap torp fired, weapons.torps.fired */ 985 unsigned int wth; /* weap torp hit, weapons.torps.hit */ 986 unsigned int wtd; /* weap torp detted, weapons.torps.detted */ 987 unsigned int wts; /* weap torp self detted, weapons.torps.selfdetted */ 988 unsigned int wtw; /* weap torp hit wall, weapons.torps.wall */ 989 unsigned int wtdi; /* weap torp damage inflicted, weapons.torps.damage.inflicted */ 990 unsigned int wtdt; /* weap torp damage taken, weapons.torps.damage.taken */ 991 unsigned int wsf; /* weap smack fired, weapons.plasma.fired */ 992 unsigned int wsh; /* weap smack hit, weapons.plasma.hit */ 993 unsigned int wsp; /* weap smack phasered, weapons.plasma.phasered */ 994 unsigned int wsw; /* weap smack hit wall, weapons.plasma.wall */ 995 unsigned int wsdi; /* weap smack damage inflicted, weapons.plasma.damage.inflicted */ 996 unsigned int wsdt; /* weap smack damage taken, weapons.plasma.damage.taken */ 997 } __attribute__ ((packed)); 998 999 #ifdef RSA 1000 struct rsa_key_spacket 1001 { 1002 char type; /* SP_RSA_KEY */ 1003 char pad1; 1004 char pad2; 1005 char pad3; 1006 unsigned char data[KEY_SIZE]; 1007 }; 1008 1009 struct rsa_key_cpacket 1010 { 1011 char type; /* CP_RSA_KEY */ 1012 char pad1; 1013 char pad2; 1014 char pad3; 1015 unsigned char global[KEY_SIZE]; 1016 unsigned char public[KEY_SIZE]; 1017 unsigned char resp[KEY_SIZE]; 1018 }; 1019 1020 #endif 1021 1022 struct ship_cap_spacket 1023 { /* Server configuration of * 1024 * 1025 * * client */ 1026 char type; /* screw motd method */ 1027 char operation; /* 0 = add/change a ship, 1 1028 * * * = remove a ship */ 1029 unsigned short s_type; /* SP_SHIP_CAP */ 1030 unsigned short s_torpspeed; 1031 unsigned short s_phaserrange; 1032 int s_maxspeed; 1033 int s_maxfuel; 1034 int s_maxshield; 1035 int s_maxdamage; 1036 int s_maxwpntemp; 1037 int s_maxegntemp; 1038 unsigned short s_width; 1039 unsigned short s_height; 1040 unsigned short s_maxarmies; 1041 char s_letter; 1042 char pad2; 1043 char s_name[16]; 1044 char s_desig1; 1045 char s_desig2; 1046 unsigned short s_bitmap; 1047 }; 1048 1049 #ifdef SHORT_PACKETS 1050 struct shortreq_cpacket 1051 { /* CP_S_REQ */ 1052 char type; 1053 char req; 1054 char version; 1055 char pad2; 1056 }; 1057 1058 struct threshold_cpacket 1059 { /* CP_S_THRS */ 1060 char type; 1061 char pad1; 1062 unsigned short thresh; 1063 }; 1064 1065 struct shortreply_spacket 1066 { /* SP_S_REPLY */ 1067 char type; 1068 char repl; 1069 unsigned short winside; 1070 LONG gwidth; 1071 }; 1072 1073 struct youshort_spacket 1074 { /* SP_S_YOU */ 1075 char type; 1076 1077 char pnum; 1078 char hostile; 1079 char swar; 1080 1081 char armies; 1082 char whydead; 1083 char whodead; 1084 1085 char pad1; 1086 1087 unsigned flags; 1088 }; 1089 1090 struct youss_spacket 1091 { /* SP_S_YOU_SS */ 1092 char type; 1093 char pad1; 1094 1095 unsigned short damage; 1096 unsigned short shield; 1097 unsigned short fuel; 1098 unsigned short etemp; 1099 unsigned short wtemp; 1100 }; 1101 1102 #define VPLANET_SIZE 6 1103 1104 struct planet_s_spacket 1105 { /* body of SP_S_PLANET */ 1106 char pnum; 1107 char owner; 1108 char info; 1109 unsigned char armies; /* more than 255 Armies ? * 1110 * * ... */ 1111 unsigned short flags; 1112 }; 1113 struct warning_s_spacket 1114 { /* SP_S_WARNING */ 1115 char type; 1116 unsigned char whichmessage; 1117 char argument, argument2; /* for phaser etc ... */ 1118 }; 1119 1120 struct player_s_spacket 1121 { 1122 char type; /* SP_S_PLAYER Header */ 1123 char packets; /* How many player-packets * 1124 * 1125 * * are in this packet ( 1126 * only * * the first 6 bits 1127 * are * * relevant ) */ 1128 unsigned char dir; 1129 char speed; 1130 LONG x, y; /* To get the absolute * * 1131 * Position */ 1132 }; 1133 1134 /* S_P2 */ 1135 struct player_s2_spacket 1136 { 1137 char type; /* SP_S_PLAYER Header */ 1138 char packets; /* How many player-packets * 1139 * 1140 * * are in this packet ( * 1141 * * only the firs t 6 bits * 1142 * * are relevant ) */ 1143 unsigned char dir; 1144 char speed; 1145 short x, y; /* absolute position / 40 */ 1146 unsigned int flags; /* 16 playerflags */ 1147 }; 1148 1149 /* The format of the body: struct player_s_body_spacket { Body of new 1150 * Player Packet unsigned char pnum; 0-4 = pnum, 5 local or galactic, 6 = 1151 * 9. x-bit, 7 9. y-bit unsigned char speeddir; 0-3 = speed , 4-7 1152 * direction of ship unsigned char x; low 8 bits from X-Pixelcoordinate 1153 * unsigned char y; low 8 bits from Y-Pixelcoordinate }; */ 1154 1155 struct torp_s_spacket 1156 { 1157 char type; /* SP_S_TORP */ 1158 unsigned char bitset; /* bit=1 that torp is in * * 1159 * packet */ 1160 unsigned char whichtorps; /* Torpnumber of first torp 1161 * * * / 8 */ 1162 unsigned char data[21]; /* For every torp 2*9 bit * 1163 * * coordinates */ 1164 }; 1165 1166 struct mesg_s_spacket 1167 { 1168 char type; /* SP_S_MESSAGE */ 1169 unsigned char m_flags; 1170 unsigned char m_recpt; 1171 unsigned char m_from; 1172 unsigned char length; /* Length of whole packet */ 1173 char mesg; 1174 char pad2; 1175 char pad3; 1176 char pad[76]; 1177 }; 1178 1179 struct mesg_s_cpacket 1180 { 1181 char type; /* CP_S__MESSAGE */ 1182 char group; 1183 char indiv; 1184 char length; /* Size of whole packet */ 1185 char mesg[80]; 1186 }; 1187 1188 /* S_P2 */ 1189 struct kills_s_spacket 1190 { 1191 char type; /* SP_S_KILLS */ 1192 char pnum; /* How many kills in packet */ 1193 unsigned short kills; /* 6 bit player numer */ 1194 /* 10 bit kills*100 */ 1195 unsigned short mkills[MAXPLAYER]; 1196 }; 1197 1198 struct phaser_s_spacket 1199 { 1200 char type; /* SP_S_PHASER */ 1201 char status; /* PH_HIT, etc... */ 1202 unsigned char pnum; /* both bytes are used for * 1203 * 1204 * * more */ 1205 unsigned char target; /* look into the code */ 1206 short x; /* x coord /40 */ 1207 short y; /* y coord /40 */ 1208 unsigned char dir; 1209 char pad1; 1210 char pad2; 1211 char pad3; 1212 }; 1213 1214 struct stats_s_spacket 1215 { 1216 char type; /* SP_S_STATS */ 1217 char pnum; 1218 unsigned short tplanets; /* Tournament planets */ 1219 unsigned short tkills; /* Tournament kills */ 1220 unsigned short tlosses; /* Tournament losses */ 1221 unsigned short kills; /* overall */ 1222 unsigned short losses; /* overall */ 1223 unsigned int tticks; /* ticks of tournament play 1224 * * * time */ 1225 unsigned int tarmies; /* Tournament armies */ 1226 unsigned int maxkills; 1227 unsigned short sbkills; /* Starbase kills */ 1228 unsigned short sblosses; /* Starbase losses */ 1229 unsigned short armies; /* non-tourn armies */ 1230 unsigned short planets; /* non-tourn planets */ 1231 unsigned int sbmaxkills; /* max kills as sb * 100 */ 1232 }; 1233 1234 #endif 1235 1236 struct generic_32_spacket { 1237 char type; 1238 char version; /* alphabetic, 0x60 + version */ 1239 char pad[30]; 1240 }; 1241 #define GENERIC_32_LENGTH 32 1242 #define COST_GENERIC_32 (F_sp_generic_32 ? GENERIC_32_LENGTH : 0) 1243 struct generic_32_spacket_a { /* SP_GENERIC_32 py-struct "b1sHH26x" #32 */ 1244 char type; 1245 char version; /* alphabetic, 0x60 + version */ 1246 unsigned short repair_time; /* server estimate of repair time in seconds */ 1247 unsigned short pl_orbit; /* what planet player orbiting, -1 if none */ 1248 char pad1[26]; 1249 /* NOTE: this version didn't use network byte order for the shorts */ 1250 }; 1251 #define GENERIC_32_VERSION_A 1 1252 struct generic_32_spacket_b { /* SP_GENERIC_32 py-struct "!b1sHbHBBsBsBB18x" #32 */ 1253 char type; 1254 char version; /* alphabetic, 0x60 + version */ 1255 unsigned short repair_time; /* server estimate of repair time, seconds */ 1256 char pl_orbit; /* what planet player orbiting, -1 if none */ 1257 unsigned short gameup; /* server status flags */ 1258 unsigned char tournament_teams; /* what teams are involved */ 1259 unsigned char tournament_age; /* duration of t-mode so far */ 1260 char tournament_age_units; /* units for above, see s2du */ 1261 unsigned char tournament_remain; /* remaining INL game time */ 1262 char tournament_remain_units; /* units for above, see s2du */ 1263 unsigned char starbase_remain; /* starbase reconstruction, mins */ 1264 unsigned char team_remain; /* team surrender time, seconds */ 1265 char pad1[18]; 1266 } __attribute__ ((packed)); 1267 #define GENERIC_32_VERSION_B 2 1268 #define GENERIC_32_VERSION GENERIC_32_VERSION_B /* default */ 1269 1270 /* SP_GENERIC_32 versioning instructions: 1271 1272 we start with version 'a', and each time a structure is changed 1273 increment the version and reduce the pad size, keeping the packet 1274 the same size ... 1275 1276 client is entitled to trust fields in struct that were defined at a 1277 particular version ... 1278 1279 client is to send CP_FEATURE with SP_GENERIC_32 value 1 for version 1280 'a', value 2 for version 'b', etc ... 1281 1282 server is to reply with SP_FEATURE with SP_GENERIC_32 value set to 1283 the maximum version it supports (not the version requested by the 1284 client), ... 1285 1286 server is to send SP_GENERIC_32 packets of the highest version it 1287 knows about, but no higher than the version the client asks for. 1288 */ 1289