Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37787414
en ru br
Репозитории ALT
S:0.9.0-alt1
5.1: 0.8.0-alt4
4.1: 0.8.0-alt4
4.0: 0.8.0-alt4
3.0: 0.8.0-alt1.1
www.altlinux.org/Changes

Группа :: Игры/Спорт
Пакет: gav

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: gav-0.8.0-fix.patch
Скачать


diff -urN gav-0.8.0.orig/automa/AutomaMainLoop.cpp gav-0.8.0/automa/AutomaMainLoop.cpp
--- gav-0.8.0.orig/automa/AutomaMainLoop.cpp	2005-11-28 09:41:45 +0300
+++ gav-0.8.0/automa/AutomaMainLoop.cpp	2005-11-28 09:45:40 +0300
@@ -33,7 +33,6 @@
 AutomaMainLoop::AutomaMainLoop()
 {
   _is = new InputState();
-  controlsArray = new ControlsArray();
   
   StateMenu *sm = new StateMenu();
   addState(STATE_MENU, sm);
diff -urN gav-0.8.0.orig/automa/StatePlaying.cpp gav-0.8.0/automa/StatePlaying.cpp
--- gav-0.8.0.orig/automa/StatePlaying.cpp	2005-11-28 09:41:45 +0300
+++ gav-0.8.0/automa/StatePlaying.cpp	2005-11-28 09:45:40 +0300
@@ -25,6 +25,7 @@
 #include "Automa.h"
 #include "AutomaMainLoop.h"
 #ifndef NONET
+#include "Ball.h"
 #include "NetServer.h"
 #endif
 #include "StateWithInput.h"
@@ -105,33 +106,10 @@
 #endif //!NONET
 }
 
