1 /* $Id: MultiPlay.h,v 1.20 2003/07/16 16:03:38 nan Exp $ */
2 
3 // Copyright (C) 2000, 2001, 2003  $B?@Fn(B $B5H9((B(Kanna Yoshihiro)
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 
19 #ifndef _MultiPlay_
20 #define _MultiPlay_
21 
22 #include "PlayGame.h"
23 
24 class ExternalData {
25 public:
26   ExternalData();
27   ExternalData( long side );
28 
29   virtual ~ExternalData();
30 
31   long side;
32   long dataType;
33   long sec;
34   char count;
35   char data[256];
36   ExternalData *next;
37 
38   virtual bool Apply( Player *targetPlayer, bool &fThePlayer, bool &fComPlayer,
39 		      bool &fTheBall ) = 0;
40   virtual bool Read( long sock ) = 0;
41 
42   static ExternalData* ReadData( long s );
43 
isNull()44   virtual bool isNull() { return false; };
45 
46 protected:
47   void ReadTime( int sd, long *sec, char *count );
48 };
49 
50 class ExternalPVData : public ExternalData {
51 public:
52   ExternalPVData();
53   ExternalPVData( long side );
54 
55   virtual bool Apply( Player *targetPlayer, bool &fThePlayer, bool &fComPlayer,
56 		      bool &fTheBall );
57   virtual bool Read( long sock );
58 };
59 
60 class ExternalPSData : public ExternalData {
61 public:
62   ExternalPSData();
63   ExternalPSData( long side );
64 
65   virtual bool Apply( Player *targetPlayer, bool &fThePlayer, bool &fComPlayer,
66 		      bool &fTheBall );
67   virtual bool Read( long sock );
68 };
69 
70 class ExternalBVData : public ExternalData {
71 public:
72   ExternalBVData();
73   ExternalBVData( long side );
74 
75   virtual bool Apply( Player *targetPlayer, bool &fThePlayer, bool &fComPlayer,
76 		      bool &fTheBall );
77   virtual bool Read( long sock );
78 };
79 
80 class ExternalPTData : public ExternalData {
81 public:
82   ExternalPTData();
83   ExternalPTData( long side );
84 
85   virtual bool Apply( Player *targetPlayer, bool &fThePlayer, bool &fComPlayer,
86 		      bool &fTheBall );
87   virtual bool Read( long sock );
88 };
89 
90 class ExternalNullData : public ExternalData {
91 public:
Apply(Player * targetPlayer,bool & fThePlayer,bool & fComPlayer,bool & fTheBall)92   virtual bool Apply( Player *targetPlayer, bool &fThePlayer, bool &fComPlayer,
93 		      bool &fTheBall ) { return false; };
Read(long sock)94   virtual bool Read( long sock ) { return false; };
95 
isNull()96   virtual bool isNull() { return true; };
97 };
98 
99 
100 class MultiPlay : public PlayGame {
101 public:
102   MultiPlay();
103   virtual ~MultiPlay();
104 
105   virtual bool Init();
106 
107   static void Create( long player, long com );
108 
109   virtual bool Move( SDL_keysym *KeyHistory, long *MouseXHistory,
110 		     long *MouseYHistory, unsigned long *MouseBHistory,
111 		     int Histptr );
112 
113   //long GetSmashPtr() { return m_smashPtr; };
114 
115   virtual bool LookAt( double &srcX, double &srcY, double &srcZ,
116 		       double &destX, double &destY, double &destZ );
117 
118 
119   void SendTime( char *buf );
120 
121   virtual void EndGame();
122 
123   //long GetTimeAdj() { return m_timeAdj; };
124 
125   void StartServer();
126   void StartClient();
127 
128   static int WaitForData( void * );
129   static int Connect( void * );
130 
131 protected:
132   //bool m_smash;
133   //long m_smashCount;
134   //long m_smashPtr;
135 };
136 
137 #endif	// _MultiPlay_
138