-// executes one step of the game's main loop
-// Returns NO_TRANSITION if the game continues, the next state otherwise
-int StatePlaying::execute(InputState *is, unsigned int ticks,
-			  unsigned int prevTicks, int firstTime)
-{
-  if ( firstTime ) {
-#ifndef NONET
-    if ( nets ) {
-      setupConnection(is);
-    }
-#endif
-
-#ifdef AUDIO
-    soundMgr->stopSound(SND_BACKGROUND_MENU);
-    soundMgr->playSound(SND_BACKGROUND_PLAYING, true);
-#endif
-
-    /* 
-       First time we change to execute state: we should
-       probably create players here instead of in the constructor,
-       and think of a clever way to destroy them once we're done.
-    */
+void StatePlaying::createteams(){
 
-    prevDrawn = ticks;
     tl = new Team(-1);
     tr = new Team(1);
-    b = new Ball(BALL_ORIG);
 
     for ( int i = 0, j = 0; i < configuration.left_nplayers; j++ ) {
       if ( configuration.left_players[j] == PLAYER_NONE ) {
@@ -175,29 +153,109 @@
 
       i++;
     }
+}
+
+// executes one step of the game's main loop
+// Returns NO_TRANSITION if the game continues, the next state otherwise
+int StatePlaying::execute(InputState *is, unsigned int ticks,
+			  unsigned int prevTicks, int firstTime)
+{
+  if ( firstTime ) {
+#ifndef NONET
+    if ( nets ) {
+      setupConnection(is);
+    }
+#endif
+
+#ifdef AUDIO
+    soundMgr->stopSound(SND_BACKGROUND_MENU);
+    soundMgr->playSound(SND_BACKGROUND_PLAYING, true);
+#endif
+
+    /* 
+       First time we change to execute state: we should
+       probably create players here instead of in the constructor,
+       and think of a clever way to destroy them once we're done.
+    */
+
+    prevDrawn = ticks;
+    b = new Ball(BALL_ORIG);
+    StatePlaying::createteams();
 
     tl->setScore(0);
     tr->setScore(0);
-    b->resetPos((int) (SCREEN_WIDTH() * 0.25),
-		(int) (SCREEN_HEIGHT() * 0.66));
+    //reset point
+     b->setX((SCREEN_WIDTH() / 2) + ((SCREEN_WIDTH() *  -1) / 4) - b->radius());
+     b->setY((SCREEN_HEIGHT() * 2) / 3 - b->radius()); 
   }
   
   controlsArray->setControlsState(is, tl, tr);
   
   if ( is->getKeyState()[SDLK_ESCAPE] ) {
+    configuration.aiact=0;
+    string msg;
+    SDL_Rect r;
+    int lscore=tl->getScore(), rscore=tr->getScore();
+    
     delete(tl);
     delete(tr);
+        
+    b->SetSpd(0,0);
+    b->Setgravity(0);
+	
+    msg="Are you sure want to exit? (Y/N)";
+    
+    r.x = (screen->w / 2) -msg.length()*(cga->charWidth())/2;
+    r.y = screen->h * 1/2;
+    cga->printXY(screen, &r, msg.c_str());
+    SDL_Flip(screen);
+  bool yes=false;
+   while (true)
+   {
+    if ((yes=(getKeyPressed(is)=='y')))
+     break;
+     else
+     break;
+   }
+   
+   if (yes) {
     delete(b);
+    delete(netc);
+    netc = NULL;
+#ifdef AUDIO
+    soundMgr->stopSound(SND_BACKGROUND_PLAYING);
+#endif
+   // return(STATE_MENU);
 #ifndef NONET
-    if ( nets ) {
+    if ( nets ) 
       delete(nets);
       nets = NULL;
-    } 
+   
 #endif
 #ifdef AUDIO
     soundMgr->stopSound(SND_BACKGROUND_PLAYING);
-#endif
+#endif      
+  // configuration.ballAmplify=balltemp;
+    SDL_Flip(screen);
     return(STATE_MENU);
+    SDL_Flip(screen);
+    configuration.aiact=1;
+    } 
+    else
+    {
+    
+   StatePlaying::createteams();
+    tl->setScore(lscore);
+    tr->setScore(rscore);
+        
+    SDL_Flip(screen);
+   
+     b->setX((SCREEN_WIDTH() / 2) + ((SCREEN_WIDTH() *  configuration.team_push) / 4) - b->radius());
+     b->setY((SCREEN_HEIGHT() * 2) / 3 - b->radius()); 
+
+     SDL_Flip(screen);
+     configuration.aiact=1;
+    }
   }  
 
   tl->update(ticks - prevTicks, controlsArray);
@@ -228,6 +286,24 @@
 	(tl->getScore() > (tr->getScore()+1))) ||
        ((tr->getScore() >= configuration.winning_score) &&
 	(tr->getScore() > (tl->getScore()+1))) ) {
+	
+	    string msg;
+    SDL_Rect r;
+    
+    msg="!THE END!";
+    
+    r.x = (screen->w / 2) -msg.length()*(cga->charWidth())/2;
+    r.y = screen->h * 1/2;
+    cga->printXY(screen, &r, msg.c_str());
+    SDL_Flip(screen);
+   while (true)
+   {
+    if (getKeyPressed(is))
+     break;
+     else
+     break;
+   }
+	
 #ifdef AUDIO
     soundMgr->playSound(SND_VICTORY);
 #endif // AUDIO
diff -urN gav-0.8.0.orig/automa/StatePlaying.h gav-0.8.0/automa/StatePlaying.h
--- gav-0.8.0.orig/automa/StatePlaying.h	2005-11-28 09:41:45 +0300
+++ gav-0.8.0/automa/StatePlaying.h	2005-11-28 09:45:40 +0300
@@ -43,6 +43,7 @@
 
 private:
   void StatePlaying::setupConnection(InputState *is);
+  void StatePlaying::createteams();
 };
 
 #endif // _STATEPLAYING_H_
diff -urN gav-0.8.0.orig/Ball.cpp gav-0.8.0/Ball.cpp
--- gav-0.8.0.orig/Ball.cpp	2005-11-28 09:41:45 +0300
+++ gav-0.8.0/Ball.cpp	2005-11-28 09:45:40 +0300
@@ -21,6 +21,7 @@
 */
 
 #include "Ball.h"
+#include "Configuration.h"
 
 #define PI 3.14158
 
@@ -107,6 +108,17 @@
 void Ball::assignPoint(int side, Team *t) {
   if ( _side == side ) {
     t->score();
+    string msg;
+    SDL_Rect r;
+    configuration.aiact=0;
+    
+    msg="!SCORE!";
+    
+    r.x = (screen->w / 2) -msg.length()*(cga->charWidth())/2;
+    r.y = screen->h * 1/2;
+    cga->printXY(screen, &r, msg.c_str());
+    SDL_Flip(screen);
+    SDL_Delay(80);
 #ifdef AUDIO
     soundMgr->playSound(SND_SCORE);
 #endif // AUDIO
@@ -120,6 +132,7 @@
   _y = (SCREEN_HEIGHT() * 2) / 3 - _radius;
   _spdx = _spdy = _accelY = 0;
   _scorerSide = 0;
+  configuration.aiact=1;
   resetCollisionCount();
 }
 
@@ -241,8 +254,8 @@
   if ( _x < LEFT_WALL  ) {
     _x = LEFT_WALL;
     _spdx = - (int) (_spdx * ELASTIC_SMOOTH);
-    if ( _collisionCount[tright] )
-      resetCollisionCount();
+//    if ( _collisionCount[tright] )
+   //   resetCollisionCount();
 #ifdef AUDIO
     soundMgr->playSound(SND_BOUNCE);
 #endif // AUDIO
@@ -253,8 +266,8 @@
   if ( _x > RIGHT_WALL(_frames->width()) ) {
     _x = RIGHT_WALL(_frames->width());
     _spdx = - (int) (_spdx * ELASTIC_SMOOTH);
-    if ( _collisionCount[tleft] )
-      resetCollisionCount();
+   // if ( _collisionCount[tleft] )
+   //   resetCollisionCount();
 #ifdef AUDIO
     soundMgr->playSound(SND_BOUNCE);
 #endif // AUDIO
@@ -310,7 +323,7 @@
     soundMgr->playSound(SND_BOUNCE);
 #endif // AUDIO
   }
-
+  
   // collisions with the players
   for ( int teami = 0; !_scorerSide && (teami < 2); teami ++ ) {
     Team *team = (teami?tright:tleft);
@@ -325,6 +338,14 @@
 	  if ( !_collisionCount[team] )
 	    resetCollisionCount();
 	  _collisionCount[team]++;
+	  
+	  configuration.team_push=(team == tleft)?1:-1;
+	  
+	  if (team==tright)
+	  _collisionCount[tleft]=0;
+	 else
+	  _collisionCount[tright]=0; 
+	  
 #ifdef AUDIO
 	  soundMgr->playSound(SND_PLAYERHIT);
 #endif // AUDIO
@@ -358,7 +379,7 @@
   
   // to activate 'gravity'
   if ( !_accelY && (abs(_spdx) + abs(_spdy)) )
-    _accelY = GRAVITY;
+    _accelY = configuration.sv_gravity;
 
   /*
   // over net test
diff -urN gav-0.8.0.orig/Ball.h gav-0.8.0/Ball.h
--- gav-0.8.0.orig/Ball.h	2005-11-28 09:41:45 +0300
+++ gav-0.8.0/Ball.h	2005-11-28 09:45:40 +0300
@@ -123,7 +123,11 @@
   inline int radius() { return _radius; }
   inline float angle() { return _angle; }
   inline void angle(float v) { _angle = v; }
-
+  
+  inline void SetXY(int x, int y) { _x=x; _y=y;}
+  inline void SetSpd(int sx, int sy) { _spdx=sx; _spdy=sy;}
+  inline void Setgravity(int ay)   { _accelY=ay; }
+    
   inline int spdx() { return _spdx; }
   inline int spdy() { return _spdy; }
   inline int frame() { return _frameIdx; }
diff -urN gav-0.8.0.orig/CHANGELOG gav-0.8.0/CHANGELOG
--- gav-0.8.0.orig/CHANGELOG	2005-11-28 09:41:45 +0300
+++ gav-0.8.0/CHANGELOG	2005-11-28 09:45:40 +0300
@@ -1,3 +1,29 @@
+*!Sometime after pause AI work incorrect
+!! Made patch from GAV v. 0.8.0 --> GAV v.1.0.0 (K@M edition)
+*! FIXED problem with sound
++ Game now more friendly, that after
++ Added comments in configuration file
+* Fixed problem with pause. Now ball stop. =)
++ At end of round now writting "THE END", and stop.
+* Fixed problems with caption
+* When game is pause - AI disabled
+* At start ball have a standart position
++ Gravity is changeable, but it is not in menu (it is not a cheat)
++! Added pause
+* Fixed "Box" problem (when if other team don't touched ball, but it was on them half of playground, touches=0)
++ Esc is pause game and ask to exit
++ Now support 12 players
+* made rebuilt of menu (it makes it more ergonomically).
+* Fixed problem with 1st start
++ Now save theme, caption, big background, ball speed, score to win, etc.
+- Problems with sound.
+* Fixed problems with home folder find
+* Fixed non-correct of load monitor type, 3th and ++ players at start.
++ Setting saves.
++ K@M begin to end develop it game
+- Stop of MS Windows version support
+
+
 Version 0.8.0 changes:
 - (we hope) *FINAL* patch for stuck on the net problem
 - patch for ball passing over the net bug
diff -urN gav-0.8.0.orig/Configuration.h gav-0.8.0/Configuration.h
--- gav-0.8.0.orig/Configuration.h	2005-11-28 09:41:45 +0300
+++ gav-0.8.0/Configuration.h	2005-11-28 09:45:40 +0300
@@ -74,7 +74,11 @@
   int right_players[MAX_PLAYERS/2];
   PlayerFrameConf_t playerFrameConf;
   BallFrameConf_t ballFrameConf;
-
+  
+  //k
+  int team_push;
+  bool aiact; //AI Activity
+  int sv_gravity;
 
   /* To add: something meaningful to record the controls... */
 
diff -urN gav-0.8.0.orig/ControlsArray.cpp gav-0.8.0/ControlsArray.cpp
--- gav-0.8.0.orig/ControlsArray.cpp	2005-11-28 09:41:45 +0300
+++ gav-0.8.0/ControlsArray.cpp	2005-11-28 09:45:40 +0300
@@ -33,21 +33,21 @@
 #endif
 
 void ControlsArray::initializeControls() {
-  _keyMapping[0].left_key = SDLK_z;
-  _keyMapping[0].right_key = SDLK_c;
-  _keyMapping[0].jump_key = SDLK_LSHIFT;
+  _keyMapping[0].left_key = SDLK_a;
+  _keyMapping[0].right_key = SDLK_d;
+  _keyMapping[0].jump_key = SDLK_w;
   
   _keyMapping[1].left_key = SDLK_LEFT;
   _keyMapping[1].right_key = SDLK_RIGHT;
   _keyMapping[1].jump_key = SDLK_UP;
   
-  _keyMapping[2].left_key = SDLK_h;
-  _keyMapping[2].right_key = SDLK_k;
-  _keyMapping[2].jump_key = SDLK_u;
-
-  _keyMapping[3].left_key = SDLK_s;
-  _keyMapping[3].right_key = SDLK_f;
-  _keyMapping[3].jump_key = SDLK_e;
+  _keyMapping[2].left_key = SDLK_v;
+  _keyMapping[2].right_key = SDLK_n;
+  _keyMapping[2].jump_key = SDLK_g;
+
+  _keyMapping[3].left_key = SDLK_j;
+  _keyMapping[3].right_key = SDLK_l;
+  _keyMapping[3].jump_key = SDLK_i;
 }
 
 void ControlsArray::setControlsState(InputState *is, Team * tl, Team * tr) {
diff -urN gav-0.8.0.orig/ControlsArray.h gav-0.8.0/ControlsArray.h
--- gav-0.8.0.orig/ControlsArray.h	2005-11-28 09:41:45 +0300
+++ gav-0.8.0/ControlsArray.h	2005-11-28 09:45:40 +0300
@@ -38,6 +38,7 @@
 typedef enum { CNTRL_LEFT = 1, CNTRL_RIGHT = 2, CNTRL_JUMP = 4} cntrl_t;
 
 class ControlsArray {
+public:
   triple_t _inputs[MAX_PLAYERS];
   controls_t _keyMapping[MAX_PLAYERS];
   Uint8 _f[12];
diff -urN gav-0.8.0.orig/globals.h gav-0.8.0/globals.h
--- gav-0.8.0.orig/globals.h	2005-11-28 09:41:45 +0300
+++ gav-0.8.0/globals.h	2005-11-28 09:45:40 +0300
@@ -27,12 +27,26 @@
 #include "ScreenFont.h"
 #include "Configuration.h"
 #include "aarg.h"
+//#inculde ""
+
+//#undef AUDIO
 
 #define FPS (50)
 
+using namespace std;
+
 class MenuRoot;
 class ControlsArray;
 
+//k
+
+/*extern unsigned int FPerS;
+extern unsigned int FSkip;
+extern unsigned int WinS;
+extern unsigned int BallS;*/
+
+//k
+
 extern SDL_Surface *screen;
 extern SDL_Surface *background;
 
diff -urN gav-0.8.0.orig/main.cpp gav-0.8.0/main.cpp
--- gav-0.8.0.orig/main.cpp	2005-11-28 09:41:45 +0300
+++ gav-0.8.0/main.cpp	2005-11-28 09:45:40 +0300
@@ -20,6 +20,7 @@
 */
 
 #include <stdlib.h>
+#include <fstream>
 #include <SDL.h>
 #include <sys/types.h>
 #include <dirent.h>
@@ -56,6 +57,8 @@
 
 #include "Theme.h"
 
+#include "Configuration.h"
+
 #include "Sound.h"
 
 #ifndef NONET 
@@ -67,6 +70,13 @@
 
 using namespace std;
 
+ ifstream f;
+ ofstream fo;
+
+  char* home=getenv("HOME");
+  string SettingsFileName=(string(home)+"/.gav");
+
+  
 #ifdef AUDIO
 SDL_AudioSpec desired,obtained;
 
@@ -74,6 +84,7 @@
 
 playing_t playing[MAX_PLAYING_SOUNDS];
 
+
 void AudioCallBack(void *user_data,Uint8 *audio,int length)
 {
   int i;
@@ -122,10 +133,111 @@
 }
 #endif
 
-void
-init()
+string LoadedThemeName;
+string WindowCaption;
+int FullScreen;
+
+
+void SaveSettings()
+{
+  fo.open (SettingsFileName.c_str(), ios::out);
+
+  if (!fo)
+  {
+    cerr << "Can't save settings" << endl;
+    return;
+  }
+   fo <<"#Please don't edit this file, and don't add/delete coments" << endl << "#GAV KE (GPL Arcade Volleyball K@M EDITION)" << endl <<  "#Next 12 lines shows status of players (0=None, 1=KeyB, 2=CPU/Net)"<<endl;
+   for (int i=0; i<(MAX_PLAYERS/2); i++)
+    fo<< configuration.left_players[i] << endl << configuration.right_players[i] << endl;
+    
+    fo <<"#gravity"<<endl; 
+  fo  << configuration.sv_gravity << endl;
+     fo <<"#Monitor type"<<endl;
+  fo  << configuration.monitor_type-1 << endl;
+     fo <<"#Fullscreen"<<endl;
+  fo << ((screenFlags & SDL_FULLSCREEN) != 0) << endl;
+     fo <<"#BigBG "<<endl;
+  fo << CurrentTheme->_bigBackground << endl;
+     fo <<"#FPS, FrameSkip, WIN_score, Ball Amplify"<<endl;
+  fo << configuration.fps  << endl << configuration.frame_skip << endl << configuration.winning_score << endl <<configuration.ballAmplify<<endl;
+     fo <<"#ThemeName"<<endl;
+  fo << CurrentTheme->_name << endl; 
+     fo <<"#Win Caption"<<endl;
+  fo<< WindowCaption << endl;
+    fo <<"#Next 36 lines are [1..12] player left, right, jump keys "<<endl;
+  for (int i=0; i<MAX_PLAYERS; i++)
+    fo << controlsArray->_keyMapping[i].left_key << endl << controlsArray->_keyMapping[i].right_key << endl
+      << controlsArray->_keyMapping[i].jump_key << endl;
+  
+  fo.close();
+}
+
+
+void LoadSettings2()
 {
-  if ( SDL_Init(SDL_INIT_VIDEO) ) {
+ char comment[300];
+   f.seekg(1,ios::cur);
+ f.getline(comment,300);
+ 
+ char wincapt[300];
+ f.getline(wincapt,300);
+ if ((WindowCaption=wincapt)=="")
+  WindowCaption="GPL Arcade VolleyBall";
+ SDL_WM_SetCaption(WindowCaption.c_str(), "GAV");
+ 
+   controlsArray = new ControlsArray();
+   f.getline(comment,300);
+  for (int i=0; i<MAX_PLAYERS; i++)
+    f >> controlsArray->_keyMapping[i].left_key >> controlsArray->_keyMapping[i].right_key >>
+      controlsArray->_keyMapping[i].jump_key;     
+}
+
+void LoadSettings1()
+{  
+ char comment[300];
+  configuration.left_nplayers=0;
+  configuration.right_nplayers=0;
+  configuration.team_push=-1;
+  configuration.aiact=1;
+ f.getline(comment,300);
+ f.getline(comment,300);
+ f.getline(comment,300);
+ for (int i=0;  i<(MAX_PLAYERS/2); i++)
+  {
+   f >> configuration.left_players[i];
+   f >> configuration.right_players[i];
+   if (configuration.left_players[i] != 0 )
+    configuration.left_nplayers++;
+   if (configuration.right_players[i] != 0 )
+   configuration.right_nplayers++;
+  }
+ f.seekg(1,ios::cur);
+  
+ f.getline(comment,300);
+ f >> configuration.sv_gravity;
+ f.seekg(1,ios::cur);   
+ f.getline(comment,300);
+ f >> configuration.monitor_type;
+ f.seekg(1,ios::cur);
+ f.getline(comment,300);
+ f >> FullScreen; 
+ f.seekg(1,ios::cur);
+ f.getline(comment,300);
+ f >> configuration.bgBig;
+ f.seekg(1,ios::cur);
+ f.getline(comment,300);
+
+f >> configuration.fps >>configuration.frame_skip>>configuration.winning_score>> configuration.ballAmplify;
+  f.seekg(1,ios::cur);
+  f.getline(comment,300);
+  f>>LoadedThemeName;  
+}
+
+void init()
+{
+  if ( SDL_Init(SDL_INIT_VIDEO) )
+  {
     cerr << "Cannot initialize SDL, exiting." << endl;
     exit(1);
   }
@@ -137,39 +249,78 @@
   }
 #endif
 
+   
 #ifdef AUDIO
   atexit(SDL_CloseAudio);
-
   desired.freq=44100;//22050;
   desired.format = AUDIO_S16;
   desired.samples=512;//4096;
   desired.channels=1;
   desired.callback=AudioCallBack;
   desired.userdata=NULL;
-
   if(SDL_OpenAudio(&desired,&obtained)<0){
     printf("Cannot open the audio device\n");
   }
 
   ClearPlayingSounds();
-
   SDL_PauseAudio(0);
 #endif
-
-  SDL_WM_SetCaption("GPL Arcade Volleyball", "GAV");
-
   setThemeDir(TH_DIR);
   videoinfo = SDL_GetVideoInfo();
-  CurrentTheme = new Theme(TH_DEFAULT);
+  CurrentTheme = new Theme(LoadedThemeName);
 }
 
+void Uhod()
+{
+SaveSettings();
+
+cerr << " GGGG  AAAA  V     V\n";
+cerr << "G      A  A   V   V\n";
+cerr << "G GGG  AAAA    V V\n";
+cerr << " GGG   A  A     V\n";
+
+cerr << "\nThanks for play.\nGood day!" << endl;
+}
+
+void Prihod()
+{ 
+  cerr << "Welcome to GPL Arcade Volleyball !\nhttp://gav.sourceforge.net/\nK@M editon\nkam@forpost.ru\n\n";
+  f.open (SettingsFileName.c_str(), ios::in);
+
+  if (!f)
+   {    // Default settings   
+     f.close();
+
+     fo.open (SettingsFileName.c_str(), ios::out);
+     fo<<"\n\n\n1\n2\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n\n250\n\n-1\n\n0\n\n0\n\n50\n0\n15\n5\n\nclassic\n\nGPL Arcade Volleyball \n\n97\n100\n119\n276\n275\n273\n118\n110\n103\n106\n108\n105\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0"<<endl;
+    fo.close();   
+    configuration.sv_gravity=250;
+    LoadedThemeName="classic";
+    //WindowCaption="GPL_Arcade_Volleyball";
+    configuration.monitor_type=-1;
+   }
+   else
+     f.close();
+
+f.open (SettingsFileName.c_str(), ios::in);
+LoadSettings1();    
+init();
+LoadSettings2();
+  f.close();      
+}
+
+
+
 #ifdef AUDIO
 Sound * Prova;
 #endif
 #include <unistd.h>
-int main(int argc, char *argv[]) {
-  init();
-  
+int main(int argc, char *argv[]) 
+{
+   Prihod();
+   SaveSettings();
+   atexit (Uhod);
+    
 #ifdef AUDIO
 #if 0
   Prova = new Sound("rocket.wav");
@@ -178,15 +329,17 @@
 #endif
 
    /* initialize menus */
+
   Menu m;
   MenuItemPlay miplay;
   MenuItemExit miexit;
+  Menu *menuPlay = new Menu();
   Menu *menuExtra = new Menu();
   Menu *menuThemes = new Menu();
 #ifndef NONET
   Menu *menuNetwork = new Menu();
 #endif
-  MenuItemBack *mib = new MenuItemBack("back");
+  MenuItemBack *mib = new MenuItemBack("Back");
   DIR *dir;
   if ((dir = opendir(ThemeDir.c_str())) == NULL) {
     std::cerr << "Cannot find themes directory\n";
@@ -207,40 +360,66 @@
   menuNetwork->add(mib);
 #endif
 
+MenuStack ms;
+
   menuExtra->add(new MenuItemSubMenu(menuThemes, string("Theme")));
+  menuExtra->add(new MenuItemSubMenu(new MenuKeys(0),  string("Define Keys")));
+    
+  menuExtra->add(new MenuItemNotImplemented(string("Set Joystick")));
+  
 #ifndef NONET
   menuExtra->add(new MenuItemSubMenu(menuNetwork, string("Network game")));
-#endif
-  menuExtra->add(new MenuItemPlayer(TEAM_LEFT, 1));
-  menuExtra->add(new MenuItemPlayer(TEAM_RIGHT, 1));
-  menuExtra->add(new MenuItemSubMenu(new MenuKeys(1),
-				     string("Define Keys")));
+#endif  
+
   menuExtra->add(new MenuItemFPS());
   menuExtra->add(new MenuItemFrameSkip());
   menuExtra->add(new MenuItemScore());
-  menuExtra->add(new MenuItemMonitor());
+  
+  MenuItemMonitor *mim;
+  menuExtra->add(mim=new MenuItemMonitor());
+  mim->execute(ms);
+  
   menuExtra->add(new MenuItemBallSpeed());
   menuExtra->add(new MenuItemBigBackground());
-  menuExtra->add(new MenuItemFullScreen());
+  
+  MenuItemFullScreen *mifs;
+  menuExtra->add(mifs = new MenuItemFullScreen());
   menuExtra->add(mib);
+ 
+  { 
+  int i;
+   for (i=1; i<(MAX_PLAYERS/2);i++)
+   {
+   menuPlay->add(new MenuItemPlayer(TEAM_LEFT, i));
+   menuPlay->add(new MenuItemPlayer(TEAM_RIGHT, i));
+   menuPlay->add(new MenuItemSubMenu(new MenuKeys(i), string("Define Keys")));
+   } 
+  }
+  menuPlay->add(mib);
 
   m.add(&miplay);
+  
   m.add(new MenuItemPlayer(TEAM_LEFT, 0));
-  m.add(new MenuItemPlayer(TEAM_RIGHT, 0));
+    
+  m.add(new MenuItemPlayer(TEAM_RIGHT,0));  
+
+  m.add(new MenuItemSubMenu(menuPlay,string("Players")));
+      
 #ifdef AUDIO
   m.add(new MenuItemSound());
 #else // AUDIO
   m.add(new MenuItemNotCompiled(string("Sound: Off")));
 #endif // AUDIO
-  m.add(new MenuItemSubMenu(new MenuKeys(0),
-			    string("Define Keys")));
-  m.add(new MenuItemNotImplemented(string("Set Joystick")));
-  m.add(new MenuItemSubMenu(menuExtra,
-			    string("Extra")));
+
+  m.add(new MenuItemSubMenu(menuExtra, string("Options")));
   m.add(&miexit);
   mroot = new MenuRoot();
   mroot->add(&m);
 
+  
+  if (FullScreen)
+    mifs->execute (ms);
+
   AutomaMainLoop *a = new AutomaMainLoop();
 
   a->start();
diff -urN gav-0.8.0.orig/Makefile gav-0.8.0/Makefile
--- gav-0.8.0.orig/Makefile	2005-11-28 09:41:45 +0300
+++ gav-0.8.0/Makefile	2005-11-28 09:45:40 +0300
@@ -68,3 +68,4 @@
 ifeq ($(wildcard $(DEPEND)),$(DEPEND))
 include $(DEPEND)
 endif
+# DO NOT DELETE
diff -urN gav-0.8.0.orig/menu/Makefile gav-0.8.0/menu/Makefile
--- gav-0.8.0.orig/menu/Makefile	2005-11-28 09:41:45 +0300
+++ gav-0.8.0/menu/Makefile	2005-11-28 09:45:40 +0300
@@ -46,3 +46,4 @@
 ifeq ($(wildcard $(DEPEND)),$(DEPEND))
 include $(DEPEND)
 endif
+# DO NOT DELETE
diff -urN gav-0.8.0.orig/menu/Menu.cpp gav-0.8.0/menu/Menu.cpp
--- gav-0.8.0.orig/menu/Menu.cpp	2005-11-28 09:41:45 +0300
+++ gav-0.8.0/menu/Menu.cpp	2005-11-28 09:45:40 +0300
@@ -1,32 +1,12 @@
-/* -*- C++ -*- */
-/*
-  GAV - Gpl Arcade Volleyball
-  
-  Copyright (C) 2002
-  GAV team (http://sourceforge.net/projects/gav/)
-
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
-  (at your option) any later version.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program; if not, write to the Free Software
-  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
-
 #include "Menu.h"
 #include <string.h>
 #include "SoundMgr.h"
 
 using namespace std;
 
-void Menu::add(MenuItem * mi) {
+
+void Menu::add(MenuItem * mi)
+{
   if (currentItem < 0)
     currentItem = 0;
   if ((mi->getLabel()).length() > maxLabelLength)
@@ -34,26 +14,68 @@
   items.push_back(mi);
 }
 
-int Menu::execute(InputState *is, std::stack<Menu *> &s) {
+
+
+bool PrevUp = false, PrevDown = false;
+
+int Menu::execute(InputState *is, std::stack<Menu *> &s)
+{
   SDL_Rect rect;
   const char * label;
   ScreenFont * font;
   static bool spacePressed = false;
 
-  if ( is->getKeyState()[SDLK_UP] && (currentItem > 0) ) {
-    currentItem--;
+  // Up  
+  if (is->getKeyState()[SDLK_UP])
+  {
+    if (!PrevUp)
+    {
+      if (currentItem > 0)
+      {
+        currentItem--;
 #ifdef AUDIO
-    soundMgr->playSound(SND_MENU_SELECT);
-#endif // AUDIO
+        soundMgr->playSound (SND_MENU_SELECT);
+#endif
+      }
+      else
+      {
+        currentItem=(int)(items.size()-1);
+#ifdef AUDIO
+        soundMgr->playSound (SND_MENU_SELECT);
+#endif
+      }
+      PrevUp = true;
+    }
   }
-  if ( is->getKeyState()[SDLK_DOWN] &&
-       (currentItem < (int) (items.size() - 1)) ) {
-    currentItem++;
+  else
+    PrevUp =false;
+
+  // Down
+  if (is->getKeyState()[SDLK_DOWN])
+  {
+    if (!PrevDown)
+    {
+      if (currentItem < (int)(items.size()-1))
+      {
+        currentItem++;
 #ifdef AUDIO
-    soundMgr->playSound(SND_MENU_SELECT);
-#endif // AUDIO
+        soundMgr->playSound (SND_MENU_SELECT);
+#endif
+      }
+      else
+            {
+        currentItem=0;
+#ifdef AUDIO
+        soundMgr->playSound (SND_MENU_SELECT);
+#endif
+      }
+      PrevDown = true;
+    }
   }
-  /* draw menu items labels */
+  else
+    PrevDown = false;
+
+  // draw menu items labels
   rect.y = 30;
   for ( unsigned int it = 0; it < items.size(); it++ ) {
     label = items[it]->getLabel().c_str();
@@ -66,7 +88,7 @@
     rect.y += font->charHeight();
   }
 
-  /* call the execute method of the current item, if an event occurred */
+  // call the execute method of the current item, if an event occurred
   if ( (is->getKeyState()[SDLK_SPACE]) ||
        (is->getKeyState()[SDLK_RETURN]) ) {
     spacePressed = true;
diff -urN gav-0.8.0.orig/menu/MenuItemBigBackground.h gav-0.8.0/menu/MenuItemBigBackground.h
--- gav-0.8.0.orig/menu/MenuItemBigBackground.h	2005-11-28 09:41:45 +0300
+++ gav-0.8.0/menu/MenuItemBigBackground.h	2005-11-28 09:45:40 +0300
@@ -31,7 +31,7 @@
 class MenuItemBigBackground: public MenuItem {
 public:
   MenuItemBigBackground() {
-    label = std::string("Big Background: No");
+      label = std::string(configuration.bgBig?"Big Background: Yes":"Big Background: No");
   }
 
   int execute(std::stack<Menu *> &s) {
diff -urN gav-0.8.0.orig/menu/MenuItemFullScreen.h gav-0.8.0/menu/MenuItemFullScreen.h
--- gav-0.8.0.orig/menu/MenuItemFullScreen.h	2005-11-28 09:41:45 +0300
+++ gav-0.8.0/menu/MenuItemFullScreen.h	2005-11-28 09:45:40 +0300
@@ -27,20 +27,21 @@
 #include "MenuItem.h"
 #include "globals.h"
 
+typedef std::stack<Menu *> MenuStack;
+
 class MenuItemFullScreen: public MenuItem {
 public:
   MenuItemFullScreen() {
     label = std::string("Fullscreen: No");
   }
 
-  int execute(std::stack<Menu *> &s) {
+  int execute(MenuStack &s) {
     SDL_FreeSurface(screen);
     int wasFull = (screenFlags & SDL_FULLSCREEN);
     label = std::string(wasFull?"Fullscreen: No":"FullScreen: Yes");
     screenFlags =
       wasFull?(screenFlags & ~SDL_FULLSCREEN):(screenFlags|SDL_FULLSCREEN);
     screen = SDL_SetVideoMode(SCREEN_WIDTH(),
-			      //	SCREEN_HEIGHT(), BPP, screenFlags);
 			      SCREEN_HEIGHT(),
 			      videoinfo->vfmt->BitsPerPixel, 
 			      screenFlags);
diff -urN gav-0.8.0.orig/menu/MenuItemMonitor.h gav-0.8.0/menu/MenuItemMonitor.h
--- gav-0.8.0.orig/menu/MenuItemMonitor.h	2005-11-28 09:41:45 +0300
+++ gav-0.8.0/menu/MenuItemMonitor.h	2005-11-28 09:45:40 +0300
@@ -50,6 +50,7 @@
       monitor = "Very, very old";
       break;
     }
+   
 
     label = std::string("Monitor Type: ") + monitor;
   }
diff -urN gav-0.8.0.orig/menu/MenuItemPlayer.h gav-0.8.0/menu/MenuItemPlayer.h
--- gav-0.8.0.orig/menu/MenuItemPlayer.h	2005-11-28 09:41:45 +0300
+++ gav-0.8.0/menu/MenuItemPlayer.h	2005-11-28 09:45:40 +0300
@@ -59,7 +59,7 @@
       postfix = std::string("Computer / Net");
       break;
     case PLAYER_HUMAN:
-      postfix = std::string("Keyboard");
+      postfix = std::string("Keyboard");        
       break;
     }
 
diff -urN gav-0.8.0.orig/menu/MenuKeys.h gav-0.8.0/menu/MenuKeys.h
--- gav-0.8.0.orig/menu/MenuKeys.h	2005-11-28 09:41:45 +0300
+++ gav-0.8.0/menu/MenuKeys.h	2005-11-28 09:45:40 +0300
@@ -60,35 +60,35 @@
       st += "Left: ";
       cga->printXY(screen, &rect, st.c_str());
       if ( ( event.type != SDL_KEYDOWN ) || isStillPressed )
-	return(0);
+	     return(0);
       controlsArray->setControl(2*_base, CNTRL_LEFT, event.key.keysym.sym);
       break;
     case PL1R:
       st += "Right: ";
       cga->printXY(screen, &rect, st.c_str());
       if ( ( event.type != SDL_KEYDOWN ) || isStillPressed )
-	return(0);
+	     return(0);
       controlsArray->setControl(2*_base, CNTRL_RIGHT, event.key.keysym.sym);
       break;
     case PL1J:
       st += "Jump: ";
       cga->printXY(screen, &rect, st.c_str());
       if ( ( event.type != SDL_KEYDOWN ) || isStillPressed )
-	return(0);
+	     return(0);
       controlsArray->setControl(2*_base, CNTRL_JUMP, event.key.keysym.sym);
       break;
     case PL2L:
       st += "Left: ";
       cga->printXY(screen, &rect, st.c_str());
       if ( ( event.type != SDL_KEYDOWN ) || isStillPressed )
-	return(0);
+	     return(0);
       controlsArray->setControl(2*_base + 1, CNTRL_LEFT, event.key.keysym.sym);
       break;
     case PL2R:
       st += "Right: ";
       cga->printXY(screen, &rect, st.c_str());
       if ( ( event.type != SDL_KEYDOWN ) || isStillPressed )
-	return(0);
+	     return(0);
       controlsArray->setControl(2*_base + 1, CNTRL_RIGHT, event.key.keysym.sym);
       // event.key.keysym.sym
       break;
@@ -96,7 +96,7 @@
       st += "Jump: ";
       cga->printXY(screen, &rect, st.c_str());
       if ( ( event.type != SDL_KEYDOWN ) || isStillPressed )
-	return(0);
+	     return(0);
       controlsArray->setControl(2*_base + 1, CNTRL_JUMP, event.key.keysym.sym);
       // event.key.keysym.sym
       break;
diff -urN gav-0.8.0.orig/PlayerAI.cpp gav-0.8.0/PlayerAI.cpp
--- gav-0.8.0.orig/PlayerAI.cpp	2005-11-28 09:41:45 +0300
+++ gav-0.8.0/PlayerAI.cpp	2005-11-28 09:45:40 +0300
@@ -29,6 +29,8 @@
 #define NEWPL_SIDE (-1)
 
 triple_t PlayerAI::planAction() {
+if (configuration.aiact==1) {
+
   int jmp = 0;
   //int i;
   int side = (team())->side();
@@ -239,5 +241,7 @@
       ret.jump = 1;
 
   return ret;
+  
+  }
 }
 
diff -urN gav-0.8.0.orig/Player.h gav-0.8.0/Player.h
--- gav-0.8.0.orig/Player.h	2005-11-28 09:41:45 +0300
+++ gav-0.8.0/Player.h	2005-11-28 09:45:40 +0300
@@ -145,6 +145,8 @@
   inline void setSpeedY(int s) {_speedY = s;}
   
   int speedX();
+  inline void setSpeedX(int sx) {_speedX=sx; }
+  
   inline int x() {return _x;}
   inline void setX(int x) {_x = x;}
   
diff -urN gav-0.8.0.orig/Team.h gav-0.8.0/Team.h
--- gav-0.8.0.orig/Team.h	2005-11-28 09:41:45 +0300
+++ gav-0.8.0/Team.h	2005-11-28 09:45:40 +0300
@@ -39,7 +39,6 @@
 
 class Team {
  private:
-  std::vector<Player *> _players;
   int _xmin;
   int _xmax;
   int _ymin;
@@ -59,6 +58,7 @@
  }
 
  public:
+   std::vector<Player *> _players;
   // side < 0: left, > 0 right
   Team(int side = -1) : _side(side) {
     _score = 0;
diff -urN gav-0.8.0.orig/Theme.cpp gav-0.8.0/Theme.cpp
--- gav-0.8.0.orig/Theme.cpp	2005-11-28 09:41:45 +0300
+++ gav-0.8.0/Theme.cpp	2005-11-28 09:45:40 +0300
@@ -44,14 +44,18 @@
 
     _hasConfFile = true;
 #ifndef WIN32
-    cerr << "Verifying Theme `" << _name << "' [" << ThemeDir << "/" << _name << "/]:\n";
+
     if ( access(_CCS(_background), R_OK) ) {
+
       if (!_bigBackground)
 	_background = TD + TH_BACKGROUND_JPG;
       else
 	_background = TD + TH_BACKGROUND_BIG_JPG;
+
       if ( access(_CCS(_background), R_OK) ) errorOn("background.{jpg,png}");
+
     }
+
     if ( access(_CCS(_font), R_OK) )        errorOn(TH_FONT);
     if ( access(_CCS(_fontinv), R_OK) )     errorOn(TH_FONTINV);
     if ( access(_CCS(_leftmale), R_OK) )    errorOn(TH_LEFTMALE);
@@ -65,7 +69,6 @@
 #else
     struct _stat sStat ;
     
-    cerr << "Verifying Theme `" << _name << "' [" << ThemeDir << "\\" << _name << "\\]:\n";
     if (_stat (_background.c_str(), &sStat)) {
       if (!_bigBackground)
 	_background = TD + TH_BACKGROUND_JPG;
@@ -78,7 +81,7 @@
     if (_stat (_fontinv.c_str(), &sStat))			errorOn (TH_FONTINV) ;
     if (_stat (_leftmale.c_str(), &sStat))			errorOn (TH_LEFTMALE) ;
     if (_stat (_rightmale.c_str(), &sStat))			errorOn (TH_RIGHTMALE) ;
-    if (_stat (_leftfemale.c_str(), &sStat))		errorOn (TH_LEFTFEMALE) ;
+    if (_stat (_leftfemale.c_str(), &sStat))	        	errorOn (TH_LEFTFEMALE) ;
     if (_stat (_rightfemale.c_str(), &sStat))		errorOn (TH_RIGHTFEMALE) ;
     if (_stat (_ball.c_str(), &sStat))				errorOn (TH_BALL) ;
     
@@ -86,17 +89,15 @@
 
     r = (_stat (_net.c_str(), &sStat) == 0) ;
 #endif /* WIN32 */
+   
     
-    if ( !r ) cerr << "Warning: No net for this theme!\n";
-
-    cerr << "OK!\n";
+ //  if ( !r ) cerr << "No net for this theme!\n";
 
     configuration.setDefaultFrameConf();
     if ( _hasConfFile ) {
-      cerr << "Using configuration file theme.conf\n";
       loadConf();
     } else {
-      cerr << "No theme.conf\n";
+ //     cerr << "No theme.conf\n";
     }
 
     return(r);
diff -urN gav-0.8.0.orig/Theme.h gav-0.8.0/Theme.h
--- gav-0.8.0.orig/Theme.h	2005-11-28 09:41:45 +0300
+++ gav-0.8.0/Theme.h	2005-11-28 09:45:40 +0300
@@ -59,7 +59,6 @@
 
 class Theme {
 private:
-  std::string _name;
   bool _hasnet; // To possibly add the image of the net (not used yet)
   std::string _background;
   std::string _net;
@@ -73,25 +72,27 @@
   std::string _confFile;
   std::string TD;
   bool _hasConfFile;
-  bool _bigBackground;
   bool _checkTheme(); // Theme Validation
     
  public:
+    bool _bigBackground; 
+    std::string _name;
+    
     Theme(std::string name) {
 #ifndef WIN32
       DIR *dir;
+      ThemeDir="themes";
+      
       if ((dir = opendir(ThemeDir.c_str())) == NULL) {
 	ThemeDir = "/usr/share/games/gav/" + ThemeDir;
 	if ((dir = opendir(ThemeDir.c_str())) == NULL) {
-	  std::cerr << "Cannot find themes directory\n";
+	//  std::cerr << "Cannot find themes directory\n [" << ThemeDir << "] \n";
 	  exit(0);
 	} else
 	  closedir(dir);
       } else
 	closedir(dir);
-
-      TD = ThemeDir + "/" + name +  "/";
-
+    
 #else
       HANDLE hFindFile ;
       WIN32_FIND_DATA ffdData ;
@@ -99,7 +100,7 @@
       hFindFile = FindFirstFile (ThemeDir.c_str(), &ffdData) ;
       if (hFindFile == INVALID_HANDLE_VALUE)
 	{
-	  std::cerr << "Cannot find themes directory\n" ;
+	//  std::cerr << "Cannot find themes directory\n" ;
 	  exit(0) ;
 	}
       
@@ -108,8 +109,10 @@
       TD = ThemeDir + "\\" + name + "\\" ;
       
 #endif /* WIN32 */
-      
+
       _name = name;
+      
+      TD=ThemeDir+"/"+name+"/";
 
       _bigBackground = configuration.bgBig;
       
@@ -119,7 +122,7 @@
 	_background = TD + TH_BACKGROUND_PNG;
       else
 	_background = TD + TH_BACKGROUND_BIG_PNG;
-      
+
       _font    = TD + TH_FONT;
       _fontinv = TD + TH_FONTINV;
       
@@ -131,8 +134,8 @@
       
       _ball = TD + TH_BALL;
       
-      _hasnet = Theme::_checkTheme();
-      
+     _hasnet = Theme::_checkTheme();
+  
       ::background = IMG_Load(background());
       //if ( CurrentTheme->hasnet() ) IMG_Load(CurrentTheme->net());
       
@@ -157,7 +160,6 @@
 			      (ThemeDir+"/../sounds").c_str());
 #endif // AUDIO
     }
-  
   ~Theme() {
     SDL_FreeSurface(::background);
     delete(cga);
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin