# HG changeset patch # User unc0rr # Date 1267873160 0 # Node ID 3f21a9dc93d00a2686271973055f5676f7eacaad # Parent 803b277e48942559e6211b6d5ec490271a27dbaa Replace tabs with spaces using 'expand -t 4' command diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/AutoUpdater.h --- a/QTfrontend/AutoUpdater.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/AutoUpdater.h Sat Mar 06 10:59:20 2010 +0000 @@ -7,10 +7,10 @@ class AutoUpdater { - public: - virtual ~AutoUpdater(); + public: + virtual ~AutoUpdater(); - virtual void checkForUpdates() = 0; + virtual void checkForUpdates() = 0; }; #endif diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/CocoaInitializer.h --- a/QTfrontend/CocoaInitializer.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/CocoaInitializer.h Sat Mar 06 10:59:20 2010 +0000 @@ -7,13 +7,13 @@ class CocoaInitializer { - public: - CocoaInitializer(); - ~CocoaInitializer(); + public: + CocoaInitializer(); + ~CocoaInitializer(); - private: - class Private; - Private* d; + private: + class Private; + Private* d; Private* c; }; diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/InstallController.h --- a/QTfrontend/InstallController.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/InstallController.h Sat Mar 06 10:59:20 2010 +0000 @@ -12,10 +12,10 @@ class InstallController { - public: - virtual ~InstallController(); + public: + virtual ~InstallController(); - virtual void showInstallController() = 0; + virtual void showInstallController() = 0; }; #endif \ No newline at end of file diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/KB.h --- a/QTfrontend/KB.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/KB.h Sat Mar 06 10:59:20 2010 +0000 @@ -25,10 +25,10 @@ const QString KBMessages[KBmsgsCount] = { - QT_TRANSLATE_NOOP("KB", "SDL_ttf returned error while rendering text, " - "most propably it is related to the bug " - "in freetype2. It's recommended to update your " - "freetype lib.") + QT_TRANSLATE_NOOP("KB", "SDL_ttf returned error while rendering text, " + "most propably it is related to the bug " + "in freetype2. It's recommended to update your " + "freetype lib.") }; #endif // KB_H diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/M3InstallController.h --- a/QTfrontend/M3InstallController.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/M3InstallController.h Sat Mar 06 10:59:20 2010 +0000 @@ -43,7 +43,7 @@ @interface M3InstallController : NSObject { - NSAlert *alert; + NSAlert *alert; } - (void)displayInstaller; diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/M3Panel.h --- a/QTfrontend/M3Panel.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/M3Panel.h Sat Mar 06 10:59:20 2010 +0000 @@ -14,15 +14,15 @@ class M3Panel : public InstallController { - public: - M3Panel(void); - ~M3Panel(); + public: + M3Panel(void); + ~M3Panel(); - void showInstallController(); + void showInstallController(); - private: - class Private; - Private* c; + private: + class Private; + Private* c; }; #endif diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/NSWorkspace_RBAdditions.h --- a/QTfrontend/NSWorkspace_RBAdditions.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/NSWorkspace_RBAdditions.h Sat Mar 06 10:59:20 2010 +0000 @@ -24,11 +24,11 @@ //- NSWorkspace_RBfstypename: will always be present.Shows the filesystem type (usually "hfs"), from statfs. //- NSWorkspace_RBmntonname: will always be present. Shows the volume mount point. //- NSWorkspace_RBmntfromname: will always be present. Shows the BSD device path for local volumes; info for -// remote volumes depends on the filesystem type. +// remote volumes depends on the filesystem type. //- NSWorkspace_RBconnectiontype: should always be present for local volumes. Shows the connection type ("SATA", "USB", etc.). //- NSWorkspace_RBpartitionscheme: should always be present for local volumes. Shows the partition scheme. //- NSWorkspace_RBdeviceinfo: should always be present for local volumes. Shows some information about the -// physical device; varies widely. +// physical device; varies widely. //- NSWorkspace_RBimagefilepath: should be present for disk images only. Shows the path of the disk image file. //- NSWorkspace_RBserverURL: should be present for remote volumes only. Shows the server URL. diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/SDLs.cpp --- a/QTfrontend/SDLs.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/SDLs.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -34,152 +34,152 @@ SDLInteraction::SDLInteraction() { - SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK); - - musicInitialized = 0; - music = NULL; - if(SDL_NumJoysticks()) - addGameControllerKeys(); - SDL_QuitSubSystem(SDL_INIT_JOYSTICK); + SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK); + + musicInitialized = 0; + music = NULL; + if(SDL_NumJoysticks()) + addGameControllerKeys(); + SDL_QuitSubSystem(SDL_INIT_JOYSTICK); } SDLInteraction::~SDLInteraction() { - if (musicInitialized == 1) { - if (music != NULL) - Mix_FreeMusic(music); - Mix_CloseAudio(); - } - SDL_Quit(); + if (musicInitialized == 1) { + if (music != NULL) + Mix_FreeMusic(music); + Mix_CloseAudio(); + } + SDL_Quit(); } QStringList SDLInteraction::getResolutions() const { - QStringList result; + QStringList result; - SDL_Rect **modes; + SDL_Rect **modes; - modes = SDL_ListModes(NULL, SDL_FULLSCREEN); + modes = SDL_ListModes(NULL, SDL_FULLSCREEN); - if((modes == (SDL_Rect **)0) || (modes == (SDL_Rect **)-1)) - { - result << "640x480"; - } else - { - for(int i = 0; modes[i]; ++i) - if ((modes[i]->w >= 640) && (modes[i]->h >= 480)) - result << QString("%1x%2").arg(modes[i]->w).arg(modes[i]->h); - } + if((modes == (SDL_Rect **)0) || (modes == (SDL_Rect **)-1)) + { + result << "640x480"; + } else + { + for(int i = 0; modes[i]; ++i) + if ((modes[i]->w >= 640) && (modes[i]->h >= 480)) + result << QString("%1x%2").arg(modes[i]->w).arg(modes[i]->h); + } - return result; + return result; } void SDLInteraction::addGameControllerKeys() const { - QStringList result; + QStringList result; - int i = 0; - while(i < 1024 && sdlkeys[i][1][0] != '\0') - i++; + int i = 0; + while(i < 1024 && sdlkeys[i][1][0] != '\0') + i++; - // Iterate through all game controllers - for(int jid = 0; jid < SDL_NumJoysticks(); jid++) - { - SDL_Joystick* joy = SDL_JoystickOpen(jid); - - // Retrieve the game controller's name and strip "Controller (...)" that's added by some drivers (English only) - QString joyname = QString(SDL_JoystickName(jid)).replace(QRegExp("^Controller \\((.*)\\)$"), "\\1"); + // Iterate through all game controllers + for(int jid = 0; jid < SDL_NumJoysticks(); jid++) + { + SDL_Joystick* joy = SDL_JoystickOpen(jid); + + // Retrieve the game controller's name and strip "Controller (...)" that's added by some drivers (English only) + QString joyname = QString(SDL_JoystickName(jid)).replace(QRegExp("^Controller \\((.*)\\)$"), "\\1"); - // Connected Xbox 360 controller? Use specific button names then - // Might be interesting to add 'named' buttons for the most often used gamepads - bool isxb = joyname.contains("Xbox 360"); + // Connected Xbox 360 controller? Use specific button names then + // Might be interesting to add 'named' buttons for the most often used gamepads + bool isxb = joyname.contains("Xbox 360"); - // This part of the string won't change for multiple keys/hats, so keep it - QString prefix = QString("%1 (%2): ").arg(joyname).arg(jid + 1); + // This part of the string won't change for multiple keys/hats, so keep it + QString prefix = QString("%1 (%2): ").arg(joyname).arg(jid + 1); - // Register entries for missing axes not assigned to sticks of this joystick/gamepad - for(int aid = 0; aid < SDL_JoystickNumAxes(joy) && i < 1021; aid++) - { - // Again store the part of the string not changing for multiple uses - QString axis = prefix + QApplication::translate("binds (keys)", "Axis") + QString(" %1 ").arg(aid + 1); - - // Entry for "Axis Up" - sprintf(sdlkeys[i][0], "j%da%du", jid, aid); - sprintf(sdlkeys[i++][1], "%s", ((isxb && aid < 5) ? (prefix + QApplication::translate("binds (keys)", xbox360axes[aid * 2])) : axis + QApplication::translate("binds (keys)", "(Up)")).toStdString().c_str()); + // Register entries for missing axes not assigned to sticks of this joystick/gamepad + for(int aid = 0; aid < SDL_JoystickNumAxes(joy) && i < 1021; aid++) + { + // Again store the part of the string not changing for multiple uses + QString axis = prefix + QApplication::translate("binds (keys)", "Axis") + QString(" %1 ").arg(aid + 1); + + // Entry for "Axis Up" + sprintf(sdlkeys[i][0], "j%da%du", jid, aid); + sprintf(sdlkeys[i++][1], "%s", ((isxb && aid < 5) ? (prefix + QApplication::translate("binds (keys)", xbox360axes[aid * 2])) : axis + QApplication::translate("binds (keys)", "(Up)")).toStdString().c_str()); - // Entry for "Axis Down" - sprintf(sdlkeys[i][0], "j%da%dd", jid, aid); - sprintf(sdlkeys[i++][1], "%s", ((isxb && aid < 5) ? (prefix + QApplication::translate("binds (keys)", xbox360axes[aid * 2 + 1])) : axis + QApplication::translate("binds (keys)", "(Down)")).toStdString().c_str()); - } + // Entry for "Axis Down" + sprintf(sdlkeys[i][0], "j%da%dd", jid, aid); + sprintf(sdlkeys[i++][1], "%s", ((isxb && aid < 5) ? (prefix + QApplication::translate("binds (keys)", xbox360axes[aid * 2 + 1])) : axis + QApplication::translate("binds (keys)", "(Down)")).toStdString().c_str()); + } - // Register entries for all coolie hats of this joystick/gamepad - for(int hid = 0; hid < SDL_JoystickNumHats(joy) && i < 1019; hid++) - { - // Again store the part of the string not changing for multiple uses - QString hat = prefix + (isxb ? (QApplication::translate("binds (keys)", xb360dpad) + QString(" ")) : QApplication::translate("binds (keys)", "Hat") + QString(" %1 ").arg(hid + 1)); + // Register entries for all coolie hats of this joystick/gamepad + for(int hid = 0; hid < SDL_JoystickNumHats(joy) && i < 1019; hid++) + { + // Again store the part of the string not changing for multiple uses + QString hat = prefix + (isxb ? (QApplication::translate("binds (keys)", xb360dpad) + QString(" ")) : QApplication::translate("binds (keys)", "Hat") + QString(" %1 ").arg(hid + 1)); - // Entry for "Hat Up" - sprintf(sdlkeys[i][0], "j%dh%du", jid, hid); - sprintf(sdlkeys[i++][1], "%s", (hat + QApplication::translate("binds (keys)", "(Up)")).toStdString().c_str()); + // Entry for "Hat Up" + sprintf(sdlkeys[i][0], "j%dh%du", jid, hid); + sprintf(sdlkeys[i++][1], "%s", (hat + QApplication::translate("binds (keys)", "(Up)")).toStdString().c_str()); - // Entry for "Hat Down" - sprintf(sdlkeys[i][0], "j%dh%dd", jid, hid); - sprintf(sdlkeys[i++][1], "%s", (hat + QApplication::translate("binds (keys)", "(Down)")).toStdString().c_str()); + // Entry for "Hat Down" + sprintf(sdlkeys[i][0], "j%dh%dd", jid, hid); + sprintf(sdlkeys[i++][1], "%s", (hat + QApplication::translate("binds (keys)", "(Down)")).toStdString().c_str()); - // Entry for "Hat Left" - sprintf(sdlkeys[i][0], "j%dh%dl", jid, hid); - sprintf(sdlkeys[i++][1], "%s", (hat + QApplication::translate("binds (keys)", "(Left)")).toStdString().c_str()); + // Entry for "Hat Left" + sprintf(sdlkeys[i][0], "j%dh%dl", jid, hid); + sprintf(sdlkeys[i++][1], "%s", (hat + QApplication::translate("binds (keys)", "(Left)")).toStdString().c_str()); - // Entry for "Hat Right" - sprintf(sdlkeys[i][0], "j%dh%dr", jid, hid); - sprintf(sdlkeys[i++][1], "%s", (hat + QApplication::translate("binds (keys)", "(Right)")).toStdString().c_str()); - } - - // Register entries for all buttons of this joystick/gamepad - for(int bid = 0; bid < SDL_JoystickNumButtons(joy) && i < 1022; bid++) - { - // Buttons - sprintf(sdlkeys[i][0], "j%db%d", jid, bid); - sprintf(sdlkeys[i++][1], "%s", (prefix + ((isxb && bid < 10) ? (QApplication::translate("binds (keys)", xb360buttons[bid]) + QString(" ")) : QApplication::translate("binds (keys)", "Button") + QString(" %1").arg(bid + 1))).toStdString().c_str()); - } - // Close the game controller as we no longer need it - SDL_JoystickClose(joy); - } - - // Terminate the list - sdlkeys[i][0][0] = '\0'; - sdlkeys[i][1][0] = '\0'; + // Entry for "Hat Right" + sprintf(sdlkeys[i][0], "j%dh%dr", jid, hid); + sprintf(sdlkeys[i++][1], "%s", (hat + QApplication::translate("binds (keys)", "(Right)")).toStdString().c_str()); + } + + // Register entries for all buttons of this joystick/gamepad + for(int bid = 0; bid < SDL_JoystickNumButtons(joy) && i < 1022; bid++) + { + // Buttons + sprintf(sdlkeys[i][0], "j%db%d", jid, bid); + sprintf(sdlkeys[i++][1], "%s", (prefix + ((isxb && bid < 10) ? (QApplication::translate("binds (keys)", xb360buttons[bid]) + QString(" ")) : QApplication::translate("binds (keys)", "Button") + QString(" %1").arg(bid + 1))).toStdString().c_str()); + } + // Close the game controller as we no longer need it + SDL_JoystickClose(joy); + } + + // Terminate the list + sdlkeys[i][0][0] = '\0'; + sdlkeys[i][1][0] = '\0'; } void SDLInteraction::SDLMusicInit() { - if (musicInitialized == 0) { - SDL_Init(SDL_INIT_AUDIO); - Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024); - musicInitialized = 1; - } + if (musicInitialized == 0) { + SDL_Init(SDL_INIT_AUDIO); + Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024); + musicInitialized = 1; + } } void SDLInteraction::StartMusic() { - SDLMusicInit(); + SDLMusicInit(); - if (music == NULL) { - music = Mix_LoadMUS((datadir->absolutePath() + "/Music/main theme.ogg").toLocal8Bit().constData()); - - } - Mix_VolumeMusic(MIX_MAX_VOLUME - 28); - Mix_FadeInMusic(music, -1, 1750); + if (music == NULL) { + music = Mix_LoadMUS((datadir->absolutePath() + "/Music/main theme.ogg").toLocal8Bit().constData()); + + } + Mix_VolumeMusic(MIX_MAX_VOLUME - 28); + Mix_FadeInMusic(music, -1, 1750); } void SDLInteraction::StopMusic() { - if (music != NULL) { - // fade out music to finish 0,5 seconds from now - while(!Mix_FadeOutMusic(1000) && Mix_PlayingMusic()) { - SDL_Delay(100); - } - } + if (music != NULL) { + // fade out music to finish 0,5 seconds from now + while(!Mix_FadeOutMusic(1000) && Mix_PlayingMusic()) { + SDL_Delay(100); + } + } } diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/SDLs.h --- a/QTfrontend/SDLs.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/SDLs.h Sat Mar 06 10:59:20 2010 +0000 @@ -28,20 +28,20 @@ class SDLInteraction : public QObject { - Q_OBJECT + Q_OBJECT private: - Mix_Music *music; - int musicInitialized; + Mix_Music *music; + int musicInitialized; public: - SDLInteraction(); - ~SDLInteraction(); - QStringList getResolutions() const; - void addGameControllerKeys() const; - void StartMusic(); - void StopMusic(); - void SDLMusicInit(); + SDLInteraction(); + ~SDLInteraction(); + QStringList getResolutions() const; + void addGameControllerKeys() const; + void StartMusic(); + void StopMusic(); + void SDLMusicInit(); }; diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/SparkleAutoUpdater.h --- a/QTfrontend/SparkleAutoUpdater.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/SparkleAutoUpdater.h Sat Mar 06 10:59:20 2010 +0000 @@ -11,15 +11,15 @@ class SparkleAutoUpdater : public AutoUpdater { - public: - SparkleAutoUpdater(const QString& url); - ~SparkleAutoUpdater(); + public: + SparkleAutoUpdater(const QString& url); + ~SparkleAutoUpdater(); - void checkForUpdates(); + void checkForUpdates(); - private: - class Private; - Private* d; + private: + class Private; + Private* d; }; #endif diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/SquareLabel.cpp --- a/QTfrontend/SquareLabel.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/SquareLabel.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -22,27 +22,27 @@ #include "hwform.h" SquareLabel::SquareLabel(QWidget * parent) : - QWidget(parent) + QWidget(parent) { if(frontendEffects) setAttribute(Qt::WA_PaintOnScreen, true); } void SquareLabel::paintEvent(QPaintEvent * event) { - QPainter painter(this); - int pixsize; - if (width() > height()) { - pixsize = height(); - painter.translate((width() - pixsize) / 2, 0); - } else { - pixsize = width(); - painter.translate(0, (height() - pixsize) / 2); - } - painter.drawPixmap(0, 0, pixsize, pixsize, pixmap.scaled(pixsize, pixsize, Qt::KeepAspectRatio)); + QPainter painter(this); + int pixsize; + if (width() > height()) { + pixsize = height(); + painter.translate((width() - pixsize) / 2, 0); + } else { + pixsize = width(); + painter.translate(0, (height() - pixsize) / 2); + } + painter.drawPixmap(0, 0, pixsize, pixsize, pixmap.scaled(pixsize, pixsize, Qt::KeepAspectRatio)); } void SquareLabel::setPixmap(const QPixmap & pixmap) { - this->pixmap = pixmap; - repaint(); + this->pixmap = pixmap; + repaint(); } diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/SquareLabel.h --- a/QTfrontend/SquareLabel.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/SquareLabel.h Sat Mar 06 10:59:20 2010 +0000 @@ -24,17 +24,17 @@ class SquareLabel : public QWidget { - Q_OBJECT + Q_OBJECT public: - SquareLabel(QWidget * parent = 0); + SquareLabel(QWidget * parent = 0); - void setPixmap(const QPixmap & pixmap); + void setPixmap(const QPixmap & pixmap); protected: - virtual void paintEvent(QPaintEvent * event); + virtual void paintEvent(QPaintEvent * event); private: - QPixmap pixmap; + QPixmap pixmap; }; diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/about.cpp --- a/QTfrontend/about.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/about.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -25,7 +25,7 @@ About::About(QWidget * parent) : QWidget(parent) { - QGridLayout *mainLayout = new QGridLayout(this); + QGridLayout *mainLayout = new QGridLayout(this); QLabel *imageLabel = new QLabel; QImage image(":/res/Hedgehog.png"); @@ -38,97 +38,97 @@ imageLabel->setMaximumHeight(300); mainLayout->addWidget(imageLabel, 0, 0, 2, 1); - QLabel *lbl1 = new QLabel(this); + QLabel *lbl1 = new QLabel(this); - lbl1->setOpenExternalLinks(true); - lbl1->setText( + lbl1->setOpenExternalLinks(true); + lbl1->setText( "" - "

Hedgewars

" - "

" + QLabel::tr("Version") + " " + *cVersionString + "

" - "

http://www.hedgewars.org/


" + - QLabel::tr("This program is distributed under the GNU General Public License") + - "
" - ); - lbl1->setWordWrap(true); - mainLayout->addWidget(lbl1, 0, 1); + "

Hedgewars

" + "

" + QLabel::tr("Version") + " " + *cVersionString + "

" + "

http://www.hedgewars.org/


" + + QLabel::tr("This program is distributed under the GNU General Public License") + + "
" + ); + lbl1->setWordWrap(true); + mainLayout->addWidget(lbl1, 0, 1); - QTextBrowser *lbl2 = new QTextBrowser(this); + QTextBrowser *lbl2 = new QTextBrowser(this); - lbl2->setOpenExternalLinks(true); - lbl2->setText( + lbl2->setOpenExternalLinks(true); + lbl2->setText( "" + QString("

") + - QLabel::tr("Developers:") + - "

" - "Engine, frontend, net server: Andrey Korotaev <unC0Rr@gmail.com>
" - "Many frontend improvements: Igor Ulyanov <disinbox@gmail.com>
" - "Many engine and frontend improvements: Derek Pomery <nemo@m8y.org>
" - "Drill rocket, Ballgun, RC Plane weapons: Martin Boze <afffect@gmail.com>
" - "Mine number and time game settings: David A. Cuadrado <krawek@gmail.com>
" - "Frontend improvements: Martin Minarik <ttsmj@pokec.sk>
" - "Frontend improvements: Kristian Lehmann <email@thexception.net>
" - "Mac OS X port, OpenAL wrapper library: Vittorio Giovara <vittorio.giovara@gmail.com>
" - "Gamepad support and additional effects: Mario Liebisch <mario.liebisch@googlemail.com>" - "

" + + QLabel::tr("Developers:") + + "

" + "Engine, frontend, net server: Andrey Korotaev <unC0Rr@gmail.com>
" + "Many frontend improvements: Igor Ulyanov <disinbox@gmail.com>
" + "Many engine and frontend improvements: Derek Pomery <nemo@m8y.org>
" + "Drill rocket, Ballgun, RC Plane weapons: Martin Boze <afffect@gmail.com>
" + "Mine number and time game settings: David A. Cuadrado <krawek@gmail.com>
" + "Frontend improvements: Martin Minarik <ttsmj@pokec.sk>
" + "Frontend improvements: Kristian Lehmann <email@thexception.net>
" + "Mac OS X port, OpenAL wrapper library: Vittorio Giovara <vittorio.giovara@gmail.com>
" + "Gamepad support and additional effects: Mario Liebisch <mario.liebisch@googlemail.com>" + "

" + - QLabel::tr("Art:") + "

" - + QString::fromUtf8( - "

Finn Brice <tiyuri@gmail.com>" - "
" - "Joshua Frese <joshfrese@gmail.com>" - "
" - "Stanko Tadić <stanko@mfhinc.net>" - "
" - "Julien Koesten <julienkoesten@aol.com>" - "
" - "Joshua O'Sullivan <battysausage@hotmail.co.uk>" - "
" - "Nils Lück <nils.luck.design@gmail.com>" - "
" - "Hats: Trey Perry <tx.perry.j@gmail.com>" - "

") + - QLabel::tr("Sounds:") + "

" - "Hedgehogs voice: Stephen Alexander <ArmagonNo1@gmail.com>" - "
" - "Finn Brice <tiyuri@gmail.com>" - "
" - "Jonatan Nilsson <jonatanfan@gmail.com>" - "
" - "Daniel Martin <elhombresinremedio@gmail.com>" - "

" + + QLabel::tr("Art:") + "

" + + QString::fromUtf8( + "

Finn Brice <tiyuri@gmail.com>" + "
" + "Joshua Frese <joshfrese@gmail.com>" + "
" + "Stanko Tadić <stanko@mfhinc.net>" + "
" + "Julien Koesten <julienkoesten@aol.com>" + "
" + "Joshua O'Sullivan <battysausage@hotmail.co.uk>" + "
" + "Nils Lück <nils.luck.design@gmail.com>" + "
" + "Hats: Trey Perry <tx.perry.j@gmail.com>" + "

") + + QLabel::tr("Sounds:") + "

" + "Hedgehogs voice: Stephen Alexander <ArmagonNo1@gmail.com>" + "
" + "Finn Brice <tiyuri@gmail.com>" + "
" + "Jonatan Nilsson <jonatanfan@gmail.com>" + "
" + "Daniel Martin <elhombresinremedio@gmail.com>" + "

" + - QLabel::tr("Translations:") + "

" - + QString::fromUtf8( - "Brazilian Portuguese: Romulo Fernandes Machado <abra185@gmail.com>
" - "Bulgarian: Svetoslav Stefanov
" - "Czech: Petr Řezáček <rezacek@gmail.com>
" - "Chinese: Jie Luo <lililjlj@gmail.com>
" - "English: Andrey Korotaev <unC0Rr@gmail.com>
" - "Finnish: Nina Kuisma <ninnnu@gmail.com>
" - "French: Antoine Turmel <geekshadow@gmail.com>
" - "German: Peter Hüwe <PeterHuewe@gmx.de>
" - "Italian: Luca Bonora <bonora.luca@gmail.com>
" - "Japanese: ADAM Etienne <etienne.adam@gmail.com>
" - "Polish: Maciej Mroziński <mynick2@o2.pl>, Wojciech Latkowski <magik_15l@poczta.fm>, Maciej Górny
" - "Russian: Andrey Korotaev <unC0Rr@gmail.com>
" - "Slovak: Jose Riha
" - "Spanish: Carlos Vives <mail@carlosvives.es>
" - "Swedish: Niklas Grahn <raewolusjoon@yaoo.com>
" - "Ukrainian: Eugene V. Lyubimkin <jackyf.devel@gmail.com>" - "

") + + QLabel::tr("Translations:") + "

" + + QString::fromUtf8( + "Brazilian Portuguese: Romulo Fernandes Machado <abra185@gmail.com>
" + "Bulgarian: Svetoslav Stefanov
" + "Czech: Petr Řezáček <rezacek@gmail.com>
" + "Chinese: Jie Luo <lililjlj@gmail.com>
" + "English: Andrey Korotaev <unC0Rr@gmail.com>
" + "Finnish: Nina Kuisma <ninnnu@gmail.com>
" + "French: Antoine Turmel <geekshadow@gmail.com>
" + "German: Peter Hüwe <PeterHuewe@gmx.de>
" + "Italian: Luca Bonora <bonora.luca@gmail.com>
" + "Japanese: ADAM Etienne <etienne.adam@gmail.com>
" + "Polish: Maciej Mroziński <mynick2@o2.pl>, Wojciech Latkowski <magik_15l@poczta.fm>, Maciej Górny
" + "Russian: Andrey Korotaev <unC0Rr@gmail.com>
" + "Slovak: Jose Riha
" + "Spanish: Carlos Vives <mail@carlosvives.es>
" + "Swedish: Niklas Grahn <raewolusjoon@yaoo.com>
" + "Ukrainian: Eugene V. Lyubimkin <jackyf.devel@gmail.com>" + "

") + - QLabel::tr("Special thanks:") + "

" - "Aleksey Andreev <blaknayabr@gmail.com>
" - "Aleksander Rudalev <alexv@pomorsu.ru>
" - "Natasha Stafeeva <layout@pisem.net>
" - "Adam Higerd (aka ahigerd at FreeNode)" - "

" - ); - mainLayout->addWidget(lbl2, 1, 1); + QLabel::tr("Special thanks:") + "

" + "Aleksey Andreev <blaknayabr@gmail.com>
" + "Aleksander Rudalev <alexv@pomorsu.ru>
" + "Natasha Stafeeva <layout@pisem.net>
" + "Adam Higerd (aka ahigerd at FreeNode)" + "

" + ); + mainLayout->addWidget(lbl2, 1, 1); } diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/about.h --- a/QTfrontend/about.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/about.h Sat Mar 06 10:59:20 2010 +0000 @@ -24,10 +24,10 @@ class About : public QWidget { - Q_OBJECT + Q_OBJECT public: - About(QWidget * parent = 0); + About(QWidget * parent = 0); }; #endif // _ABOUT_H diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/ammoSchemeModel.cpp --- a/QTfrontend/ammoSchemeModel.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/ammoSchemeModel.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -23,370 +23,370 @@ #include "hwconsts.h" QList defaultScheme = QList() - << QVariant("Default") // name 0 - << QVariant(false) // fortsmode 1 - << QVariant(false) // team divide 2 - << QVariant(false) // solid land 3 - << QVariant(false) // border 4 - << QVariant(false) // low gravity 5 - << QVariant(false) // laser sight 6 - << QVariant(false) // invulnerable 7 - << QVariant(true) // add mines 8 - << QVariant(false) // vampiric 9 - << QVariant(false) // karma 10 - << QVariant(false) // artillery 11 - << QVariant(true) // random order 12 - << QVariant(false) // king 13 - << QVariant(false) // place hog 14 - << QVariant(false) // shared ammo 15 - << QVariant(false) //disable girders 16 - << QVariant(100) // damage modfier 17 - << QVariant(45) // turn time 18 - << QVariant(100) // init health 19 - << QVariant(15) // sudden death 20 - << QVariant(5) // case prob 21 - << QVariant(3) // mines time 22 - << QVariant(4) // landadds 23 - << QVariant(0) // mine dud pct 24 - << QVariant(2) // explosives 25 - ; + << QVariant("Default") // name 0 + << QVariant(false) // fortsmode 1 + << QVariant(false) // team divide 2 + << QVariant(false) // solid land 3 + << QVariant(false) // border 4 + << QVariant(false) // low gravity 5 + << QVariant(false) // laser sight 6 + << QVariant(false) // invulnerable 7 + << QVariant(true) // add mines 8 + << QVariant(false) // vampiric 9 + << QVariant(false) // karma 10 + << QVariant(false) // artillery 11 + << QVariant(true) // random order 12 + << QVariant(false) // king 13 + << QVariant(false) // place hog 14 + << QVariant(false) // shared ammo 15 + << QVariant(false) //disable girders 16 + << QVariant(100) // damage modfier 17 + << QVariant(45) // turn time 18 + << QVariant(100) // init health 19 + << QVariant(15) // sudden death 20 + << QVariant(5) // case prob 21 + << QVariant(3) // mines time 22 + << QVariant(4) // landadds 23 + << QVariant(0) // mine dud pct 24 + << QVariant(2) // explosives 25 + ; AmmoSchemeModel::AmmoSchemeModel(QObject* parent, const QString & fileName) : - QAbstractTableModel(parent), - numberOfDefaultSchemes(4), - fileConfig(fileName, QSettings::IniFormat) + QAbstractTableModel(parent), + numberOfDefaultSchemes(4), + fileConfig(fileName, QSettings::IniFormat) { - QStringList predefSchemesNames; - predefSchemesNames - << "Default" - << "Pro mode" - << "Shoppa" - << "Basketball" - << "Minefield"; + QStringList predefSchemesNames; + predefSchemesNames + << "Default" + << "Pro mode" + << "Shoppa" + << "Basketball" + << "Minefield"; - spNames = QStringList() - << "name" // 0 - << "fortsmode" // 1 - << "divteams" // 2 - << "solidland" // 3 - << "border" // 4 - << "lowgrav" // 5 - << "laser" // 6 - << "invulnerability" // 7 - << "mines" // 8 - << "vampiric" // 9 - << "karma" // 10 - << "artillery" // 11 - << "randomorder" // 12 - << "king" // 13 - << "placehog" // 14 - << "sharedammo" // 15 - << "disablegirders" // 16 - << "damagefactor" // 17 - << "turntime" // 18 - << "health" // 19 - << "suddendeath" // 20 - << "caseprobability" // 21 - << "minestime" // 22 - << "landadds" // 23 - << "minedudpct" // 24 - << "explosives" // 25 - ; + spNames = QStringList() + << "name" // 0 + << "fortsmode" // 1 + << "divteams" // 2 + << "solidland" // 3 + << "border" // 4 + << "lowgrav" // 5 + << "laser" // 6 + << "invulnerability" // 7 + << "mines" // 8 + << "vampiric" // 9 + << "karma" // 10 + << "artillery" // 11 + << "randomorder" // 12 + << "king" // 13 + << "placehog" // 14 + << "sharedammo" // 15 + << "disablegirders" // 16 + << "damagefactor" // 17 + << "turntime" // 18 + << "health" // 19 + << "suddendeath" // 20 + << "caseprobability" // 21 + << "minestime" // 22 + << "landadds" // 23 + << "minedudpct" // 24 + << "explosives" // 25 + ; - QList proMode; - proMode - << predefSchemesNames[1] // name 0 - << QVariant(false) // fortsmode 1 - << QVariant(false) // team divide 2 - << QVariant(false) // solid land 3 - << QVariant(false) // border 4 - << QVariant(false) // low gravity 5 - << QVariant(false) // laser sight 6 - << QVariant(false) // invulnerable 7 - << QVariant(false) // add mines 8 - << QVariant(false) // vampiric 9 - << QVariant(false) // karma 10 - << QVariant(false) // artillery 11 - << QVariant(true) // random order 12 - << QVariant(false) // king 13 - << QVariant(false) // place hog 14 - << QVariant(true) // shared ammo 15 - << QVariant(false) //disable girders 16 - << QVariant(100) // damage modfier 17 - << QVariant(15) // turn time 18 - << QVariant(100) // init health 19 - << QVariant(15) // sudden death 20 - << QVariant(0) // case prob 21 - << QVariant(3) // mines time 22 - << QVariant(4) // landadds 23 - << QVariant(0) // mine dud pct 24 - << QVariant(2) // explosives 25 - ; + QList proMode; + proMode + << predefSchemesNames[1] // name 0 + << QVariant(false) // fortsmode 1 + << QVariant(false) // team divide 2 + << QVariant(false) // solid land 3 + << QVariant(false) // border 4 + << QVariant(false) // low gravity 5 + << QVariant(false) // laser sight 6 + << QVariant(false) // invulnerable 7 + << QVariant(false) // add mines 8 + << QVariant(false) // vampiric 9 + << QVariant(false) // karma 10 + << QVariant(false) // artillery 11 + << QVariant(true) // random order 12 + << QVariant(false) // king 13 + << QVariant(false) // place hog 14 + << QVariant(true) // shared ammo 15 + << QVariant(false) //disable girders 16 + << QVariant(100) // damage modfier 17 + << QVariant(15) // turn time 18 + << QVariant(100) // init health 19 + << QVariant(15) // sudden death 20 + << QVariant(0) // case prob 21 + << QVariant(3) // mines time 22 + << QVariant(4) // landadds 23 + << QVariant(0) // mine dud pct 24 + << QVariant(2) // explosives 25 + ; - QList shoppa; - shoppa - << predefSchemesNames[2] // name 0 - << QVariant(false) // fortsmode 1 - << QVariant(false) // team divide 2 - << QVariant(true) // solid land 3 - << QVariant(true) // border 4 - << QVariant(false) // low gravity 5 - << QVariant(false) // laser sight 6 - << QVariant(false) // invulnerable 7 - << QVariant(false) // add mines 8 - << QVariant(false) // vampiric 9 - << QVariant(false) // karma 10 - << QVariant(false) // artillery 11 - << QVariant(true) // random order 12 - << QVariant(false) // king 13 - << QVariant(false) // place hog 14 - << QVariant(true) // shared ammo 15 - << QVariant(true) //disable girders 16 - << QVariant(100) // damage modfier 17 - << QVariant(30) // turn time 18 - << QVariant(100) // init health 19 - << QVariant(50) // sudden death 20 - << QVariant(1) // case prob 21 - << QVariant(3) // mines time 22 - << QVariant(4) // landadds 23 - << QVariant(0) // mine dud pct 24 - << QVariant(0) // explosives 25 - ; + QList shoppa; + shoppa + << predefSchemesNames[2] // name 0 + << QVariant(false) // fortsmode 1 + << QVariant(false) // team divide 2 + << QVariant(true) // solid land 3 + << QVariant(true) // border 4 + << QVariant(false) // low gravity 5 + << QVariant(false) // laser sight 6 + << QVariant(false) // invulnerable 7 + << QVariant(false) // add mines 8 + << QVariant(false) // vampiric 9 + << QVariant(false) // karma 10 + << QVariant(false) // artillery 11 + << QVariant(true) // random order 12 + << QVariant(false) // king 13 + << QVariant(false) // place hog 14 + << QVariant(true) // shared ammo 15 + << QVariant(true) //disable girders 16 + << QVariant(100) // damage modfier 17 + << QVariant(30) // turn time 18 + << QVariant(100) // init health 19 + << QVariant(50) // sudden death 20 + << QVariant(1) // case prob 21 + << QVariant(3) // mines time 22 + << QVariant(4) // landadds 23 + << QVariant(0) // mine dud pct 24 + << QVariant(0) // explosives 25 + ; - QList basketball; - basketball - << predefSchemesNames[3] // name 0 - << QVariant(false) // fortsmode 1 - << QVariant(false) // team divide 2 - << QVariant(true) // solid land 3 - << QVariant(true) // border 4 - << QVariant(true) // low gravity 5 - << QVariant(false) // laser sight 6 - << QVariant(true) // invulnerable 7 - << QVariant(false) // add mines 8 - << QVariant(false) // vampiric 9 - << QVariant(false) // karma 10 - << QVariant(false) // artillery 11 - << QVariant(true) // random order 12 - << QVariant(false) // king 13 - << QVariant(false) // place hog 14 - << QVariant(true) // shared ammo 15 - << QVariant(true) //disable girders 16 - << QVariant(100) // damage modfier 17 - << QVariant(30) // turn time 18 - << QVariant(100) // init health 19 - << QVariant(15) // sudden death 20 - << QVariant(0) // case prob 21 - << QVariant(3) // mines time 22 - << QVariant(4) // landadds 23 - << QVariant(0) // mine dud pct 24 - << QVariant(0) // explosives 25 - ; + QList basketball; + basketball + << predefSchemesNames[3] // name 0 + << QVariant(false) // fortsmode 1 + << QVariant(false) // team divide 2 + << QVariant(true) // solid land 3 + << QVariant(true) // border 4 + << QVariant(true) // low gravity 5 + << QVariant(false) // laser sight 6 + << QVariant(true) // invulnerable 7 + << QVariant(false) // add mines 8 + << QVariant(false) // vampiric 9 + << QVariant(false) // karma 10 + << QVariant(false) // artillery 11 + << QVariant(true) // random order 12 + << QVariant(false) // king 13 + << QVariant(false) // place hog 14 + << QVariant(true) // shared ammo 15 + << QVariant(true) //disable girders 16 + << QVariant(100) // damage modfier 17 + << QVariant(30) // turn time 18 + << QVariant(100) // init health 19 + << QVariant(15) // sudden death 20 + << QVariant(0) // case prob 21 + << QVariant(3) // mines time 22 + << QVariant(4) // landadds 23 + << QVariant(0) // mine dud pct 24 + << QVariant(0) // explosives 25 + ; - QList minefield; - minefield - << predefSchemesNames[4] // name 0 - << QVariant(false) // fortsmode 1 - << QVariant(false) // team divide 2 - << QVariant(false) // solid land 3 - << QVariant(false) // border 4 - << QVariant(false) // low gravity 5 - << QVariant(false) // laser sight 6 - << QVariant(false) // invulnerable 7 - << QVariant(true) // add mines 8 - << QVariant(false) // vampiric 9 - << QVariant(false) // karma 10 - << QVariant(false) // artillery 11 - << QVariant(true) // random order 12 - << QVariant(false) // king 13 - << QVariant(false) // place hog 14 - << QVariant(true) // shared ammo 15 - << QVariant(true) //disable girders 16 - << QVariant(150) // damage modfier 17 - << QVariant(30) // turn time 18 - << QVariant(50) // init health 19 - << QVariant(15) // sudden death 20 - << QVariant(0) // case prob 21 - << QVariant(0) // mines time 22 - << QVariant(80) // landadds 23 - << QVariant(0) // mine dud pct 24 - << QVariant(0) // explosives 25 - ; + QList minefield; + minefield + << predefSchemesNames[4] // name 0 + << QVariant(false) // fortsmode 1 + << QVariant(false) // team divide 2 + << QVariant(false) // solid land 3 + << QVariant(false) // border 4 + << QVariant(false) // low gravity 5 + << QVariant(false) // laser sight 6 + << QVariant(false) // invulnerable 7 + << QVariant(true) // add mines 8 + << QVariant(false) // vampiric 9 + << QVariant(false) // karma 10 + << QVariant(false) // artillery 11 + << QVariant(true) // random order 12 + << QVariant(false) // king 13 + << QVariant(false) // place hog 14 + << QVariant(true) // shared ammo 15 + << QVariant(true) //disable girders 16 + << QVariant(150) // damage modfier 17 + << QVariant(30) // turn time 18 + << QVariant(50) // init health 19 + << QVariant(15) // sudden death 20 + << QVariant(0) // case prob 21 + << QVariant(0) // mines time 22 + << QVariant(80) // landadds 23 + << QVariant(0) // mine dud pct 24 + << QVariant(0) // explosives 25 + ; - schemes.append(defaultScheme); - schemes.append(proMode); - schemes.append(shoppa); - schemes.append(basketball); - schemes.append(minefield); + schemes.append(defaultScheme); + schemes.append(proMode); + schemes.append(shoppa); + schemes.append(basketball); + schemes.append(minefield); - int size = fileConfig.beginReadArray("schemes"); - for (int i = 0; i < size; ++i) { - fileConfig.setArrayIndex(i); + int size = fileConfig.beginReadArray("schemes"); + for (int i = 0; i < size; ++i) { + fileConfig.setArrayIndex(i); - if (!predefSchemesNames.contains(fileConfig.value(spNames[0]).toString())) - { - QList scheme; + if (!predefSchemesNames.contains(fileConfig.value(spNames[0]).toString())) + { + QList scheme; - for (int k = 0; k < spNames.size(); ++k) - scheme << fileConfig.value(spNames[k], defaultScheme[k]); + for (int k = 0; k < spNames.size(); ++k) + scheme << fileConfig.value(spNames[k], defaultScheme[k]); - schemes.append(scheme); - } - } - fileConfig.endArray(); + schemes.append(scheme); + } + } + fileConfig.endArray(); } QVariant AmmoSchemeModel::headerData(int section, Qt::Orientation orientation, int role) const { - return QVariant(); + return QVariant(); } int AmmoSchemeModel::rowCount(const QModelIndex &parent) const { - if (parent.isValid()) - return 0; - else - return schemes.size(); + if (parent.isValid()) + return 0; + else + return schemes.size(); } int AmmoSchemeModel::columnCount(const QModelIndex & parent) const { - if (parent.isValid()) - return 0; - else - return defaultScheme.size(); + if (parent.isValid()) + return 0; + else + return defaultScheme.size(); } Qt::ItemFlags AmmoSchemeModel::flags(const QModelIndex & index) const { - return - Qt::ItemIsEnabled - | Qt::ItemIsSelectable - | Qt::ItemIsEditable; + return + Qt::ItemIsEnabled + | Qt::ItemIsSelectable + | Qt::ItemIsEditable; } bool AmmoSchemeModel::setData(const QModelIndex & index, const QVariant & value, int role) { - if (!index.isValid() || index.row() < numberOfDefaultSchemes - || index.row() >= schemes.size() - || index.column() >= defaultScheme.size() - || role != Qt::EditRole) - return false; + if (!index.isValid() || index.row() < numberOfDefaultSchemes + || index.row() >= schemes.size() + || index.column() >= defaultScheme.size() + || role != Qt::EditRole) + return false; - schemes[index.row()][index.column()] = value; + schemes[index.row()][index.column()] = value; - emit dataChanged(index, index); - return true; + emit dataChanged(index, index); + return true; } bool AmmoSchemeModel::insertRows(int row, int count, const QModelIndex & parent) { - beginInsertRows(parent, row, row); + beginInsertRows(parent, row, row); - QList newScheme = defaultScheme; - newScheme[0] = QVariant(tr("new")); + QList newScheme = defaultScheme; + newScheme[0] = QVariant(tr("new")); - schemes.insert(row, newScheme); + schemes.insert(row, newScheme); - endInsertRows(); + endInsertRows(); - return true; + return true; } bool AmmoSchemeModel::removeRows(int row, int count, const QModelIndex & parent) { - if(count != 1 - || row < numberOfDefaultSchemes - || row >= schemes.size()) - return false; + if(count != 1 + || row < numberOfDefaultSchemes + || row >= schemes.size()) + return false; - beginRemoveRows(parent, row, row); + beginRemoveRows(parent, row, row); - schemes.removeAt(row); + schemes.removeAt(row); - endRemoveRows(); + endRemoveRows(); - return true; + return true; } QVariant AmmoSchemeModel::data(const QModelIndex &index, int role) const { - if (!index.isValid() || index.row() < 0 - || index.row() >= schemes.size() - || index.column() >= defaultScheme.size() - || (role != Qt::EditRole && role != Qt::DisplayRole) - ) - return QVariant(); + if (!index.isValid() || index.row() < 0 + || index.row() >= schemes.size() + || index.column() >= defaultScheme.size() + || (role != Qt::EditRole && role != Qt::DisplayRole) + ) + return QVariant(); - return schemes[index.row()][index.column()]; + return schemes[index.row()][index.column()]; } void AmmoSchemeModel::Save() { - fileConfig.beginWriteArray("schemes", schemes.size()); + fileConfig.beginWriteArray("schemes", schemes.size()); - for (int i = 0; i < schemes.size(); ++i) { - fileConfig.setArrayIndex(i); + for (int i = 0; i < schemes.size(); ++i) { + fileConfig.setArrayIndex(i); - QList scheme = schemes[i]; + QList scheme = schemes[i]; - for (int k = 0; k < scheme.size(); ++k) - fileConfig.setValue(spNames[k], scheme[k]); - } - fileConfig.endArray(); + for (int k = 0; k < scheme.size(); ++k) + fileConfig.setValue(spNames[k], scheme[k]); + } + fileConfig.endArray(); } NetAmmoSchemeModel::NetAmmoSchemeModel(QObject * parent) : - QAbstractTableModel(parent) + QAbstractTableModel(parent) { - netScheme = defaultScheme; + netScheme = defaultScheme; } QVariant NetAmmoSchemeModel::headerData(int section, Qt::Orientation orientation, int role) const { - return QVariant(); + return QVariant(); } int NetAmmoSchemeModel::rowCount(const QModelIndex & parent) const { - if (parent.isValid()) - return 0; - else - return 1; + if (parent.isValid()) + return 0; + else + return 1; } int NetAmmoSchemeModel::columnCount(const QModelIndex & parent) const { - if (parent.isValid()) - return 0; - else - return defaultScheme.size(); + if (parent.isValid()) + return 0; + else + return defaultScheme.size(); } QVariant NetAmmoSchemeModel::data(const QModelIndex &index, int role) const { - if (!index.isValid() || index.row() < 0 - || index.row() > 1 - || index.column() >= defaultScheme.size() - || (role != Qt::EditRole && role != Qt::DisplayRole) - ) - return QVariant(); + if (!index.isValid() || index.row() < 0 + || index.row() > 1 + || index.column() >= defaultScheme.size() + || (role != Qt::EditRole && role != Qt::DisplayRole) + ) + return QVariant(); - return netScheme[index.column()]; + return netScheme[index.column()]; } void NetAmmoSchemeModel::setNetSchemeConfig(QStringList & cfg) { - if(cfg.size() != netScheme.size()) - { - qWarning("Incorrect scheme cfg size"); - return; - } + if(cfg.size() != netScheme.size()) + { + qWarning("Incorrect scheme cfg size"); + return; + } - for(int i = 0; i < cfg.size(); ++i) - netScheme[i] = QVariant(cfg[i]); + for(int i = 0; i < cfg.size(); ++i) + netScheme[i] = QVariant(cfg[i]); - reset(); + reset(); } diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/ammoSchemeModel.h --- a/QTfrontend/ammoSchemeModel.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/ammoSchemeModel.h Sat Mar 06 10:59:20 2010 +0000 @@ -26,54 +26,54 @@ class AmmoSchemeModel : public QAbstractTableModel { - Q_OBJECT + Q_OBJECT public: - AmmoSchemeModel(QObject * parent, const QString & fileName); + AmmoSchemeModel(QObject * parent, const QString & fileName); - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - int rowCount(const QModelIndex & parent) const; - int columnCount(const QModelIndex & parent) const; - Qt::ItemFlags flags(const QModelIndex & index) const; - bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole); - bool insertRows(int row, int count, const QModelIndex & parent = QModelIndex()); - bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex()); - QVariant data(const QModelIndex &index, int role) const; + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + int rowCount(const QModelIndex & parent) const; + int columnCount(const QModelIndex & parent) const; + Qt::ItemFlags flags(const QModelIndex & index) const; + bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole); + bool insertRows(int row, int count, const QModelIndex & parent = QModelIndex()); + bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex()); + QVariant data(const QModelIndex &index, int role) const; - const int numberOfDefaultSchemes; + const int numberOfDefaultSchemes; public slots: - void Save(); + void Save(); signals: - void dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight); + void dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight); protected: - QList< QList > schemes; + QList< QList > schemes; private: - QSettings fileConfig; + QSettings fileConfig; - QStringList spNames; + QStringList spNames; }; class NetAmmoSchemeModel : public QAbstractTableModel { - Q_OBJECT + Q_OBJECT public: - NetAmmoSchemeModel(QObject * parent); + NetAmmoSchemeModel(QObject * parent); - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - int rowCount(const QModelIndex & parent) const; - int columnCount(const QModelIndex & parent) const; - QVariant data(const QModelIndex &index, int role) const; + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + int rowCount(const QModelIndex & parent) const; + int columnCount(const QModelIndex & parent) const; + QVariant data(const QModelIndex &index, int role) const; public slots: - void setNetSchemeConfig(QStringList & cfg); + void setNetSchemeConfig(QStringList & cfg); private: - QList netScheme; + QList netScheme; }; #endif // _AMMO_SCHEME_MODEL_INCLUDED diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/bgwidget.cpp --- a/QTfrontend/bgwidget.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/bgwidget.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -20,9 +20,9 @@ SpritePosition::SpritePosition(QWidget * parent, int sh) { - wParent = parent; - iSpriteHeight = sh; - reset(); + wParent = parent; + iSpriteHeight = sh; + reset(); } SpritePosition::~SpritePosition() @@ -31,110 +31,110 @@ void SpritePosition::move() { - fX += fXMov; - fY += fYMov; - iAngle += 4; - if (iAngle >= 360) iAngle = 0; - if (fY > wParent->height()) reset(); + fX += fXMov; + fY += fYMov; + iAngle += 4; + if (iAngle >= 360) iAngle = 0; + if (fY > wParent->height()) reset(); } void SpritePosition::reset() { - fY = -1 * iSpriteHeight; - fX = (qrand() % ((int)(wParent->width() * 1.5))) - wParent->width()/2; - fYMov = ((qrand() % 400)+300) / 100.0f; - fXMov = fYMov * 0.5f; - iAngle = qrand() % 360; + fY = -1 * iSpriteHeight; + fX = (qrand() % ((int)(wParent->width() * 1.5))) - wParent->width()/2; + fYMov = ((qrand() % 400)+300) / 100.0f; + fXMov = fYMov * 0.5f; + iAngle = qrand() % 360; } QPoint SpritePosition::pos() { - return QPoint((int)fX,(int)fY); + return QPoint((int)fX,(int)fY); } int SpritePosition::getAngle() { - return iAngle; + return iAngle; } void SpritePosition::init() { - fY = qrand() % (wParent->height() + 1); - fX = qrand() % (wParent->width() + 1); + fY = qrand() % (wParent->height() + 1); + fX = qrand() % (wParent->width() + 1); } BGWidget::BGWidget(QWidget * parent) : QWidget(parent) { setAttribute(Qt::WA_NoSystemBackground, true); - sprite.load(":/res/Star.png"); + sprite.load(":/res/Star.png"); - setAutoFillBackground(false); + setAutoFillBackground(false); - for (int i = 0; i < SPRITE_MAX; i++) spritePositions[i] = new SpritePosition(this, sprite.height()); + for (int i = 0; i < SPRITE_MAX; i++) spritePositions[i] = new SpritePosition(this, sprite.height()); - for (int i = 0; i < 360; i++) - { - rotatedSprites[i] = new QImage(sprite.width(), sprite.height(), QImage::Format_ARGB32); - rotatedSprites[i]->fill(0); + for (int i = 0; i < 360; i++) + { + rotatedSprites[i] = new QImage(sprite.width(), sprite.height(), QImage::Format_ARGB32); + rotatedSprites[i]->fill(0); - QPoint translate(sprite.width()/2, sprite.height()/2); + QPoint translate(sprite.width()/2, sprite.height()/2); - QPainter p; - p.begin(rotatedSprites[i]); - // p.setRenderHint(QPainter::Antialiasing); - p.setRenderHint(QPainter::SmoothPixmapTransform); - p.translate(translate.x(), translate.y()); - p.rotate(i); - p.translate(-1*translate.x(), -1*translate.y()); - p.drawImage(0, 0, sprite); - } + QPainter p; + p.begin(rotatedSprites[i]); + // p.setRenderHint(QPainter::Antialiasing); + p.setRenderHint(QPainter::SmoothPixmapTransform); + p.translate(translate.x(), translate.y()); + p.rotate(i); + p.translate(-1*translate.x(), -1*translate.y()); + p.drawImage(0, 0, sprite); + } - timerAnimation = new QTimer(); - connect(timerAnimation, SIGNAL(timeout()), this, SLOT(animate())); - timerAnimation->setInterval(ANIMATION_INTERVAL); + timerAnimation = new QTimer(); + connect(timerAnimation, SIGNAL(timeout()), this, SLOT(animate())); + timerAnimation->setInterval(ANIMATION_INTERVAL); } BGWidget::~BGWidget() { - for (int i = 0; i < SPRITE_MAX; i++) delete spritePositions[i]; - for (int i = 0; i < 360; i++) delete rotatedSprites[i]; - delete timerAnimation; + for (int i = 0; i < SPRITE_MAX; i++) delete spritePositions[i]; + for (int i = 0; i < 360; i++) delete rotatedSprites[i]; + delete timerAnimation; } void BGWidget::paintEvent(QPaintEvent *event) { - QPainter p; - p.begin(this); - //p.setRenderHint(QPainter::Antialiasing); - for (int i = 0; i < SPRITE_MAX; i++) - { - QPoint point = spritePositions[i]->pos(); - p.drawImage(point.x(), point.y(), *rotatedSprites[spritePositions[i]->getAngle()]); - } - p.end(); + QPainter p; + p.begin(this); + //p.setRenderHint(QPainter::Antialiasing); + for (int i = 0; i < SPRITE_MAX; i++) + { + QPoint point = spritePositions[i]->pos(); + p.drawImage(point.x(), point.y(), *rotatedSprites[spritePositions[i]->getAngle()]); + } + p.end(); } void BGWidget::animate() { - for (int i = 0; i < SPRITE_MAX; i++) - { + for (int i = 0; i < SPRITE_MAX; i++) + { // bottom edge of star *seems* clipped, but in fact, if I switch to just plain old repaint()/update() it is still clipped - artifact of transform? As for 5, is arbitrary number. 4 was noticeably clipping, 5 seemed same as update() - I assume extra room is due to rotation and value really should be calculated proportional to width/height update(spritePositions[i]->pos().x(),spritePositions[i]->pos().y(), sprite.width()+5, sprite.height()+5); - spritePositions[i]->move(); - } + spritePositions[i]->move(); + } } void BGWidget::startAnimation() { - timerAnimation->start(); + timerAnimation->start(); } void BGWidget::stopAnimation() { - timerAnimation->stop(); + timerAnimation->stop(); } void BGWidget::init() { - for (int i = 0; i < SPRITE_MAX; i++) spritePositions[i]->init(); + for (int i = 0; i < SPRITE_MAX; i++) spritePositions[i]->init(); } diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/bgwidget.h --- a/QTfrontend/bgwidget.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/bgwidget.h Sat Mar 06 10:59:20 2010 +0000 @@ -34,42 +34,42 @@ class SpritePosition { public: - SpritePosition(QWidget * parent, int sh); - ~SpritePosition(); + SpritePosition(QWidget * parent, int sh); + ~SpritePosition(); private: - float fX; - float fY; - float fXMov; - float fYMov; - int iAngle; - QWidget * wParent; - int iSpriteHeight; + float fX; + float fY; + float fXMov; + float fYMov; + int iAngle; + QWidget * wParent; + int iSpriteHeight; public: - void move(); - void reset(); - QPoint pos(); - int getAngle(); - void init(); + void move(); + void reset(); + QPoint pos(); + int getAngle(); + void init(); }; class BGWidget : public QWidget { - Q_OBJECT + Q_OBJECT public: - BGWidget(QWidget * parent); - ~BGWidget(); - void startAnimation(); - void stopAnimation(); - void init(); + BGWidget(QWidget * parent); + ~BGWidget(); + void startAnimation(); + void stopAnimation(); + void init(); private: - QImage sprite; - QTimer * timerAnimation; - SpritePosition * spritePositions[SPRITE_MAX]; - QImage * rotatedSprites[360]; + QImage sprite; + QTimer * timerAnimation; + SpritePosition * spritePositions[SPRITE_MAX]; + QImage * rotatedSprites[360]; protected: - void paintEvent(QPaintEvent * event); + void paintEvent(QPaintEvent * event); private slots: - void animate(); + void animate(); }; #endif // BGWIDGET_H diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/binds.cpp --- a/QTfrontend/binds.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/binds.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -20,50 +20,50 @@ const BindAction cbinds[BINDS_NUMBER] = { - {"+up", "up", QT_TRANSLATE_NOOP("binds", "up"), QT_TRANSLATE_NOOP("binds (categories)", "Basic controls"), QT_TRANSLATE_NOOP("binds (descriptions)", "Move your hogs and aim:")}, - {"+left", "left", QT_TRANSLATE_NOOP("binds", "left"), NULL, NULL}, - {"+right", "right", QT_TRANSLATE_NOOP("binds", "right"), NULL, NULL}, - {"+down", "down", QT_TRANSLATE_NOOP("binds", "down"), NULL, NULL}, - {"+precise", "left_shift", QT_TRANSLATE_NOOP("binds", "precise aim"), NULL, NULL}, - {"ljump", "return", QT_TRANSLATE_NOOP("binds", "long jump"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Traverse gaps and obstacles by jumping:")}, - {"hjump", "backspace", QT_TRANSLATE_NOOP("binds", "high jump"), NULL, NULL}, - {"+attack", "space", QT_TRANSLATE_NOOP("binds", "attack"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Fire your selected weapon or trigger an utility item:")}, - {"put", "mousel", QT_TRANSLATE_NOOP("binds", "put"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Pick a weapon or a target location under the cursor:")}, - {"switch", "tab", QT_TRANSLATE_NOOP("binds", "switch"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Switch your currently active hog (if possible):")}, - {"ammomenu", "mouser", QT_TRANSLATE_NOOP("binds", "ammo menu"), QT_TRANSLATE_NOOP("binds (categories)", "Weapon controls"), QT_TRANSLATE_NOOP("binds (descriptions)", "Pick a weapon or utility item:")}, - {"slot 1", "f1", QT_TRANSLATE_NOOP("binds", "slot 1"), NULL, NULL}, - {"slot 2", "f2", QT_TRANSLATE_NOOP("binds", "slot 2"), NULL, NULL}, - {"slot 3", "f3", QT_TRANSLATE_NOOP("binds", "slot 3"), NULL, NULL}, - {"slot 4", "f4", QT_TRANSLATE_NOOP("binds", "slot 4"), NULL, NULL}, - {"slot 5", "f5", QT_TRANSLATE_NOOP("binds", "slot 5"), NULL, NULL}, - {"slot 6", "f6", QT_TRANSLATE_NOOP("binds", "slot 6"), NULL, NULL}, - {"slot 7", "f7", QT_TRANSLATE_NOOP("binds", "slot 7"), NULL, NULL}, - {"slot 8", "f8", QT_TRANSLATE_NOOP("binds", "slot 8"), NULL, NULL}, - {"slot 9", "f9", QT_TRANSLATE_NOOP("binds", "slot 9"), NULL, NULL}, - {"timer 1", "1", QT_TRANSLATE_NOOP("binds", "timer 1 sec"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Set the timer on bombs and timed weapons:")}, - {"timer 2", "2", QT_TRANSLATE_NOOP("binds", "timer 2 sec"), NULL, NULL}, - {"timer 3", "3", QT_TRANSLATE_NOOP("binds", "timer 3 sec"), NULL, NULL}, - {"timer 4", "4", QT_TRANSLATE_NOOP("binds", "timer 4 sec"), NULL, NULL}, - {"timer 5", "5", QT_TRANSLATE_NOOP("binds", "timer 5 sec"), NULL, NULL}, - {"findhh", "h", QT_TRANSLATE_NOOP("binds", "find hedgehog"), QT_TRANSLATE_NOOP("binds (categories)", "Camera and cursor controls"), QT_TRANSLATE_NOOP("binds (descriptions)", "Move the camera to the active hog:")}, - {"+cur_u", "", QT_TRANSLATE_NOOP("binds", "up"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Move the cursor or camera without using the mouse:")}, - {"+cur_l", "", QT_TRANSLATE_NOOP("binds", "left"), NULL, NULL}, - {"+cur_r", "", QT_TRANSLATE_NOOP("binds", "right"), NULL, NULL}, - {"+cur_d", "", QT_TRANSLATE_NOOP("binds", "down"), NULL, NULL}, -// {"+cur_m", "", QT_TRANSLATE_NOOP("binds", "movement key modifier"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Specify a modifier key to move camera and cursor using your default hog movement keys:")}, - {"zoomin", "wheeldown", QT_TRANSLATE_NOOP("binds", "zoom in"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Modify the camera's zoom level:")}, - {"zoomout", "wheelup", QT_TRANSLATE_NOOP("binds", "zoom out"), NULL, NULL}, - {"zoomreset", "mousem", QT_TRANSLATE_NOOP("binds", "reset zoom"), NULL, NULL}, - {"chat", "t", QT_TRANSLATE_NOOP("binds", "chat"), QT_TRANSLATE_NOOP("binds (categories)", "Other"), QT_TRANSLATE_NOOP("binds (descriptions)", "Talk to your team or all participants:")}, - {"history", "`", QT_TRANSLATE_NOOP("binds", "chat history"), NULL, NULL}, - {"pause", "p", QT_TRANSLATE_NOOP("binds", "pause"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Pause, continue or leave your game:")}, - {"quit", "escape", QT_TRANSLATE_NOOP("binds", "quit"), NULL, NULL}, - {"confirm", "y", QT_TRANSLATE_NOOP("binds", "confirmation"), NULL, NULL}, - {"+voldown", "9", QT_TRANSLATE_NOOP("binds", "volume down"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Modify the game's volume while playing:")}, - {"+volup", "0", QT_TRANSLATE_NOOP("binds", "volume up"), NULL, NULL}, + {"+up", "up", QT_TRANSLATE_NOOP("binds", "up"), QT_TRANSLATE_NOOP("binds (categories)", "Basic controls"), QT_TRANSLATE_NOOP("binds (descriptions)", "Move your hogs and aim:")}, + {"+left", "left", QT_TRANSLATE_NOOP("binds", "left"), NULL, NULL}, + {"+right", "right", QT_TRANSLATE_NOOP("binds", "right"), NULL, NULL}, + {"+down", "down", QT_TRANSLATE_NOOP("binds", "down"), NULL, NULL}, + {"+precise", "left_shift", QT_TRANSLATE_NOOP("binds", "precise aim"), NULL, NULL}, + {"ljump", "return", QT_TRANSLATE_NOOP("binds", "long jump"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Traverse gaps and obstacles by jumping:")}, + {"hjump", "backspace", QT_TRANSLATE_NOOP("binds", "high jump"), NULL, NULL}, + {"+attack", "space", QT_TRANSLATE_NOOP("binds", "attack"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Fire your selected weapon or trigger an utility item:")}, + {"put", "mousel", QT_TRANSLATE_NOOP("binds", "put"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Pick a weapon or a target location under the cursor:")}, + {"switch", "tab", QT_TRANSLATE_NOOP("binds", "switch"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Switch your currently active hog (if possible):")}, + {"ammomenu", "mouser", QT_TRANSLATE_NOOP("binds", "ammo menu"), QT_TRANSLATE_NOOP("binds (categories)", "Weapon controls"), QT_TRANSLATE_NOOP("binds (descriptions)", "Pick a weapon or utility item:")}, + {"slot 1", "f1", QT_TRANSLATE_NOOP("binds", "slot 1"), NULL, NULL}, + {"slot 2", "f2", QT_TRANSLATE_NOOP("binds", "slot 2"), NULL, NULL}, + {"slot 3", "f3", QT_TRANSLATE_NOOP("binds", "slot 3"), NULL, NULL}, + {"slot 4", "f4", QT_TRANSLATE_NOOP("binds", "slot 4"), NULL, NULL}, + {"slot 5", "f5", QT_TRANSLATE_NOOP("binds", "slot 5"), NULL, NULL}, + {"slot 6", "f6", QT_TRANSLATE_NOOP("binds", "slot 6"), NULL, NULL}, + {"slot 7", "f7", QT_TRANSLATE_NOOP("binds", "slot 7"), NULL, NULL}, + {"slot 8", "f8", QT_TRANSLATE_NOOP("binds", "slot 8"), NULL, NULL}, + {"slot 9", "f9", QT_TRANSLATE_NOOP("binds", "slot 9"), NULL, NULL}, + {"timer 1", "1", QT_TRANSLATE_NOOP("binds", "timer 1 sec"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Set the timer on bombs and timed weapons:")}, + {"timer 2", "2", QT_TRANSLATE_NOOP("binds", "timer 2 sec"), NULL, NULL}, + {"timer 3", "3", QT_TRANSLATE_NOOP("binds", "timer 3 sec"), NULL, NULL}, + {"timer 4", "4", QT_TRANSLATE_NOOP("binds", "timer 4 sec"), NULL, NULL}, + {"timer 5", "5", QT_TRANSLATE_NOOP("binds", "timer 5 sec"), NULL, NULL}, + {"findhh", "h", QT_TRANSLATE_NOOP("binds", "find hedgehog"), QT_TRANSLATE_NOOP("binds (categories)", "Camera and cursor controls"), QT_TRANSLATE_NOOP("binds (descriptions)", "Move the camera to the active hog:")}, + {"+cur_u", "", QT_TRANSLATE_NOOP("binds", "up"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Move the cursor or camera without using the mouse:")}, + {"+cur_l", "", QT_TRANSLATE_NOOP("binds", "left"), NULL, NULL}, + {"+cur_r", "", QT_TRANSLATE_NOOP("binds", "right"), NULL, NULL}, + {"+cur_d", "", QT_TRANSLATE_NOOP("binds", "down"), NULL, NULL}, +// {"+cur_m", "", QT_TRANSLATE_NOOP("binds", "movement key modifier"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Specify a modifier key to move camera and cursor using your default hog movement keys:")}, + {"zoomin", "wheeldown", QT_TRANSLATE_NOOP("binds", "zoom in"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Modify the camera's zoom level:")}, + {"zoomout", "wheelup", QT_TRANSLATE_NOOP("binds", "zoom out"), NULL, NULL}, + {"zoomreset", "mousem", QT_TRANSLATE_NOOP("binds", "reset zoom"), NULL, NULL}, + {"chat", "t", QT_TRANSLATE_NOOP("binds", "chat"), QT_TRANSLATE_NOOP("binds (categories)", "Other"), QT_TRANSLATE_NOOP("binds (descriptions)", "Talk to your team or all participants:")}, + {"history", "`", QT_TRANSLATE_NOOP("binds", "chat history"), NULL, NULL}, + {"pause", "p", QT_TRANSLATE_NOOP("binds", "pause"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Pause, continue or leave your game:")}, + {"quit", "escape", QT_TRANSLATE_NOOP("binds", "quit"), NULL, NULL}, + {"confirm", "y", QT_TRANSLATE_NOOP("binds", "confirmation"), NULL, NULL}, + {"+voldown", "9", QT_TRANSLATE_NOOP("binds", "volume down"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Modify the game's volume while playing:")}, + {"+volup", "0", QT_TRANSLATE_NOOP("binds", "volume up"), NULL, NULL}, #ifndef _WIN32 - {"fullscr", "f12", QT_TRANSLATE_NOOP("binds", "change mode"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Toggle fullscreen mode:")}, + {"fullscr", "f12", QT_TRANSLATE_NOOP("binds", "change mode"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Toggle fullscreen mode:")}, #endif - {"capture", "c", QT_TRANSLATE_NOOP("binds", "capture"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Take a screenshot:")}, - {"rotmask", "delete", QT_TRANSLATE_NOOP("binds", "hedgehogs\ninfo"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Toggle labels above hedgehogs:")} + {"capture", "c", QT_TRANSLATE_NOOP("binds", "capture"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Take a screenshot:")}, + {"rotmask", "delete", QT_TRANSLATE_NOOP("binds", "hedgehogs\ninfo"), NULL, QT_TRANSLATE_NOOP("binds (descriptions)", "Toggle labels above hedgehogs:")} }; diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/binds.h --- a/QTfrontend/binds.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/binds.h Sat Mar 06 10:59:20 2010 +0000 @@ -29,11 +29,11 @@ struct BindAction { - QString action; - QString strbind; - const char * name; - const char * category; - const char * description; + QString action; + QString strbind; + const char * name; + const char * category; + const char * description; }; extern const BindAction cbinds[BINDS_NUMBER]; diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/chatwidget.cpp --- a/QTfrontend/chatwidget.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/chatwidget.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -51,192 +51,192 @@ sound[3] = Mix_LoadWAV(QString(tmpdir.absolutePath() + "/Russian/Hello.ogg").toLocal8Bit().constData()); } - mainLayout.setSpacing(1); - mainLayout.setMargin(1); - mainLayout.setSizeConstraint(QLayout::SetMinimumSize); - mainLayout.setColumnStretch(0, 75); - mainLayout.setColumnStretch(1, 25); + mainLayout.setSpacing(1); + mainLayout.setMargin(1); + mainLayout.setSizeConstraint(QLayout::SetMinimumSize); + mainLayout.setColumnStretch(0, 75); + mainLayout.setColumnStretch(1, 25); - chatEditLine = new QLineEdit(this); - chatEditLine->setMaxLength(300); - connect(chatEditLine, SIGNAL(returnPressed()), this, SLOT(returnPressed())); + chatEditLine = new QLineEdit(this); + chatEditLine->setMaxLength(300); + connect(chatEditLine, SIGNAL(returnPressed()), this, SLOT(returnPressed())); - mainLayout.addWidget(chatEditLine, 1, 0, 1, 2); + mainLayout.addWidget(chatEditLine, 1, 0, 1, 2); - chatText = new QTextBrowser(this); - chatText->setMinimumHeight(20); - chatText->setMinimumWidth(10); - chatText->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - chatText->setOpenExternalLinks(true); - mainLayout.addWidget(chatText, 0, 0); + chatText = new QTextBrowser(this); + chatText->setMinimumHeight(20); + chatText->setMinimumWidth(10); + chatText->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + chatText->setOpenExternalLinks(true); + mainLayout.addWidget(chatText, 0, 0); - chatNicks = new QListWidget(this); - chatNicks->setMinimumHeight(10); - chatNicks->setMinimumWidth(10); - chatNicks->setSortingEnabled(true); - chatNicks->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - chatNicks->setContextMenuPolicy(Qt::ActionsContextMenu); - connect(chatNicks, SIGNAL(itemDoubleClicked(QListWidgetItem *)), - this, SLOT(chatNickDoubleClicked(QListWidgetItem *))); - connect(chatNicks, SIGNAL(currentRowChanged(int)), - this, SLOT(chatNickSelected(int))); + chatNicks = new QListWidget(this); + chatNicks->setMinimumHeight(10); + chatNicks->setMinimumWidth(10); + chatNicks->setSortingEnabled(true); + chatNicks->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + chatNicks->setContextMenuPolicy(Qt::ActionsContextMenu); + connect(chatNicks, SIGNAL(itemDoubleClicked(QListWidgetItem *)), + this, SLOT(chatNickDoubleClicked(QListWidgetItem *))); + connect(chatNicks, SIGNAL(currentRowChanged(int)), + this, SLOT(chatNickSelected(int))); - mainLayout.addWidget(chatNicks, 0, 1); + mainLayout.addWidget(chatNicks, 0, 1); - acInfo = new QAction(QAction::tr("Info"), chatNicks); - connect(acInfo, SIGNAL(triggered(bool)), this, SLOT(onInfo())); - acKick = new QAction(QAction::tr("Kick"), chatNicks); - connect(acKick, SIGNAL(triggered(bool)), this, SLOT(onKick())); - acBan = new QAction(QAction::tr("Ban"), chatNicks); - connect(acBan, SIGNAL(triggered(bool)), this, SLOT(onBan())); - acFollow = new QAction(QAction::tr("Follow"), chatNicks); - connect(acFollow, SIGNAL(triggered(bool)), this, SLOT(onFollow())); - acIgnore = new QAction(QAction::tr("Ignore"), chatNicks); - connect(acIgnore, SIGNAL(triggered(bool)), this, SLOT(onIgnore())); - acFriend = new QAction(QAction::tr("Add friend"), chatNicks); - connect(acFriend, SIGNAL(triggered(bool)), this, SLOT(onFriend())); + acInfo = new QAction(QAction::tr("Info"), chatNicks); + connect(acInfo, SIGNAL(triggered(bool)), this, SLOT(onInfo())); + acKick = new QAction(QAction::tr("Kick"), chatNicks); + connect(acKick, SIGNAL(triggered(bool)), this, SLOT(onKick())); + acBan = new QAction(QAction::tr("Ban"), chatNicks); + connect(acBan, SIGNAL(triggered(bool)), this, SLOT(onBan())); + acFollow = new QAction(QAction::tr("Follow"), chatNicks); + connect(acFollow, SIGNAL(triggered(bool)), this, SLOT(onFollow())); + acIgnore = new QAction(QAction::tr("Ignore"), chatNicks); + connect(acIgnore, SIGNAL(triggered(bool)), this, SLOT(onIgnore())); + acFriend = new QAction(QAction::tr("Add friend"), chatNicks); + connect(acFriend, SIGNAL(triggered(bool)), this, SLOT(onFriend())); - chatNicks->insertAction(0, acInfo); - chatNicks->insertAction(0, acFollow); - chatNicks->insertAction(0, acIgnore); - chatNicks->insertAction(0, acFriend); - - showReady = false; + chatNicks->insertAction(0, acInfo); + chatNicks->insertAction(0, acFollow); + chatNicks->insertAction(0, acIgnore); + chatNicks->insertAction(0, acFriend); + + showReady = false; } void HWChatWidget::loadList(QStringList & list, const QString & file) { - list.clear(); - QFile txt((cfgdir->absolutePath() + "/" + file).toLocal8Bit().constData()); - if(!txt.open(QIODevice::ReadOnly)) - return; - QTextStream stream(&txt); - stream.setCodec("UTF-8"); + list.clear(); + QFile txt((cfgdir->absolutePath() + "/" + file).toLocal8Bit().constData()); + if(!txt.open(QIODevice::ReadOnly)) + return; + QTextStream stream(&txt); + stream.setCodec("UTF-8"); - while(!stream.atEnd()) - { - QString str = stream.readLine(); - if(str.startsWith(";") || str.length() == 0) - continue; - list << str.trimmed(); - } - list.removeDuplicates(); - txt.close(); + while(!stream.atEnd()) + { + QString str = stream.readLine(); + if(str.startsWith(";") || str.length() == 0) + continue; + list << str.trimmed(); + } + list.removeDuplicates(); + txt.close(); } void HWChatWidget::saveList(QStringList & list, const QString & file) { - QFile txt((cfgdir->absolutePath() + "/" + file).toLocal8Bit().constData()); - if(!txt.open(QIODevice::WriteOnly | QIODevice::Truncate)) - return; - QTextStream stream(&txt); - stream.setCodec("UTF-8"); + QFile txt((cfgdir->absolutePath() + "/" + file).toLocal8Bit().constData()); + if(!txt.open(QIODevice::WriteOnly | QIODevice::Truncate)) + return; + QTextStream stream(&txt); + stream.setCodec("UTF-8"); - stream << "; this list is used by Hedgewars - do not edit it unless you know what you're doing!" << endl; - for(int i = 0; i < list.size(); i++) - stream << list[i] << endl; - txt.close(); + stream << "; this list is used by Hedgewars - do not edit it unless you know what you're doing!" << endl; + for(int i = 0; i < list.size(); i++) + stream << list[i] << endl; + txt.close(); } void HWChatWidget::updateIcon(QListWidgetItem *item) { - QString nick = item->text(); + QString nick = item->text(); - if(ignoreList.contains(nick, Qt::CaseInsensitive)) - { - item->setIcon(QIcon(showReady ? (item->data(Qt::UserRole).toBool() ? ":/res/chat_ignore_on" : ":/res/chat_ignore_off") : ":/res/chat_ignore.png")); - item->setForeground(Qt::gray); - } - else if(friendsList.contains(nick, Qt::CaseInsensitive)) - { - item->setIcon(QIcon(showReady ? (item->data(Qt::UserRole).toBool() ? ":/res/chat_friend_on" : ":/res/chat_friend_off") : ":/res/chat_friend.png")); - item->setForeground(Qt::green); - } - else - { - item->setIcon(QIcon(showReady ? (item->data(Qt::UserRole).toBool() ? ":/res/chat_default_on" : ":/res/chat_default_off") : ":/res/chat_default.png")); - item->setForeground(QBrush(QColor(0xff, 0xcc, 0x00))); - } + if(ignoreList.contains(nick, Qt::CaseInsensitive)) + { + item->setIcon(QIcon(showReady ? (item->data(Qt::UserRole).toBool() ? ":/res/chat_ignore_on" : ":/res/chat_ignore_off") : ":/res/chat_ignore.png")); + item->setForeground(Qt::gray); + } + else if(friendsList.contains(nick, Qt::CaseInsensitive)) + { + item->setIcon(QIcon(showReady ? (item->data(Qt::UserRole).toBool() ? ":/res/chat_friend_on" : ":/res/chat_friend_off") : ":/res/chat_friend.png")); + item->setForeground(Qt::green); + } + else + { + item->setIcon(QIcon(showReady ? (item->data(Qt::UserRole).toBool() ? ":/res/chat_default_on" : ":/res/chat_default_off") : ":/res/chat_default.png")); + item->setForeground(QBrush(QColor(0xff, 0xcc, 0x00))); + } } void HWChatWidget::updateIcons() { - for(int i = 0; i < chatNicks->count(); i++) - updateIcon(chatNicks->item(i)); + for(int i = 0; i < chatNicks->count(); i++) + updateIcon(chatNicks->item(i)); } void HWChatWidget::loadLists(const QString & nick) { - loadList(ignoreList, nick.toLower() + "_ignore.txt"); - loadList(friendsList, nick.toLower() + "_friends.txt"); - updateIcons(); + loadList(ignoreList, nick.toLower() + "_ignore.txt"); + loadList(friendsList, nick.toLower() + "_friends.txt"); + updateIcons(); } void HWChatWidget::saveLists(const QString & nick) { - saveList(ignoreList, nick.toLower() + "_ignore.txt"); - saveList(friendsList, nick.toLower() + "_friends.txt"); + saveList(ignoreList, nick.toLower() + "_ignore.txt"); + saveList(friendsList, nick.toLower() + "_friends.txt"); } void HWChatWidget::returnPressed() { - emit chatLine(chatEditLine->text()); - chatEditLine->clear(); + emit chatLine(chatEditLine->text()); + chatEditLine->clear(); } void HWChatWidget::onChatString(const QString& str) { - if (chatStrings.size() > 250) - chatStrings.removeFirst(); + if (chatStrings.size() > 250) + chatStrings.removeFirst(); - QString formattedStr = Qt::escape(str.mid(1)); - QStringList parts = formattedStr.split(QRegExp("\\W+"), QString::SkipEmptyParts); + QString formattedStr = Qt::escape(str.mid(1)); + QStringList parts = formattedStr.split(QRegExp("\\W+"), QString::SkipEmptyParts); - if (!formattedStr.startsWith(" ***")) // don't ignore status messages - { - if (formattedStr.startsWith(" *")) // emote - parts[0] = parts[1]; - if(parts.size() > 0 && ignoreList.contains(parts[0], Qt::CaseInsensitive)) - return; - } + if (!formattedStr.startsWith(" ***")) // don't ignore status messages + { + if (formattedStr.startsWith(" *")) // emote + parts[0] = parts[1]; + if(parts.size() > 0 && ignoreList.contains(parts[0], Qt::CaseInsensitive)) + return; + } - QString color(""); - bool isFriend = friendsList.contains(parts[0], Qt::CaseInsensitive); - - if (str.startsWith("\x03")) - color = QString("#c0c0c0"); - else if (str.startsWith("\x02")) - color = QString(isFriend ? "#00ff00" : "#ff00ff"); - else if (isFriend) - color = QString("#00c000"); + QString color(""); + bool isFriend = friendsList.contains(parts[0], Qt::CaseInsensitive); + + if (str.startsWith("\x03")) + color = QString("#c0c0c0"); + else if (str.startsWith("\x02")) + color = QString(isFriend ? "#00ff00" : "#ff00ff"); + else if (isFriend) + color = QString("#00c000"); - if(color.compare("") != 0) - formattedStr = QString("%1").arg(formattedStr).arg(color); + if(color.compare("") != 0) + formattedStr = QString("%1").arg(formattedStr).arg(color); - chatStrings.append(formattedStr); + chatStrings.append(formattedStr); - chatText->setHtml(chatStrings.join("
")); + chatText->setHtml(chatStrings.join("
")); - chatText->moveCursor(QTextCursor::End); + chatText->moveCursor(QTextCursor::End); } void HWChatWidget::onServerMessage(const QString& str) { - if (chatStrings.size() > 250) - chatStrings.removeFirst(); + if (chatStrings.size() > 250) + chatStrings.removeFirst(); - chatStrings.append("
" + str + "
"); + chatStrings.append("
" + str + "
"); - chatText->setHtml(chatStrings.join("
")); + chatText->setHtml(chatStrings.join("
")); - chatText->moveCursor(QTextCursor::End); + chatText->moveCursor(QTextCursor::End); } void HWChatWidget::nickAdded(const QString& nick, bool notifyNick) { - QListWidgetItem * item = new QListWidgetItem(nick); - updateIcon(item); - chatNicks->addItem(item); + QListWidgetItem * item = new QListWidgetItem(nick); + updateIcon(item); + chatNicks->addItem(item); if(notifyNick && notify && gameSettings->value("audio/frontendsound", true).toBool()) { Mix_PlayChannel(-1, sound[rand()%4], 0); @@ -245,140 +245,140 @@ void HWChatWidget::nickRemoved(const QString& nick) { - QList items = chatNicks->findItems(nick, Qt::MatchExactly); - for(QList::iterator it=items.begin(); it!=items.end();) { - chatNicks->takeItem(chatNicks->row(*it)); - ++it; - } + QList items = chatNicks->findItems(nick, Qt::MatchExactly); + for(QList::iterator it=items.begin(); it!=items.end();) { + chatNicks->takeItem(chatNicks->row(*it)); + ++it; + } } void HWChatWidget::clear() { - chatText->clear(); - chatStrings.clear(); - chatNicks->clear(); + chatText->clear(); + chatStrings.clear(); + chatNicks->clear(); } void HWChatWidget::onKick() { - QListWidgetItem * curritem = chatNicks->currentItem(); - if (curritem) - emit kick(curritem->text()); + QListWidgetItem * curritem = chatNicks->currentItem(); + if (curritem) + emit kick(curritem->text()); } void HWChatWidget::onBan() { - QListWidgetItem * curritem = chatNicks->currentItem(); - if (curritem) - emit ban(curritem->text()); + QListWidgetItem * curritem = chatNicks->currentItem(); + if (curritem) + emit ban(curritem->text()); } void HWChatWidget::onInfo() { - QListWidgetItem * curritem = chatNicks->currentItem(); - if (curritem) - emit info(curritem->text()); + QListWidgetItem * curritem = chatNicks->currentItem(); + if (curritem) + emit info(curritem->text()); } void HWChatWidget::onFollow() { - QListWidgetItem * curritem = chatNicks->currentItem(); - if (curritem) - emit follow(curritem->text()); + QListWidgetItem * curritem = chatNicks->currentItem(); + if (curritem) + emit follow(curritem->text()); } void HWChatWidget::onIgnore() { - QListWidgetItem * curritem = chatNicks->currentItem(); - if(!curritem) - return; + QListWidgetItem * curritem = chatNicks->currentItem(); + if(!curritem) + return; - if(ignoreList.contains(curritem->text(), Qt::CaseInsensitive)) // already on list - remove him - { - ignoreList.removeAll(curritem->text().toLower()); - onChatString(HWChatWidget::tr("%1 *** %2 has been removed from your ignore list").arg('\x03').arg(curritem->text())); - } - else // not on list - add - { - ignoreList << curritem->text().toLower(); - onChatString(HWChatWidget::tr("%1 *** %2 has been added to your ignore list").arg('\x03').arg(curritem->text())); - } - updateIcon(curritem); // update icon - chatNickSelected(0); // update context menu + if(ignoreList.contains(curritem->text(), Qt::CaseInsensitive)) // already on list - remove him + { + ignoreList.removeAll(curritem->text().toLower()); + onChatString(HWChatWidget::tr("%1 *** %2 has been removed from your ignore list").arg('\x03').arg(curritem->text())); + } + else // not on list - add + { + ignoreList << curritem->text().toLower(); + onChatString(HWChatWidget::tr("%1 *** %2 has been added to your ignore list").arg('\x03').arg(curritem->text())); + } + updateIcon(curritem); // update icon + chatNickSelected(0); // update context menu } void HWChatWidget::onFriend() { - QListWidgetItem * curritem = chatNicks->currentItem(); - if(!curritem) - return; + QListWidgetItem * curritem = chatNicks->currentItem(); + if(!curritem) + return; - if(friendsList.contains(curritem->text(), Qt::CaseInsensitive)) // already on list - remove him - { - friendsList.removeAll(curritem->text().toLower()); - onChatString(HWChatWidget::tr("%1 *** %2 has been removed from your friends list").arg('\x03').arg(curritem->text())); - } - else // not on list - add - { - friendsList << curritem->text().toLower(); - onChatString(HWChatWidget::tr("%1 *** %2 has been added to your friends list").arg('\x03').arg(curritem->text())); - } - updateIcon(curritem); // update icon - chatNickSelected(0); // update context menu + if(friendsList.contains(curritem->text(), Qt::CaseInsensitive)) // already on list - remove him + { + friendsList.removeAll(curritem->text().toLower()); + onChatString(HWChatWidget::tr("%1 *** %2 has been removed from your friends list").arg('\x03').arg(curritem->text())); + } + else // not on list - add + { + friendsList << curritem->text().toLower(); + onChatString(HWChatWidget::tr("%1 *** %2 has been added to your friends list").arg('\x03').arg(curritem->text())); + } + updateIcon(curritem); // update icon + chatNickSelected(0); // update context menu } void HWChatWidget::chatNickDoubleClicked(QListWidgetItem * item) { - if (item) onFollow(); + if (item) onFollow(); } void HWChatWidget::chatNickSelected(int index) { - QListWidgetItem* item = chatNicks->currentItem(); - if (!item) - return; + QListWidgetItem* item = chatNicks->currentItem(); + if (!item) + return; - // update context menu labels according to possible action - if(ignoreList.contains(item->text(), Qt::CaseInsensitive)) - acIgnore->setText(QAction::tr("Unignore")); - else - acIgnore->setText(QAction::tr("Ignore")); + // update context menu labels according to possible action + if(ignoreList.contains(item->text(), Qt::CaseInsensitive)) + acIgnore->setText(QAction::tr("Unignore")); + else + acIgnore->setText(QAction::tr("Ignore")); - if(friendsList.contains(item->text(), Qt::CaseInsensitive)) - acFriend->setText(QAction::tr("Remove friend")); - else - acFriend->setText(QAction::tr("Add friend")); + if(friendsList.contains(item->text(), Qt::CaseInsensitive)) + acFriend->setText(QAction::tr("Remove friend")); + else + acFriend->setText(QAction::tr("Add friend")); } void HWChatWidget::setShowReady(bool s) { - showReady = s; + showReady = s; } void HWChatWidget::setReadyStatus(const QString & nick, bool isReady) { - QList items = chatNicks->findItems(nick, Qt::MatchExactly); - if (items.size() != 1) - { - qWarning("Bug: cannot find user in chat"); - return; - } + QList items = chatNicks->findItems(nick, Qt::MatchExactly); + if (items.size() != 1) + { + qWarning("Bug: cannot find user in chat"); + return; + } - items[0]->setData(Qt::UserRole, isReady); // bulb status - updateIcon(items[0]); + items[0]->setData(Qt::UserRole, isReady); // bulb status + updateIcon(items[0]); - // ensure we're still showing the status bulbs - showReady = true; + // ensure we're still showing the status bulbs + showReady = true; } void HWChatWidget::adminAccess(bool b) { - chatNicks->removeAction(acKick); - chatNicks->removeAction(acBan); + chatNicks->removeAction(acKick); + chatNicks->removeAction(acBan); - if(b) - { - chatNicks->insertAction(0, acKick); -// chatNicks->insertAction(0, acBan); - } + if(b) + { + chatNicks->insertAction(0, acKick); +// chatNicks->insertAction(0, acBan); + } } diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/fpsedit.cpp --- a/QTfrontend/fpsedit.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/fpsedit.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -19,13 +19,13 @@ #include "fpsedit.h" FPSEdit::FPSEdit(QWidget * parent) : - QSpinBox(parent) + QSpinBox(parent) { - setRange(1, 34); - setValue(27); + setRange(1, 34); + setValue(27); } QString FPSEdit::textFromValue(int value) const { - return QString::number(1000 / (35 - value)); + return QString::number(1000 / (35 - value)); } diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/fpsedit.h --- a/QTfrontend/fpsedit.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/fpsedit.h Sat Mar 06 10:59:20 2010 +0000 @@ -23,13 +23,13 @@ class FPSEdit : public QSpinBox { - Q_OBJECT + Q_OBJECT public: - FPSEdit(QWidget * parent = 0); + FPSEdit(QWidget * parent = 0); protected: - QString textFromValue (int value) const; + QString textFromValue (int value) const; }; #endif // _FPSEDIT_H diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/frameTeam.cpp --- a/QTfrontend/frameTeam.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/frameTeam.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -27,32 +27,32 @@ FrameTeams::FrameTeams(QWidget* parent) : QFrame(parent), maxHedgehogsPerGame(48), overallHedgehogs(0), mainLayout(this), nonInteractive(false) { - QPalette newPalette = palette(); - newPalette.setColor(QPalette::Window, QColor(0x00, 0x00, 0x00)); - setPalette(newPalette); - setAutoFillBackground(true); + QPalette newPalette = palette(); + newPalette.setColor(QPalette::Window, QColor(0x00, 0x00, 0x00)); + setPalette(newPalette); + setAutoFillBackground(true); - mainLayout.setSpacing(1); - mainLayout.setContentsMargins(4, 4, 4, 4); + mainLayout.setSpacing(1); + mainLayout.setContentsMargins(4, 4, 4, 4); - availableColors.push_back(*color1); - availableColors.push_back(*color2); - availableColors.push_back(*color3); - availableColors.push_back(*color4); - availableColors.push_back(*color5); - availableColors.push_back(*color6); + availableColors.push_back(*color1); + availableColors.push_back(*color2); + availableColors.push_back(*color3); + availableColors.push_back(*color4); + availableColors.push_back(*color5); + availableColors.push_back(*color6); - resetColors(); + resetColors(); } void FrameTeams::setInteractivity(bool interactive) { - nonInteractive = !interactive; - for(tmapTeamToWidget::iterator it=teamToWidget.begin(); it!=teamToWidget.end(); ++it) { - TeamShowWidget* pts = dynamic_cast(it.value()); - if(!pts) throw; - pts->setInteractivity(interactive); - } + nonInteractive = !interactive; + for(tmapTeamToWidget::iterator it=teamToWidget.begin(); it!=teamToWidget.end(); ++it) { + TeamShowWidget* pts = dynamic_cast(it.value()); + if(!pts) throw; + pts->setInteractivity(interactive); + } } void FrameTeams::resetColors() diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/game.cpp --- a/QTfrontend/game.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/game.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -37,315 +37,315 @@ ammostr(ammo), m_pTeamSelWidget(pTeamSelWidget) { - this->config = config; - this->gamecfg = gamecfg; - TeamCount = 0; + this->config = config; + this->gamecfg = gamecfg; + TeamCount = 0; } HWGame::~HWGame() { - SetGameState(gsDestroyed); + SetGameState(gsDestroyed); } void HWGame::onClientDisconnect() { - switch (gameType) { - case gtDemo: break; - case gtNet: - emit HaveRecord(true, demo); - break; - default: - if (gameState == gsInterrupted) emit HaveRecord(false, demo); - else if (gameState == gsFinished) emit HaveRecord(true, demo); - } - SetGameState(gsStopped); + switch (gameType) { + case gtDemo: break; + case gtNet: + emit HaveRecord(true, demo); + break; + default: + if (gameState == gsInterrupted) emit HaveRecord(false, demo); + else if (gameState == gsFinished) emit HaveRecord(true, demo); + } + SetGameState(gsStopped); } void HWGame::commonConfig() { - QByteArray buf; - QString gt; - switch (gameType) { - case gtDemo: - gt = "TD"; - break; - case gtNet: - gt = "TN"; - break; - default: - gt = "TL"; - } - HWProto::addStringToBuffer(buf, gt); + QByteArray buf; + QString gt; + switch (gameType) { + case gtDemo: + gt = "TD"; + break; + case gtNet: + gt = "TN"; + break; + default: + gt = "TL"; + } + HWProto::addStringToBuffer(buf, gt); - HWProto::addStringListToBuffer(buf, gamecfg->getFullConfig()); + HWProto::addStringListToBuffer(buf, gamecfg->getFullConfig()); - if (m_pTeamSelWidget) - { - QList teams = m_pTeamSelWidget->getPlayingTeams(); - for(QList::iterator it = teams.begin(); it != teams.end(); ++it) - { - HWProto::addStringListToBuffer(buf, - (*it).TeamGameConfig(gamecfg->getInitHealth())); - HWProto::addStringToBuffer(buf, QString("eammstore %1").arg(ammostr)); - } - } - RawSendIPC(buf); + if (m_pTeamSelWidget) + { + QList teams = m_pTeamSelWidget->getPlayingTeams(); + for(QList::iterator it = teams.begin(); it != teams.end(); ++it) + { + HWProto::addStringListToBuffer(buf, + (*it).TeamGameConfig(gamecfg->getInitHealth())); + HWProto::addStringToBuffer(buf, QString("eammstore %1").arg(ammostr)); + } + } + RawSendIPC(buf); } void HWGame::SendConfig() { - commonConfig(); + commonConfig(); } void HWGame::SendQuickConfig() { - QByteArray teamscfg; + QByteArray teamscfg; - HWProto::addStringToBuffer(teamscfg, "TL"); - HWProto::addStringToBuffer(teamscfg, QString("etheme %1") - .arg((Themes->size() > 0) ? Themes->at(rand() % Themes->size()) : "steel")); - HWProto::addStringToBuffer(teamscfg, "eseed " + QUuid::createUuid().toString()); + HWProto::addStringToBuffer(teamscfg, "TL"); + HWProto::addStringToBuffer(teamscfg, QString("etheme %1") + .arg((Themes->size() > 0) ? Themes->at(rand() % Themes->size()) : "steel")); + HWProto::addStringToBuffer(teamscfg, "eseed " + QUuid::createUuid().toString()); - HWNamegen namegen; + HWNamegen namegen; - HWTeam * team1; - team1 = new HWTeam; - team1->difficulty = 0; - team1->teamColor = *color1; - team1->numHedgehogs = 4; - namegen.TeamRandomNames(team1,TRUE); - HWProto::addStringListToBuffer(teamscfg, - team1->TeamGameConfig(100)); + HWTeam * team1; + team1 = new HWTeam; + team1->difficulty = 0; + team1->teamColor = *color1; + team1->numHedgehogs = 4; + namegen.TeamRandomNames(team1,TRUE); + HWProto::addStringListToBuffer(teamscfg, + team1->TeamGameConfig(100)); - HWTeam * team2; - team2 = new HWTeam; - team2->difficulty = 4; - team2->teamColor = *color2; - team2->numHedgehogs = 4; - namegen.TeamRandomNames(team2,TRUE); - HWProto::addStringListToBuffer(teamscfg, - team2->TeamGameConfig(100)); + HWTeam * team2; + team2 = new HWTeam; + team2->difficulty = 4; + team2->teamColor = *color2; + team2->numHedgehogs = 4; + namegen.TeamRandomNames(team2,TRUE); + HWProto::addStringListToBuffer(teamscfg, + team2->TeamGameConfig(100)); - HWProto::addStringToBuffer(teamscfg, "eammstore " + *cDefaultAmmoStore); - HWProto::addStringToBuffer(teamscfg, "eammstore " + *cDefaultAmmoStore); - RawSendIPC(teamscfg); + HWProto::addStringToBuffer(teamscfg, "eammstore " + *cDefaultAmmoStore); + HWProto::addStringToBuffer(teamscfg, "eammstore " + *cDefaultAmmoStore); + RawSendIPC(teamscfg); } void HWGame::SendTrainingConfig() { - QByteArray traincfg; - HWProto::addStringToBuffer(traincfg, "TL"); + QByteArray traincfg; + HWProto::addStringToBuffer(traincfg, "TL"); - HWProto::addStringToBuffer(traincfg, "escript " + datadir->absolutePath() + "/Missions/" + training + ".hwt"); + HWProto::addStringToBuffer(traincfg, "escript " + datadir->absolutePath() + "/Missions/" + training + ".hwt"); - RawSendIPC(traincfg); + RawSendIPC(traincfg); } void HWGame::SendNetConfig() { - commonConfig(); + commonConfig(); } void HWGame::ParseMessage(const QByteArray & msg) { - switch(msg.at(1)) { - case '?': { - SendIPC("!"); - break; - } - case 'C': { - switch (gameType) { - case gtLocal: { - SendConfig(); - break; - } - case gtQLocal: { - SendQuickConfig(); - break; - } - case gtDemo: break; - case gtNet: { - SendNetConfig(); - break; - } - case gtTraining: { - SendTrainingConfig(); - break; - } - } - break; - } - case 'E': { - int size = msg.size(); - emit ErrorMessage(QString("Last two engine messages:\n") + QString().append(msg.mid(2)).left(size - 4)); - return; - } - case 'K': { - ulong kb = msg.mid(2).toULong(); - if (kb==1) { - qWarning("%s", KBMessages[kb - 1].toLocal8Bit().constData()); - return; - } - if (kb && kb <= KBmsgsCount) - { - emit ErrorMessage(KBMessages[kb - 1]); - } - return; - } - case 'i': { - emit GameStats(msg.at(2), QString::fromUtf8(msg.mid(3))); - break; - } - case 'Q': { - SetGameState(gsInterrupted); - break; - } - case 'q': { - SetGameState(gsFinished); - break; - } - case 's': { - int size = msg.size(); - QString msgbody = QString::fromUtf8(msg.mid(2).left(size - 4)); - emit SendChat(msgbody); - // FIXME: /me command doesn't work here - QByteArray buf; - HWProto::addStringToBuffer(buf, "s" + HWProto::formatChatMsg(config->netNick(), msgbody) + "\x20\x20"); - demo.append(buf); - break; - } - case 'b': { - int size = msg.size(); - QString msgbody = QString::fromUtf8(msg.mid(2).left(size - 4)); - emit SendTeamMessage(msgbody); - break; - } - default: { - if (gameType == gtNet) - { - emit SendNet(msg); - } - if (msg.at(1) != 's') - demo.append(msg); - } - } + switch(msg.at(1)) { + case '?': { + SendIPC("!"); + break; + } + case 'C': { + switch (gameType) { + case gtLocal: { + SendConfig(); + break; + } + case gtQLocal: { + SendQuickConfig(); + break; + } + case gtDemo: break; + case gtNet: { + SendNetConfig(); + break; + } + case gtTraining: { + SendTrainingConfig(); + break; + } + } + break; + } + case 'E': { + int size = msg.size(); + emit ErrorMessage(QString("Last two engine messages:\n") + QString().append(msg.mid(2)).left(size - 4)); + return; + } + case 'K': { + ulong kb = msg.mid(2).toULong(); + if (kb==1) { + qWarning("%s", KBMessages[kb - 1].toLocal8Bit().constData()); + return; + } + if (kb && kb <= KBmsgsCount) + { + emit ErrorMessage(KBMessages[kb - 1]); + } + return; + } + case 'i': { + emit GameStats(msg.at(2), QString::fromUtf8(msg.mid(3))); + break; + } + case 'Q': { + SetGameState(gsInterrupted); + break; + } + case 'q': { + SetGameState(gsFinished); + break; + } + case 's': { + int size = msg.size(); + QString msgbody = QString::fromUtf8(msg.mid(2).left(size - 4)); + emit SendChat(msgbody); + // FIXME: /me command doesn't work here + QByteArray buf; + HWProto::addStringToBuffer(buf, "s" + HWProto::formatChatMsg(config->netNick(), msgbody) + "\x20\x20"); + demo.append(buf); + break; + } + case 'b': { + int size = msg.size(); + QString msgbody = QString::fromUtf8(msg.mid(2).left(size - 4)); + emit SendTeamMessage(msgbody); + break; + } + default: { + if (gameType == gtNet) + { + emit SendNet(msg); + } + if (msg.at(1) != 's') + demo.append(msg); + } + } } void HWGame::FromNet(const QByteArray & msg) { - RawSendIPC(msg); + RawSendIPC(msg); } void HWGame::FromNetChat(const QString & msg) { - QByteArray buf; - HWProto::addStringToBuffer(buf, 's' + msg + "\x20\x20"); - RawSendIPC(buf); + QByteArray buf; + HWProto::addStringToBuffer(buf, 's' + msg + "\x20\x20"); + RawSendIPC(buf); } void HWGame::onClientRead() { - quint8 msglen; - quint32 bufsize; - while (!readbuffer.isEmpty() && ((bufsize = readbuffer.size()) > 0) && - ((msglen = readbuffer.data()[0]) < bufsize)) - { - QByteArray msg = readbuffer.left(msglen + 1); - readbuffer.remove(0, msglen + 1); - ParseMessage(msg); - } + quint8 msglen; + quint32 bufsize; + while (!readbuffer.isEmpty() && ((bufsize = readbuffer.size()) > 0) && + ((msglen = readbuffer.data()[0]) < bufsize)) + { + QByteArray msg = readbuffer.left(msglen + 1); + readbuffer.remove(0, msglen + 1); + ParseMessage(msg); + } } QStringList HWGame::setArguments() { - QStringList arguments; - QRect resolution = config->vid_Resolution(); - arguments << cfgdir->absolutePath(); - arguments << QString::number(resolution.width()); - arguments << QString::number(resolution.height()); - arguments << QString::number(config->bitDepth()); // bpp - arguments << QString("%1").arg(ipc_port); - arguments << (config->vid_Fullscreen() ? "1" : "0"); - arguments << (config->isSoundEnabled() ? "1" : "0"); + QStringList arguments; + QRect resolution = config->vid_Resolution(); + arguments << cfgdir->absolutePath(); + arguments << QString::number(resolution.width()); + arguments << QString::number(resolution.height()); + arguments << QString::number(config->bitDepth()); // bpp + arguments << QString("%1").arg(ipc_port); + arguments << (config->vid_Fullscreen() ? "1" : "0"); + arguments << (config->isSoundEnabled() ? "1" : "0"); #ifdef _WIN32 - arguments << (config->isSoundHardware() ? "1" : "0"); + arguments << (config->isSoundHardware() ? "1" : "0"); #else - arguments << "0"; + arguments << "0"; #endif - arguments << (config->isWeaponTooltip() ? "1" : "0"); - arguments << tr("en.txt"); - arguments << QString::number(config->volume()); // sound volume - arguments << QString::number(config->timerInterval()); - arguments << datadir->absolutePath(); - arguments << (config->isShowFPSEnabled() ? "1" : "0"); - arguments << (config->isAltDamageEnabled() ? "1" : "0"); - arguments << config->netNick().toUtf8().toBase64(); - arguments << (config->isMusicEnabled() ? "1" : "0"); - arguments << (config->isReducedQuality() ? "1" : "0"); - return arguments; + arguments << (config->isWeaponTooltip() ? "1" : "0"); + arguments << tr("en.txt"); + arguments << QString::number(config->volume()); // sound volume + arguments << QString::number(config->timerInterval()); + arguments << datadir->absolutePath(); + arguments << (config->isShowFPSEnabled() ? "1" : "0"); + arguments << (config->isAltDamageEnabled() ? "1" : "0"); + arguments << config->netNick().toUtf8().toBase64(); + arguments << (config->isMusicEnabled() ? "1" : "0"); + arguments << (config->isReducedQuality() ? "1" : "0"); + return arguments; } void HWGame::AddTeam(const QString & teamname) { - if (TeamCount == 5) return; - teams[TeamCount] = teamname; - TeamCount++; + if (TeamCount == 5) return; + teams[TeamCount] = teamname; + TeamCount++; } void HWGame::PlayDemo(const QString & demofilename) { - gameType = gtDemo; - QFile demofile(demofilename); - if (!demofile.open(QIODevice::ReadOnly)) - { - emit ErrorMessage(tr("Cannot open demofile %1").arg(demofilename)); - return ; - } + gameType = gtDemo; + QFile demofile(demofilename); + if (!demofile.open(QIODevice::ReadOnly)) + { + emit ErrorMessage(tr("Cannot open demofile %1").arg(demofilename)); + return ; + } - // read demo - toSendBuf = demofile.readAll(); + // read demo + toSendBuf = demofile.readAll(); - // run engine - demo.clear(); - Start(); - SetGameState(gsStarted); + // run engine + demo.clear(); + Start(); + SetGameState(gsStarted); } void HWGame::StartNet() { - gameType = gtNet; - demo.clear(); - Start(); - SetGameState(gsStarted); + gameType = gtNet; + demo.clear(); + Start(); + SetGameState(gsStarted); } void HWGame::StartLocal() { - gameType = gtLocal; - demo.clear(); - Start(); - SetGameState(gsStarted); + gameType = gtLocal; + demo.clear(); + Start(); + SetGameState(gsStarted); } void HWGame::StartQuick() { - gameType = gtQLocal; - demo.clear(); - Start(); - SetGameState(gsStarted); + gameType = gtQLocal; + demo.clear(); + Start(); + SetGameState(gsStarted); } void HWGame::StartTraining(const QString & file) { - gameType = gtTraining; - training = file; - demo.clear(); - Start(); - SetGameState(gsStarted); + gameType = gtTraining; + training = file; + demo.clear(); + Start(); + SetGameState(gsStarted); } void HWGame::SetGameState(GameState state) { - gameState = state; - emit GameStateChanged(state); + gameState = state; + emit GameStateChanged(state); } diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/game.h --- a/QTfrontend/game.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/game.h Sat Mar 06 10:59:20 2010 +0000 @@ -30,71 +30,71 @@ class TeamSelWidget; enum GameState { - gsNotStarted = 0, - gsStarted = 1, - gsInterrupted = 2, - gsFinished = 3, - gsStopped = 4, - gsDestroyed = 5 + gsNotStarted = 0, + gsStarted = 1, + gsInterrupted = 2, + gsFinished = 3, + gsStopped = 4, + gsDestroyed = 5 }; class HWGame : public TCPBase { - Q_OBJECT + Q_OBJECT public: - HWGame(GameUIConfig * config, GameCFGWidget * gamecfg, QString ammo, TeamSelWidget* pTeamSelWidget = 0); - virtual ~HWGame(); - void AddTeam(const QString & team); - void PlayDemo(const QString & demofilename); - void StartLocal(); - void StartQuick(); - void StartNet(); - void StartTraining(const QString & file); + HWGame(GameUIConfig * config, GameCFGWidget * gamecfg, QString ammo, TeamSelWidget* pTeamSelWidget = 0); + virtual ~HWGame(); + void AddTeam(const QString & team); + void PlayDemo(const QString & demofilename); + void StartLocal(); + void StartQuick(); + void StartNet(); + void StartTraining(const QString & file); protected: - virtual QStringList setArguments(); - virtual void onClientRead(); - virtual void onClientDisconnect(); + virtual QStringList setArguments(); + virtual void onClientRead(); + virtual void onClientDisconnect(); signals: - void SendNet(const QByteArray & msg); - void SendChat(const QString & msg); - void SendTeamMessage(const QString & msg); - void GameStateChanged(GameState gameState); - void GameStats(char type, const QString & info); - void HaveRecord(bool isDemo, const QByteArray & record); - void ErrorMessage(const QString &); + void SendNet(const QByteArray & msg); + void SendChat(const QString & msg); + void SendTeamMessage(const QString & msg); + void GameStateChanged(GameState gameState); + void GameStats(char type, const QString & info); + void HaveRecord(bool isDemo, const QByteArray & record); + void ErrorMessage(const QString &); public slots: - void FromNet(const QByteArray & msg); - void FromNetChat(const QString & msg); + void FromNet(const QByteArray & msg); + void FromNetChat(const QString & msg); private: - enum GameType { - gtLocal = 1, - gtQLocal = 2, - gtDemo = 3, - gtNet = 4, - gtTraining = 5 + enum GameType { + gtLocal = 1, + gtQLocal = 2, + gtDemo = 3, + gtNet = 4, + gtTraining = 5 }; - char msgbuf[MAXMSGCHARS]; - QString teams[5]; - QString ammostr; - int TeamCount; - GameUIConfig * config; - GameCFGWidget * gamecfg; - TeamSelWidget* m_pTeamSelWidget; - GameType gameType; - GameState gameState; + char msgbuf[MAXMSGCHARS]; + QString teams[5]; + QString ammostr; + int TeamCount; + GameUIConfig * config; + GameCFGWidget * gamecfg; + TeamSelWidget* m_pTeamSelWidget; + GameType gameType; + GameState gameState; - void commonConfig(); - void SendConfig(); - void SendQuickConfig(); - void SendNetConfig(); - void SendTrainingConfig(); - void ParseMessage(const QByteArray & msg); - void SetGameState(GameState state); + void commonConfig(); + void SendConfig(); + void SendQuickConfig(); + void SendNetConfig(); + void SendTrainingConfig(); + void ParseMessage(const QByteArray & msg); + void SetGameState(GameState state); }; #endif diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/gamecfgwidget.cpp --- a/QTfrontend/gamecfgwidget.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/gamecfgwidget.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -34,242 +34,242 @@ GameCFGWidget::GameCFGWidget(QWidget* parent, bool externalControl) : QGroupBox(parent), mainLayout(this) { - mainLayout.setMargin(0); -// mainLayout.setSizeConstraint(QLayout::SetMinimumSize); + mainLayout.setMargin(0); +// mainLayout.setSizeConstraint(QLayout::SetMinimumSize); - pMapContainer = new HWMapContainer(this); - mainLayout.addWidget(pMapContainer, 0, 0); + pMapContainer = new HWMapContainer(this); + mainLayout.addWidget(pMapContainer, 0, 0); - IconedGroupBox *GBoxOptions = new IconedGroupBox(this); - GBoxOptions->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); - mainLayout.addWidget(GBoxOptions); + IconedGroupBox *GBoxOptions = new IconedGroupBox(this); + GBoxOptions->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + mainLayout.addWidget(GBoxOptions); - QGridLayout *GBoxOptionsLayout = new QGridLayout(GBoxOptions); + QGridLayout *GBoxOptionsLayout = new QGridLayout(GBoxOptions); - GameSchemes = new QComboBox(GBoxOptions); - GBoxOptionsLayout->addWidget(GameSchemes, 0, 1); - connect(GameSchemes, SIGNAL(currentIndexChanged(int)), this, SLOT(schemeChanged(int))); + GameSchemes = new QComboBox(GBoxOptions); + GBoxOptionsLayout->addWidget(GameSchemes, 0, 1); + connect(GameSchemes, SIGNAL(currentIndexChanged(int)), this, SLOT(schemeChanged(int))); - GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Game scheme"), GBoxOptions), 0, 0); + GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Game scheme"), GBoxOptions), 0, 0); - QPixmap pmEdit(":/res/edit.png"); - - QPushButton * goToSchemePage = new QPushButton(GBoxOptions); - //goToSchemePage->setText(tr("Edit schemes")); + QPixmap pmEdit(":/res/edit.png"); + + QPushButton * goToSchemePage = new QPushButton(GBoxOptions); + //goToSchemePage->setText(tr("Edit schemes")); goToSchemePage->setToolTip(tr("Edit schemes")); - goToSchemePage->setIconSize(pmEdit.size()); - goToSchemePage->setIcon(pmEdit); - goToSchemePage->setMaximumWidth(pmEdit.width() + 6); - GBoxOptionsLayout->addWidget(goToSchemePage, 0, 2); - connect(goToSchemePage, SIGNAL(clicked()), this, SIGNAL(goToSchemes())); + goToSchemePage->setIconSize(pmEdit.size()); + goToSchemePage->setIcon(pmEdit); + goToSchemePage->setMaximumWidth(pmEdit.width() + 6); + GBoxOptionsLayout->addWidget(goToSchemePage, 0, 2); + connect(goToSchemePage, SIGNAL(clicked()), this, SIGNAL(goToSchemes())); - GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Weapons"), GBoxOptions), 1, 0); + GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Weapons"), GBoxOptions), 1, 0); - WeaponsName = new QComboBox(GBoxOptions); - GBoxOptionsLayout->addWidget(WeaponsName, 1, 1); + WeaponsName = new QComboBox(GBoxOptions); + GBoxOptionsLayout->addWidget(WeaponsName, 1, 1); - connect(WeaponsName, SIGNAL(currentIndexChanged(int)), this, SLOT(ammoChanged(int))); + connect(WeaponsName, SIGNAL(currentIndexChanged(int)), this, SLOT(ammoChanged(int))); - QPushButton * goToWeaponPage = new QPushButton(GBoxOptions); - //goToWeaponPage->setText(tr("Edit weapons")); + QPushButton * goToWeaponPage = new QPushButton(GBoxOptions); + //goToWeaponPage->setText(tr("Edit weapons")); goToWeaponPage->setToolTip(tr("Edit weapons")); - goToWeaponPage->setIconSize(pmEdit.size()); - goToWeaponPage->setIcon(pmEdit); - goToWeaponPage->setMaximumWidth(pmEdit.width() + 6); - GBoxOptionsLayout->addWidget(goToWeaponPage, 1, 2); + goToWeaponPage->setIconSize(pmEdit.size()); + goToWeaponPage->setIcon(pmEdit); + goToWeaponPage->setMaximumWidth(pmEdit.width() + 6); + GBoxOptionsLayout->addWidget(goToWeaponPage, 1, 2); - connect(goToWeaponPage, SIGNAL(clicked()), this, SLOT(jumpToWeapons())); + connect(goToWeaponPage, SIGNAL(clicked()), this, SLOT(jumpToWeapons())); - connect(pMapContainer, SIGNAL(seedChanged(const QString &)), this, SLOT(seedChanged(const QString &))); - connect(pMapContainer, SIGNAL(mapChanged(const QString &)), this, SLOT(mapChanged(const QString &))); - connect(pMapContainer, SIGNAL(themeChanged(const QString &)), this, SLOT(themeChanged(const QString &))); - connect(pMapContainer, SIGNAL(newTemplateFilter(int)), this, SLOT(templateFilterChanged(int))); + connect(pMapContainer, SIGNAL(seedChanged(const QString &)), this, SLOT(seedChanged(const QString &))); + connect(pMapContainer, SIGNAL(mapChanged(const QString &)), this, SLOT(mapChanged(const QString &))); + connect(pMapContainer, SIGNAL(themeChanged(const QString &)), this, SLOT(themeChanged(const QString &))); + connect(pMapContainer, SIGNAL(newTemplateFilter(int)), this, SLOT(templateFilterChanged(int))); } void GameCFGWidget::jumpToWeapons() { - emit goToWeapons(WeaponsName->currentText()); + emit goToWeapons(WeaponsName->currentText()); } QVariant GameCFGWidget::schemeData(int column) const { - return GameSchemes->model()->data(GameSchemes->model()->index(GameSchemes->currentIndex(), column)); + return GameSchemes->model()->data(GameSchemes->model()->index(GameSchemes->currentIndex(), column)); } quint32 GameCFGWidget::getGameFlags() const { - quint32 result = 0; + quint32 result = 0; - if (schemeData(1).toBool()) - result |= 0x01; - if (schemeData(2).toBool()) - result |= 0x10; - if (schemeData(3).toBool()) - result |= 0x04; - if (schemeData(4).toBool()) - result |= 0x08; - if (schemeData(5).toBool()) - result |= 0x20; - if (schemeData(6).toBool()) - result |= 0x40; - if (schemeData(7).toBool()) - result |= 0x80; - if (schemeData(8).toBool()) - result |= 0x100; - if (schemeData(9).toBool()) - result |= 0x200; - if (schemeData(10).toBool()) - result |= 0x400; - if (schemeData(11).toBool()) - result |= 0x800; - if (schemeData(12).toBool()) - result |= 0x2000; - if (schemeData(13).toBool()) - result |= 0x4000; - if (schemeData(14).toBool()) - result |= 0x8000; - if (schemeData(15).toBool()) - result |= 0x10000; - if (schemeData(16).toBool()) - result |= 0x20000; + if (schemeData(1).toBool()) + result |= 0x01; + if (schemeData(2).toBool()) + result |= 0x10; + if (schemeData(3).toBool()) + result |= 0x04; + if (schemeData(4).toBool()) + result |= 0x08; + if (schemeData(5).toBool()) + result |= 0x20; + if (schemeData(6).toBool()) + result |= 0x40; + if (schemeData(7).toBool()) + result |= 0x80; + if (schemeData(8).toBool()) + result |= 0x100; + if (schemeData(9).toBool()) + result |= 0x200; + if (schemeData(10).toBool()) + result |= 0x400; + if (schemeData(11).toBool()) + result |= 0x800; + if (schemeData(12).toBool()) + result |= 0x2000; + if (schemeData(13).toBool()) + result |= 0x4000; + if (schemeData(14).toBool()) + result |= 0x8000; + if (schemeData(15).toBool()) + result |= 0x10000; + if (schemeData(16).toBool()) + result |= 0x20000; - return result; + return result; } quint32 GameCFGWidget::getInitHealth() const { - return schemeData(19).toInt(); + return schemeData(19).toInt(); } QStringList GameCFGWidget::getFullConfig() const { - QStringList sl; - sl.append("eseed " + pMapContainer->getCurrentSeed()); - sl.append(QString("e$gmflags %1").arg(getGameFlags())); - sl.append(QString("e$damagepct %1").arg(schemeData(17).toInt())); - sl.append(QString("e$turntime %1").arg(schemeData(18).toInt() * 1000)); - sl.append(QString("e$minestime %1").arg(schemeData(22).toInt() * 1000)); - sl.append(QString("e$landadds %1").arg(schemeData(23).toInt())); - sl.append(QString("e$sd_turns %1").arg(schemeData(20).toInt())); - sl.append(QString("e$casefreq %1").arg(schemeData(21).toInt())); - sl.append(QString("e$minedudpct %1").arg(schemeData(24).toInt())); - sl.append(QString("e$explosives %1").arg(schemeData(25).toInt())); - sl.append(QString("e$template_filter %1").arg(pMapContainer->getTemplateFilter())); + QStringList sl; + sl.append("eseed " + pMapContainer->getCurrentSeed()); + sl.append(QString("e$gmflags %1").arg(getGameFlags())); + sl.append(QString("e$damagepct %1").arg(schemeData(17).toInt())); + sl.append(QString("e$turntime %1").arg(schemeData(18).toInt() * 1000)); + sl.append(QString("e$minestime %1").arg(schemeData(22).toInt() * 1000)); + sl.append(QString("e$landadds %1").arg(schemeData(23).toInt())); + sl.append(QString("e$sd_turns %1").arg(schemeData(20).toInt())); + sl.append(QString("e$casefreq %1").arg(schemeData(21).toInt())); + sl.append(QString("e$minedudpct %1").arg(schemeData(24).toInt())); + sl.append(QString("e$explosives %1").arg(schemeData(25).toInt())); + sl.append(QString("e$template_filter %1").arg(pMapContainer->getTemplateFilter())); - QString currentMap = pMapContainer->getCurrentMap(); - if (currentMap.size() > 0) - sl.append("emap " + currentMap); - sl.append("etheme " + pMapContainer->getCurrentTheme()); - return sl; + QString currentMap = pMapContainer->getCurrentMap(); + if (currentMap.size() > 0) + sl.append("emap " + currentMap); + sl.append("etheme " + pMapContainer->getCurrentTheme()); + return sl; } void GameCFGWidget::setNetAmmo(const QString& name, const QString& ammo) { - bool illegal = ammo.size() != cDefaultAmmoStore->size(); - if (illegal) - QMessageBox::critical(this, tr("Error"), tr("Illegal ammo scheme")); + bool illegal = ammo.size() != cDefaultAmmoStore->size(); + if (illegal) + QMessageBox::critical(this, tr("Error"), tr("Illegal ammo scheme")); - int pos = WeaponsName->findText(name); - if ((pos == -1) || illegal) { // prevent from overriding schemes with bad ones - WeaponsName->addItem(name, ammo); - WeaponsName->setCurrentIndex(WeaponsName->count() - 1); - } else { - WeaponsName->setItemData(pos, ammo); - WeaponsName->setCurrentIndex(pos); - } + int pos = WeaponsName->findText(name); + if ((pos == -1) || illegal) { // prevent from overriding schemes with bad ones + WeaponsName->addItem(name, ammo); + WeaponsName->setCurrentIndex(WeaponsName->count() - 1); + } else { + WeaponsName->setItemData(pos, ammo); + WeaponsName->setCurrentIndex(pos); + } } void GameCFGWidget::fullNetConfig() { - ammoChanged(WeaponsName->currentIndex()); + ammoChanged(WeaponsName->currentIndex()); - seedChanged(pMapContainer->getCurrentSeed()); - templateFilterChanged(pMapContainer->getTemplateFilter()); - themeChanged(pMapContainer->getCurrentTheme()); + seedChanged(pMapContainer->getCurrentSeed()); + templateFilterChanged(pMapContainer->getTemplateFilter()); + themeChanged(pMapContainer->getCurrentTheme()); - schemeChanged(GameSchemes->currentIndex()); + schemeChanged(GameSchemes->currentIndex()); - // map must be the last - QString map = pMapContainer->getCurrentMap(); - if (map.size()) - mapChanged(map); + // map must be the last + QString map = pMapContainer->getCurrentMap(); + if (map.size()) + mapChanged(map); } void GameCFGWidget::setParam(const QString & param, const QStringList & slValue) { - if (slValue.size() == 1) - { - QString value = slValue[0]; - if (param == "MAP") { - pMapContainer->setMap(value); - return; - } - if (param == "SEED") { - pMapContainer->setSeed(value); - return; - } - if (param == "THEME") { - pMapContainer->setTheme(value); - return; - } - if (param == "TEMPLATE") { - pMapContainer->setTemplateFilter(value.toUInt()); - return; - } - } + if (slValue.size() == 1) + { + QString value = slValue[0]; + if (param == "MAP") { + pMapContainer->setMap(value); + return; + } + if (param == "SEED") { + pMapContainer->setSeed(value); + return; + } + if (param == "THEME") { + pMapContainer->setTheme(value); + return; + } + if (param == "TEMPLATE") { + pMapContainer->setTemplateFilter(value.toUInt()); + return; + } + } - if (slValue.size() == 2) - { - if (param == "AMMO") { - setNetAmmo(slValue[0], slValue[1]); - return; - } - } + if (slValue.size() == 2) + { + if (param == "AMMO") { + setNetAmmo(slValue[0], slValue[1]); + return; + } + } - qWarning("Got bad config param from net"); + qWarning("Got bad config param from net"); } void GameCFGWidget::ammoChanged(int index) { - if (index >= 0) - emit paramChanged( - "AMMO", - QStringList() << WeaponsName->itemText(index) << WeaponsName->itemData(index).toString() - ); + if (index >= 0) + emit paramChanged( + "AMMO", + QStringList() << WeaponsName->itemText(index) << WeaponsName->itemData(index).toString() + ); } void GameCFGWidget::mapChanged(const QString & value) { - emit paramChanged("MAP", QStringList(value)); + emit paramChanged("MAP", QStringList(value)); } void GameCFGWidget::templateFilterChanged(int value) { - emit paramChanged("TEMPLATE", QStringList(QString::number(value))); + emit paramChanged("TEMPLATE", QStringList(QString::number(value))); } void GameCFGWidget::seedChanged(const QString & value) { - emit paramChanged("SEED", QStringList(value)); + emit paramChanged("SEED", QStringList(value)); } void GameCFGWidget::themeChanged(const QString & value) { - emit paramChanged("THEME", QStringList(value)); + emit paramChanged("THEME", QStringList(value)); } void GameCFGWidget::schemeChanged(int value) { - QStringList sl; + QStringList sl; - int size = GameSchemes->model()->columnCount(); - for(int i = 0; i < size; ++i) - sl << schemeData(i).toString(); + int size = GameSchemes->model()->columnCount(); + for(int i = 0; i < size; ++i) + sl << schemeData(i).toString(); - emit paramChanged("SCHEME", sl); + emit paramChanged("SCHEME", sl); } void GameCFGWidget::resendSchemeData() { - schemeChanged(GameSchemes->currentIndex()); + schemeChanged(GameSchemes->currentIndex()); } diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/gamecfgwidget.h --- a/QTfrontend/gamecfgwidget.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/gamecfgwidget.h Sat Mar 06 10:59:20 2010 +0000 @@ -33,46 +33,46 @@ class GameCFGWidget : public QGroupBox { - Q_OBJECT + Q_OBJECT public: - GameCFGWidget(QWidget* parent, bool externalControl=false); - quint32 getGameFlags() const; - quint32 getInitHealth() const; - QStringList getFullConfig() const; - QComboBox * GameSchemes; - QComboBox * WeaponsName; - HWMapContainer* pMapContainer; - QTableView * tv; + GameCFGWidget(QWidget* parent, bool externalControl=false); + quint32 getGameFlags() const; + quint32 getInitHealth() const; + QStringList getFullConfig() const; + QComboBox * GameSchemes; + QComboBox * WeaponsName; + HWMapContainer* pMapContainer; + QTableView * tv; public slots: - void setParam(const QString & param, const QStringList & value); - void fullNetConfig(); - void resendSchemeData(); + void setParam(const QString & param, const QStringList & value); + void fullNetConfig(); + void resendSchemeData(); signals: - void paramChanged(const QString & param, const QStringList & value); - void goToSchemes(); - void goToWeapons(const QString & name); + void paramChanged(const QString & param, const QStringList & value); + void goToSchemes(); + void goToWeapons(const QString & name); private slots: - void ammoChanged(int index); - void mapChanged(const QString &); - void templateFilterChanged(int); - void seedChanged(const QString &); - void themeChanged(const QString &); - void schemeChanged(int); - void jumpToWeapons(); + void ammoChanged(int index); + void mapChanged(const QString &); + void templateFilterChanged(int); + void seedChanged(const QString &); + void themeChanged(const QString &); + void schemeChanged(int); + void jumpToWeapons(); private: - QGridLayout mainLayout; + QGridLayout mainLayout; - QString curNetAmmoName; - QString curNetAmmo; + QString curNetAmmoName; + QString curNetAmmo; - void setNetAmmo(const QString& name, const QString& ammo); + void setNetAmmo(const QString& name, const QString& ammo); - QVariant schemeData(int column) const; + QVariant schemeData(int column) const; }; #endif // GAMECONFIGWIDGET_H diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/gameuiconfig.cpp --- a/QTfrontend/gameuiconfig.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/gameuiconfig.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -30,77 +30,77 @@ #include "fpsedit.h" GameUIConfig::GameUIConfig(HWForm * FormWidgets, const QString & fileName) - : QSettings(fileName, QSettings::IniFormat) + : QSettings(fileName, QSettings::IniFormat) { - Form = FormWidgets; + Form = FormWidgets; - connect(Form->ui.pageOptions->CBEnableFrontendMusic, SIGNAL(toggled(bool)), Form, SLOT(Music(bool))); + connect(Form->ui.pageOptions->CBEnableFrontendMusic, SIGNAL(toggled(bool)), Form, SLOT(Music(bool))); - //Form->resize(value("window/width", 640).toUInt(), value("window/height", 450).toUInt()); - resizeToConfigValues(); + //Form->resize(value("window/width", 640).toUInt(), value("window/height", 450).toUInt()); + resizeToConfigValues(); - Form->ui.pageOptions->WeaponTooltip->setChecked(value("misc/weaponTooltip", true).toBool()); + Form->ui.pageOptions->WeaponTooltip->setChecked(value("misc/weaponTooltip", true).toBool()); - int t = Form->ui.pageOptions->CBResolution->findText(value("video/resolution").toString()); - Form->ui.pageOptions->CBResolution->setCurrentIndex((t < 0) ? 0 : t); - Form->ui.pageOptions->CBFullscreen->setChecked(value("video/fullscreen", false).toBool()); - bool ffscr=value("video/frontendfullscreen", false).toBool(); - Form->ui.pageOptions->CBFrontendFullscreen->setChecked(ffscr); + int t = Form->ui.pageOptions->CBResolution->findText(value("video/resolution").toString()); + Form->ui.pageOptions->CBResolution->setCurrentIndex((t < 0) ? 0 : t); + Form->ui.pageOptions->CBFullscreen->setChecked(value("video/fullscreen", false).toBool()); + bool ffscr=value("video/frontendfullscreen", false).toBool(); + Form->ui.pageOptions->CBFrontendFullscreen->setChecked(ffscr); - Form->ui.pageOptions->CBReduceQuality->setChecked(value("video/reducequality", false).toBool()); - Form->ui.pageOptions->CBFrontendEffects->setChecked(frontendEffects); - Form->ui.pageOptions->CBEnableSound->setChecked(value("audio/sound", true).toBool()); - Form->ui.pageOptions->CBEnableFrontendSound->setChecked(value("audio/frontendsound", true).toBool()); + Form->ui.pageOptions->CBReduceQuality->setChecked(value("video/reducequality", false).toBool()); + Form->ui.pageOptions->CBFrontendEffects->setChecked(frontendEffects); + Form->ui.pageOptions->CBEnableSound->setChecked(value("audio/sound", true).toBool()); + Form->ui.pageOptions->CBEnableFrontendSound->setChecked(value("audio/frontendsound", true).toBool()); #ifdef _WIN32 -// Form->ui.pageOptions->CBHardwareSound->setChecked(value("audio/hardware", false).toBool()); +// Form->ui.pageOptions->CBHardwareSound->setChecked(value("audio/hardware", false).toBool()); #endif - Form->ui.pageOptions->CBEnableMusic->setChecked(value("audio/music", true).toBool()); - Form->ui.pageOptions->CBEnableFrontendMusic->setChecked(value("audio/frontendmusic", true).toBool()); - Form->ui.pageOptions->volumeBox->setValue(value("audio/volume", 100).toUInt()); + Form->ui.pageOptions->CBEnableMusic->setChecked(value("audio/music", true).toBool()); + Form->ui.pageOptions->CBEnableFrontendMusic->setChecked(value("audio/frontendmusic", true).toBool()); + Form->ui.pageOptions->volumeBox->setValue(value("audio/volume", 100).toUInt()); - QString netNick = value("net/nick", "").toString(); - if (netNick.isEmpty()) - netNick = QInputDialog::getText(Form, - QObject::tr("Nickname"), - QObject::tr("Please enter your nickname"), - QLineEdit::Normal, - QDir::home().dirName()); + QString netNick = value("net/nick", "").toString(); + if (netNick.isEmpty()) + netNick = QInputDialog::getText(Form, + QObject::tr("Nickname"), + QObject::tr("Please enter your nickname"), + QLineEdit::Normal, + QDir::home().dirName()); - Form->ui.pageOptions->editNetNick->setText(netNick); + Form->ui.pageOptions->editNetNick->setText(netNick); - delete netHost; - netHost = new QString(value("net/ip", "").toString()); - netPort = value("net/port", 46631).toUInt(); + delete netHost; + netHost = new QString(value("net/ip", "").toString()); + netPort = value("net/port", 46631).toUInt(); - Form->ui.pageNetServer->leServerDescr->setText(value("net/servername", "hedgewars server").toString()); - Form->ui.pageNetServer->sbPort->setValue(value("net/serverport", 46631).toUInt()); + Form->ui.pageNetServer->leServerDescr->setText(value("net/servername", "hedgewars server").toString()); + Form->ui.pageNetServer->sbPort->setValue(value("net/serverport", 46631).toUInt()); - Form->ui.pageOptions->CBShowFPS->setChecked(value("fps/show", false).toBool()); - Form->ui.pageOptions->fpsedit->setValue(value("fps/interval", 27).toUInt()); + Form->ui.pageOptions->CBShowFPS->setChecked(value("fps/show", false).toBool()); + Form->ui.pageOptions->fpsedit->setValue(value("fps/interval", 27).toUInt()); - Form->ui.pageOptions->CBAltDamage->setChecked(value("misc/altdamage", false).toBool()); - Form->ui.pageOptions->CBNameWithDate->setChecked(value("misc/appendTimeToRecords", false).toBool()); + Form->ui.pageOptions->CBAltDamage->setChecked(value("misc/altdamage", false).toBool()); + Form->ui.pageOptions->CBNameWithDate->setChecked(value("misc/appendTimeToRecords", false).toBool()); #ifdef SPARKLE_ENABLED Form->ui.pageOptions->CBAutoUpdate->setChecked(value("misc/autoUpdate", true).toBool()); #endif - Form->ui.pageOptions->CBLanguage->setCurrentIndex(Form->ui.pageOptions->CBLanguage->findData(value("misc/locale", "").toString())); + Form->ui.pageOptions->CBLanguage->setCurrentIndex(Form->ui.pageOptions->CBLanguage->findData(value("misc/locale", "").toString())); - depth = QApplication::desktop()->depth(); - if (depth < 16) depth = 16; - else if (depth > 16) depth = 32; + depth = QApplication::desktop()->depth(); + if (depth < 16) depth = 16; + else if (depth > 16) depth = 32; } QStringList GameUIConfig::GetTeamsList() { - QStringList teamslist = cfgdir->entryList(QStringList("*.cfg")); - QStringList cleanedList; - for (QStringList::Iterator it = teamslist.begin(); it != teamslist.end(); ++it ) { + QStringList teamslist = cfgdir->entryList(QStringList("*.cfg")); + QStringList cleanedList; + for (QStringList::Iterator it = teamslist.begin(); it != teamslist.end(); ++it ) { QString tmpTeamStr=(*it).replace(QRegExp("^(.*)\\.cfg$"), "\\1"); cleanedList.push_back(tmpTeamStr); - } - return cleanedList; + } + return cleanedList; } void GameUIConfig::resizeToConfigValues() @@ -110,46 +110,46 @@ void GameUIConfig::SaveOptions() { - setValue("video/resolution", Form->ui.pageOptions->CBResolution->currentText()); - setValue("video/fullscreen", vid_Fullscreen()); + setValue("video/resolution", Form->ui.pageOptions->CBResolution->currentText()); + setValue("video/fullscreen", vid_Fullscreen()); - setValue("video/reducequality", isReducedQuality()); + setValue("video/reducequality", isReducedQuality()); - setValue("video/frontendeffects", isFrontendEffects()); + setValue("video/frontendeffects", isFrontendEffects()); - setValue("misc/weaponTooltip", isWeaponTooltip()); + setValue("misc/weaponTooltip", isWeaponTooltip()); - bool ffscr = isFrontendFullscreen(); - setValue("video/frontendfullscreen", ffscr); - emit frontendFullscreen(ffscr); - if (!ffscr) { - setValue("window/width", Form->width()); - setValue("window/height", Form->height()); - } else { - //resizeToConfigValues(); // TODO: why this has been made? - } + bool ffscr = isFrontendFullscreen(); + setValue("video/frontendfullscreen", ffscr); + emit frontendFullscreen(ffscr); + if (!ffscr) { + setValue("window/width", Form->width()); + setValue("window/height", Form->height()); + } else { + //resizeToConfigValues(); // TODO: why this has been made? + } - setValue("audio/sound", isSoundEnabled()); - setValue("audio/frontendsound", isFrontendSoundEnabled()); + setValue("audio/sound", isSoundEnabled()); + setValue("audio/frontendsound", isFrontendSoundEnabled()); #ifdef _WIN32 -// setValue("audio/hardware", isSoundHardware()); +// setValue("audio/hardware", isSoundHardware()); #endif - setValue("audio/music", isMusicEnabled()); - setValue("audio/frontendmusic", isFrontendMusicEnabled()); - setValue("audio/volume", Form->ui.pageOptions->volumeBox->value()); + setValue("audio/music", isMusicEnabled()); + setValue("audio/frontendmusic", isFrontendMusicEnabled()); + setValue("audio/volume", Form->ui.pageOptions->volumeBox->value()); - setValue("net/nick", netNick()); - setValue("net/ip", *netHost); - setValue("net/port", netPort); - setValue("net/servername", Form->ui.pageNetServer->leServerDescr->text()); - setValue("net/serverport", Form->ui.pageNetServer->sbPort->value()); + setValue("net/nick", netNick()); + setValue("net/ip", *netHost); + setValue("net/port", netPort); + setValue("net/servername", Form->ui.pageNetServer->leServerDescr->text()); + setValue("net/serverport", Form->ui.pageNetServer->sbPort->value()); - setValue("fps/show", isShowFPSEnabled()); - setValue("fps/interval", Form->ui.pageOptions->fpsedit->value()); + setValue("fps/show", isShowFPSEnabled()); + setValue("fps/interval", Form->ui.pageOptions->fpsedit->value()); - setValue("misc/altdamage", isAltDamageEnabled()); - setValue("misc/appendTimeToRecords", appendDateTimeToRecordName()); - setValue("misc/locale", language()); + setValue("misc/altdamage", isAltDamageEnabled()); + setValue("misc/appendTimeToRecords", appendDateTimeToRecordName()); + setValue("misc/locale", language()); #ifdef SPARKLE_ENABLED setValue("misc/autoUpdate", isAutoUpdateEnabled()); @@ -159,24 +159,24 @@ QString GameUIConfig::language() { - return Form->ui.pageOptions->CBLanguage->itemData(Form->ui.pageOptions->CBLanguage->currentIndex()).toString(); + return Form->ui.pageOptions->CBLanguage->itemData(Form->ui.pageOptions->CBLanguage->currentIndex()).toString(); } QRect GameUIConfig::vid_Resolution() { - QRect result(0, 0, 640, 480); - QStringList wh = Form->ui.pageOptions->CBResolution->currentText().split('x'); - if (wh.size() == 2) - { - result.setWidth(wh[0].toInt()); - result.setHeight(wh[1].toInt()); - } - return result; + QRect result(0, 0, 640, 480); + QStringList wh = Form->ui.pageOptions->CBResolution->currentText().split('x'); + if (wh.size() == 2) + { + result.setWidth(wh[0].toInt()); + result.setHeight(wh[1].toInt()); + } + return result; } bool GameUIConfig::vid_Fullscreen() { - return Form->ui.pageOptions->CBFullscreen->isChecked(); + return Form->ui.pageOptions->CBFullscreen->isChecked(); } bool GameUIConfig::isReducedQuality() const @@ -200,43 +200,43 @@ bool GameUIConfig::isSoundEnabled() { - return Form->ui.pageOptions->CBEnableSound->isChecked(); + return Form->ui.pageOptions->CBEnableSound->isChecked(); } bool GameUIConfig::isFrontendSoundEnabled() { - return Form->ui.pageOptions->CBEnableFrontendSound->isChecked(); + return Form->ui.pageOptions->CBEnableFrontendSound->isChecked(); } #ifdef _WIN32 bool GameUIConfig::isSoundHardware() { -// return Form->ui.pageOptions->CBHardwareSound->isChecked(); +// return Form->ui.pageOptions->CBHardwareSound->isChecked(); return false; } #endif bool GameUIConfig::isMusicEnabled() { - return Form->ui.pageOptions->CBEnableMusic->isChecked(); + return Form->ui.pageOptions->CBEnableMusic->isChecked(); } bool GameUIConfig::isFrontendMusicEnabled() { - return Form->ui.pageOptions->CBEnableFrontendMusic->isChecked(); + return Form->ui.pageOptions->CBEnableFrontendMusic->isChecked(); } bool GameUIConfig::isShowFPSEnabled() { - return Form->ui.pageOptions->CBShowFPS->isChecked(); + return Form->ui.pageOptions->CBShowFPS->isChecked(); } bool GameUIConfig::isAltDamageEnabled() { - return Form->ui.pageOptions->CBAltDamage->isChecked(); + return Form->ui.pageOptions->CBAltDamage->isChecked(); } bool GameUIConfig::appendDateTimeToRecordName() { - return Form->ui.pageOptions->CBNameWithDate->isChecked(); + return Form->ui.pageOptions->CBNameWithDate->isChecked(); } #ifdef SPARKLE_ENABLED @@ -248,20 +248,20 @@ quint8 GameUIConfig::timerInterval() { - return 35 - Form->ui.pageOptions->fpsedit->value(); + return 35 - Form->ui.pageOptions->fpsedit->value(); } quint8 GameUIConfig::bitDepth() { - return depth; + return depth; } QString GameUIConfig::netNick() { - return Form->ui.pageOptions->editNetNick->text(); + return Form->ui.pageOptions->editNetNick->text(); } quint8 GameUIConfig::volume() { - return Form->ui.pageOptions->volumeBox->value() * 128 / 100; + return Form->ui.pageOptions->volumeBox->value() * 128 / 100; } diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/gameuiconfig.h --- a/QTfrontend/gameuiconfig.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/gameuiconfig.h Sat Mar 06 10:59:20 2010 +0000 @@ -28,49 +28,49 @@ class GameUIConfig : public QSettings { - Q_OBJECT + Q_OBJECT public: - GameUIConfig(HWForm * FormWidgets, const QString & fileName); - QStringList GetTeamsList(); - QRect vid_Resolution(); - bool vid_Fullscreen(); - bool isSoundEnabled(); - bool isFrontendSoundEnabled(); - QString language(); + GameUIConfig(HWForm * FormWidgets, const QString & fileName); + QStringList GetTeamsList(); + QRect vid_Resolution(); + bool vid_Fullscreen(); + bool isSoundEnabled(); + bool isFrontendSoundEnabled(); + QString language(); #ifdef _WIN32 - bool isSoundHardware(); + bool isSoundHardware(); #endif - bool isMusicEnabled(); - bool isFrontendMusicEnabled(); - bool isShowFPSEnabled(); - bool isAltDamageEnabled(); - bool appendDateTimeToRecordName(); - quint8 volume(); - quint8 timerInterval(); - quint8 bitDepth(); - QString netNick(); - bool isReducedQuality() const; - bool isFrontendEffects() const; - bool isFrontendFullscreen() const; - bool isWeaponTooltip() const; - void resizeToConfigValues(); + bool isMusicEnabled(); + bool isFrontendMusicEnabled(); + bool isShowFPSEnabled(); + bool isAltDamageEnabled(); + bool appendDateTimeToRecordName(); + quint8 volume(); + quint8 timerInterval(); + quint8 bitDepth(); + QString netNick(); + bool isReducedQuality() const; + bool isFrontendEffects() const; + bool isFrontendFullscreen() const; + bool isWeaponTooltip() const; + void resizeToConfigValues(); #ifdef __APPLE__ #ifdef SPARKLE_ENABLED - bool isAutoUpdateEnabled(); + bool isAutoUpdateEnabled(); #endif #endif signals: - void frontendFullscreen(bool value); + void frontendFullscreen(bool value); public slots: - void SaveOptions(); + void SaveOptions(); private: - HWForm * Form; - quint8 depth; + HWForm * Form; + quint8 depth; }; #endif diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/hats.cpp --- a/QTfrontend/hats.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/hats.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -26,84 +26,84 @@ HatsModel::HatsModel(QObject* parent) : QAbstractListModel(parent) { - QPixmap hhpix = QPixmap(datadir->absolutePath() + "/Graphics/Hedgehog/Idle.png").copy(0, 0, 32, 32); + QPixmap hhpix = QPixmap(datadir->absolutePath() + "/Graphics/Hedgehog/Idle.png").copy(0, 0, 32, 32); - QDir tmpdir; - tmpdir.cd(datadir->absolutePath()); - tmpdir.cd("Graphics"); - tmpdir.cd("Hats"); + QDir tmpdir; + tmpdir.cd(datadir->absolutePath()); + tmpdir.cd("Graphics"); + tmpdir.cd("Hats"); - tmpdir.setFilter(QDir::Files); + tmpdir.setFilter(QDir::Files); - QStringList hatsList = tmpdir.entryList(QStringList("*.png")); - for (QStringList::Iterator it = hatsList.begin(); it != hatsList.end(); ++it ) - { - QString str = (*it).replace(QRegExp("^(.*)\\.png"), "\\1"); - QPixmap pix(datadir->absolutePath() + "/Graphics/Hats/" + str + ".png"); + QStringList hatsList = tmpdir.entryList(QStringList("*.png")); + for (QStringList::Iterator it = hatsList.begin(); it != hatsList.end(); ++it ) + { + QString str = (*it).replace(QRegExp("^(.*)\\.png"), "\\1"); + QPixmap pix(datadir->absolutePath() + "/Graphics/Hats/" + str + ".png"); - QPixmap tmppix(32, 37); - tmppix.fill(QColor(Qt::transparent)); + QPixmap tmppix(32, 37); + tmppix.fill(QColor(Qt::transparent)); - QPainter painter(&tmppix); - painter.drawPixmap(QPoint(0, 5), hhpix); - painter.drawPixmap(QPoint(0, 0), pix.copy(0, 0, 32, 32)); - painter.end(); + QPainter painter(&tmppix); + painter.drawPixmap(QPoint(0, 5), hhpix); + painter.drawPixmap(QPoint(0, 0), pix.copy(0, 0, 32, 32)); + painter.end(); - hats.append(qMakePair(str, QIcon(tmppix))); - } + hats.append(qMakePair(str, QIcon(tmppix))); + } // Reserved hats tmpdir.cd("Reserved"); - hatsList = tmpdir.entryList(QStringList(playerHash+"*.png")); - for (QStringList::Iterator it = hatsList.begin(); it != hatsList.end(); ++it ) - { - QString str = (*it).replace(QRegExp("^(.*)\\.png"), "\\1"); - QPixmap pix(datadir->absolutePath() + "/Graphics/Hats/Reserved/" + str + ".png"); + hatsList = tmpdir.entryList(QStringList(playerHash+"*.png")); + for (QStringList::Iterator it = hatsList.begin(); it != hatsList.end(); ++it ) + { + QString str = (*it).replace(QRegExp("^(.*)\\.png"), "\\1"); + QPixmap pix(datadir->absolutePath() + "/Graphics/Hats/Reserved/" + str + ".png"); - QPixmap tmppix(32, 37); - tmppix.fill(QColor(Qt::transparent)); + QPixmap tmppix(32, 37); + tmppix.fill(QColor(Qt::transparent)); - QPainter painter(&tmppix); - painter.drawPixmap(QPoint(0, 5), hhpix); - painter.drawPixmap(QPoint(0, 0), pix.copy(0, 0, 32, 32)); - painter.end(); + QPainter painter(&tmppix); + painter.drawPixmap(QPoint(0, 5), hhpix); + painter.drawPixmap(QPoint(0, 0), pix.copy(0, 0, 32, 32)); + painter.end(); - hats.append(qMakePair("Reserved "+str.remove(0,32), QIcon(tmppix))); - } + hats.append(qMakePair("Reserved "+str.remove(0,32), QIcon(tmppix))); + } } QVariant HatsModel::headerData(int section, Qt::Orientation orientation, int role) const { - return QVariant(); + return QVariant(); } int HatsModel::rowCount(const QModelIndex &parent) const { - if (parent.isValid()) - return 0; - else - return hats.size(); + if (parent.isValid()) + return 0; + else + return hats.size(); } /*int HatsModel::columnCount(const QModelIndex & parent) const { - if (parent.isValid()) - return 0; - else - return 2; + if (parent.isValid()) + return 0; + else + return 2; } */ QVariant HatsModel::data(const QModelIndex &index, int role) const { - if (!index.isValid() || index.row() < 0 - || index.row() >= hats.size() - || (role != Qt::DisplayRole && role != Qt::DecorationRole)) - return QVariant(); + if (!index.isValid() || index.row() < 0 + || index.row() >= hats.size() + || (role != Qt::DisplayRole && role != Qt::DecorationRole)) + return QVariant(); - if (role == Qt::DisplayRole) - return hats.at(index.row()).first; - else // role == Qt::DecorationRole - return hats.at(index.row()).second; + if (role == Qt::DisplayRole) + return hats.at(index.row()).first; + else // role == Qt::DecorationRole + return hats.at(index.row()).second; } diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/hats.h --- a/QTfrontend/hats.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/hats.h Sat Mar 06 10:59:20 2010 +0000 @@ -27,18 +27,18 @@ class HatsModel : public QAbstractListModel { - Q_OBJECT + Q_OBJECT public: - HatsModel(QObject *parent = 0); + HatsModel(QObject *parent = 0); - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - int rowCount(const QModelIndex & parent) const; - //int columnCount(const QModelIndex & parent) const; + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + int rowCount(const QModelIndex & parent) const; + //int columnCount(const QModelIndex & parent) const; - QVariant data(const QModelIndex &index, int role) const; + QVariant data(const QModelIndex &index, int role) const; protected: - QVector > hats; + QVector > hats; }; #endif // _HATS_INCLUDED diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/hwform.cpp --- a/QTfrontend/hwform.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/hwform.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -75,21 +75,21 @@ : QMainWindow(parent), pnetserver(0), pRegisterServer(0), editedTeam(0), hwnet(0) { #ifdef USE_XFIRE - xfire_init(); + xfire_init(); #endif gameSettings = new QSettings(cfgdir->absolutePath() + "/hedgewars.ini", QSettings::IniFormat); frontendEffects = gameSettings->value("video/frontendeffects", true).toBool(); playerHash = QString(QCryptographicHash::hash(gameSettings->value("net/nick","").toString().toLatin1(), QCryptographicHash::Md5).toHex()); - ui.setupUi(this); + ui.setupUi(this); - CustomizePalettes(); - - ui.pageOptions->CBResolution->addItems(sdli.getResolutions()); + CustomizePalettes(); + + ui.pageOptions->CBResolution->addItems(sdli.getResolutions()); - config = new GameUIConfig(this, cfgdir->absolutePath() + "/hedgewars.ini"); + config = new GameUIConfig(this, cfgdir->absolutePath() + "/hedgewars.ini"); - namegen = new HWNamegen(); + namegen = new HWNamegen(); #ifdef __APPLE__ panel = new M3Panel; @@ -97,107 +97,107 @@ AutoUpdater* updater; CocoaInitializer initializer; updater = new SparkleAutoUpdater(SPARKLE_APPCAST_URL); - if(updater && config->isAutoUpdateEnabled()) + if(updater && config->isAutoUpdateEnabled()) updater->checkForUpdates(); #endif #endif - UpdateTeamsLists(); - UpdateWeapons(); + UpdateTeamsLists(); + UpdateWeapons(); - connect(config, SIGNAL(frontendFullscreen(bool)), this, SLOT(onFrontendFullscreen(bool))); - onFrontendFullscreen(config->isFrontendFullscreen()); + connect(config, SIGNAL(frontendFullscreen(bool)), this, SLOT(onFrontendFullscreen(bool))); + onFrontendFullscreen(config->isFrontendFullscreen()); - connect(ui.pageMain->BtnSinglePlayer, SIGNAL(clicked()), this, SLOT(GoToSinglePlayer())); - connect(ui.pageMain->BtnSetup, SIGNAL(clicked()), this, SLOT(GoToSetup())); - connect(ui.pageMain->BtnNet, SIGNAL(clicked()), this, SLOT(GoToNetType())); - connect(ui.pageMain->BtnInfo, SIGNAL(clicked()), this, SLOT(GoToInfo())); - connect(ui.pageMain->BtnExit, SIGNAL(pressed()), this, SLOT(btnExitPressed())); - connect(ui.pageMain->BtnExit, SIGNAL(clicked()), this, SLOT(btnExitClicked())); + connect(ui.pageMain->BtnSinglePlayer, SIGNAL(clicked()), this, SLOT(GoToSinglePlayer())); + connect(ui.pageMain->BtnSetup, SIGNAL(clicked()), this, SLOT(GoToSetup())); + connect(ui.pageMain->BtnNet, SIGNAL(clicked()), this, SLOT(GoToNetType())); + connect(ui.pageMain->BtnInfo, SIGNAL(clicked()), this, SLOT(GoToInfo())); + connect(ui.pageMain->BtnExit, SIGNAL(pressed()), this, SLOT(btnExitPressed())); + connect(ui.pageMain->BtnExit, SIGNAL(clicked()), this, SLOT(btnExitClicked())); - connect(ui.pageEditTeam->BtnTeamSave, SIGNAL(clicked()), this, SLOT(TeamSave())); - connect(ui.pageEditTeam->BtnTeamDiscard, SIGNAL(clicked()), this, SLOT(TeamDiscard())); + connect(ui.pageEditTeam->BtnTeamSave, SIGNAL(clicked()), this, SLOT(TeamSave())); + connect(ui.pageEditTeam->BtnTeamDiscard, SIGNAL(clicked()), this, SLOT(TeamDiscard())); - connect(ui.pageEditTeam->signalMapper, SIGNAL(mapped(const int &)), this, SLOT(RandomName(const int &))); - connect(ui.pageEditTeam->randTeamButton, SIGNAL(clicked()), this, SLOT(RandomNames())); + connect(ui.pageEditTeam->signalMapper, SIGNAL(mapped(const int &)), this, SLOT(RandomName(const int &))); + connect(ui.pageEditTeam->randTeamButton, SIGNAL(clicked()), this, SLOT(RandomNames())); - connect(ui.pageMultiplayer->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); - connect(ui.pageMultiplayer->BtnStartMPGame, SIGNAL(clicked()), this, SLOT(StartMPGame())); - connect(ui.pageMultiplayer->teamsSelect, SIGNAL(setEnabledGameStart(bool)), - ui.pageMultiplayer->BtnStartMPGame, SLOT(setEnabled(bool))); - connect(ui.pageMultiplayer->teamsSelect, SIGNAL(SetupClicked()), this, SLOT(IntermediateSetup())); - connect(ui.pageMultiplayer->gameCFG, SIGNAL(goToSchemes()), this, SLOT(GoToSchemes())); - connect(ui.pageMultiplayer->gameCFG, SIGNAL(goToWeapons(const QString &)), this, SLOT(GoToSelectWeaponSet(const QString &))); + connect(ui.pageMultiplayer->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); + connect(ui.pageMultiplayer->BtnStartMPGame, SIGNAL(clicked()), this, SLOT(StartMPGame())); + connect(ui.pageMultiplayer->teamsSelect, SIGNAL(setEnabledGameStart(bool)), + ui.pageMultiplayer->BtnStartMPGame, SLOT(setEnabled(bool))); + connect(ui.pageMultiplayer->teamsSelect, SIGNAL(SetupClicked()), this, SLOT(IntermediateSetup())); + connect(ui.pageMultiplayer->gameCFG, SIGNAL(goToSchemes()), this, SLOT(GoToSchemes())); + connect(ui.pageMultiplayer->gameCFG, SIGNAL(goToWeapons(const QString &)), this, SLOT(GoToSelectWeaponSet(const QString &))); - connect(ui.pagePlayDemo->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); - connect(ui.pagePlayDemo->BtnPlayDemo, SIGNAL(clicked()), this, SLOT(PlayDemo())); - connect(ui.pagePlayDemo->DemosList, SIGNAL(doubleClicked (const QModelIndex &)), this, SLOT(PlayDemo())); + connect(ui.pagePlayDemo->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); + connect(ui.pagePlayDemo->BtnPlayDemo, SIGNAL(clicked()), this, SLOT(PlayDemo())); + connect(ui.pagePlayDemo->DemosList, SIGNAL(doubleClicked (const QModelIndex &)), this, SLOT(PlayDemo())); - connect(ui.pageOptions->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); - connect(ui.pageOptions->BtnNewTeam, SIGNAL(clicked()), this, SLOT(NewTeam())); - connect(ui.pageOptions->BtnEditTeam, SIGNAL(clicked()), this, SLOT(EditTeam())); - connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), config, SLOT(SaveOptions())); - connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), this, SLOT(GoBack())); + connect(ui.pageOptions->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); + connect(ui.pageOptions->BtnNewTeam, SIGNAL(clicked()), this, SLOT(NewTeam())); + connect(ui.pageOptions->BtnEditTeam, SIGNAL(clicked()), this, SLOT(EditTeam())); + connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), config, SLOT(SaveOptions())); + connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), this, SLOT(GoBack())); - connect(ui.pageOptions->WeaponEdit, SIGNAL(clicked()), this, SLOT(GoToSelectWeapon())); - connect(ui.pageOptions->WeaponsButt, SIGNAL(clicked()), this, SLOT(GoToSelectNewWeapon())); - connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsChanged()), this, SLOT(UpdateWeapons())); + connect(ui.pageOptions->WeaponEdit, SIGNAL(clicked()), this, SLOT(GoToSelectWeapon())); + connect(ui.pageOptions->WeaponsButt, SIGNAL(clicked()), this, SLOT(GoToSelectNewWeapon())); + connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsChanged()), this, SLOT(UpdateWeapons())); - connect(ui.pageNet->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); - connect(ui.pageNet->BtnSpecifyServer, SIGNAL(clicked()), this, SLOT(NetConnect())); - connect(ui.pageNet->BtnNetSvrStart, SIGNAL(clicked()), this, SLOT(GoToNetServer())); - connect(ui.pageNet, SIGNAL(connectClicked(const QString &, quint16)), this, SLOT(NetConnectServer(const QString &, quint16))); + connect(ui.pageNet->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); + connect(ui.pageNet->BtnSpecifyServer, SIGNAL(clicked()), this, SLOT(NetConnect())); + connect(ui.pageNet->BtnNetSvrStart, SIGNAL(clicked()), this, SLOT(GoToNetServer())); + connect(ui.pageNet, SIGNAL(connectClicked(const QString &, quint16)), this, SLOT(NetConnectServer(const QString &, quint16))); - connect(ui.pageNetServer->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); - connect(ui.pageNetServer->BtnStart, SIGNAL(clicked()), this, SLOT(NetStartServer())); + connect(ui.pageNetServer->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); + connect(ui.pageNetServer->BtnStart, SIGNAL(clicked()), this, SLOT(NetStartServer())); - connect(ui.pageNetGame->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); - connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(setEnabledGameStart(bool)), - ui.pageNetGame->BtnGo, SLOT(setEnabled(bool))); - connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(setEnabledGameStart(bool)), - ui.pageNetGame->BtnStart, SLOT(setEnabled(bool))); - connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(SetupClicked()), this, SLOT(IntermediateSetup())); - connect(ui.pageNetGame->pGameCFG, SIGNAL(goToSchemes()), this, SLOT(GoToSchemes())); - connect(ui.pageNetGame->pGameCFG, SIGNAL(goToWeapons(const QString &)), this, SLOT(GoToSelectWeaponSet(const QString &))); + connect(ui.pageNetGame->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); + connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(setEnabledGameStart(bool)), + ui.pageNetGame->BtnGo, SLOT(setEnabled(bool))); + connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(setEnabledGameStart(bool)), + ui.pageNetGame->BtnStart, SLOT(setEnabled(bool))); + connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(SetupClicked()), this, SLOT(IntermediateSetup())); + connect(ui.pageNetGame->pGameCFG, SIGNAL(goToSchemes()), this, SLOT(GoToSchemes())); + connect(ui.pageNetGame->pGameCFG, SIGNAL(goToWeapons(const QString &)), this, SLOT(GoToSelectWeaponSet(const QString &))); - connect(ui.pageRoomsList->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); - connect(ui.pageRoomsList->BtnAdmin, SIGNAL(clicked()), this, SLOT(GoToAdmin())); + connect(ui.pageRoomsList->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); + connect(ui.pageRoomsList->BtnAdmin, SIGNAL(clicked()), this, SLOT(GoToAdmin())); - connect(ui.pageInfo->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); + connect(ui.pageInfo->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); - connect(ui.pageGameStats->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); + connect(ui.pageGameStats->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); - connect(ui.pageSinglePlayer->BtnSimpleGamePage, SIGNAL(clicked()), this, SLOT(SimpleGame())); - connect(ui.pageSinglePlayer->BtnTrainPage, SIGNAL(clicked()), this, SLOT(GoToTraining())); - connect(ui.pageSinglePlayer->BtnMultiplayer, SIGNAL(clicked()), this, SLOT(GoToMultiplayer())); - connect(ui.pageSinglePlayer->BtnLoad, SIGNAL(clicked()), this, SLOT(GoToSaves())); - connect(ui.pageSinglePlayer->BtnDemos, SIGNAL(clicked()), this, SLOT(GoToDemos())); - connect(ui.pageSinglePlayer->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); + connect(ui.pageSinglePlayer->BtnSimpleGamePage, SIGNAL(clicked()), this, SLOT(SimpleGame())); + connect(ui.pageSinglePlayer->BtnTrainPage, SIGNAL(clicked()), this, SLOT(GoToTraining())); + connect(ui.pageSinglePlayer->BtnMultiplayer, SIGNAL(clicked()), this, SLOT(GoToMultiplayer())); + connect(ui.pageSinglePlayer->BtnLoad, SIGNAL(clicked()), this, SLOT(GoToSaves())); + connect(ui.pageSinglePlayer->BtnDemos, SIGNAL(clicked()), this, SLOT(GoToDemos())); + connect(ui.pageSinglePlayer->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); - connect(ui.pageTraining->BtnStartTrain, SIGNAL(clicked()), this, SLOT(StartTraining())); - connect(ui.pageTraining->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); + connect(ui.pageTraining->BtnStartTrain, SIGNAL(clicked()), this, SLOT(StartTraining())); + connect(ui.pageTraining->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); - connect(ui.pageSelectWeapon->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); + connect(ui.pageSelectWeapon->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); - connect(ui.pageSelectWeapon->BtnDelete, SIGNAL(clicked()), - ui.pageSelectWeapon->pWeapons, SLOT(deleteWeaponsName())); // executed first - connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsDeleted()), - this, SLOT(UpdateWeapons())); // executed second - connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsDeleted()), - this, SLOT(GoBack())); // executed third + connect(ui.pageSelectWeapon->BtnDelete, SIGNAL(clicked()), + ui.pageSelectWeapon->pWeapons, SLOT(deleteWeaponsName())); // executed first + connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsDeleted()), + this, SLOT(UpdateWeapons())); // executed second + connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsDeleted()), + this, SLOT(GoBack())); // executed third - connect(ui.pageScheme->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); + connect(ui.pageScheme->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); - connect(ui.pageAdmin->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); + connect(ui.pageAdmin->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); - connect(ui.pageNetType->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); - connect(ui.pageNetType->BtnLAN, SIGNAL(clicked()), this, SLOT(GoToNet())); - connect(ui.pageNetType->BtnOfficialServer, SIGNAL(clicked()), this, SLOT(NetConnectOfficialServer())); + connect(ui.pageNetType->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); + connect(ui.pageNetType->BtnLAN, SIGNAL(clicked()), this, SLOT(GoToNet())); + connect(ui.pageNetType->BtnOfficialServer, SIGNAL(clicked()), this, SLOT(NetConnectOfficialServer())); - ammoSchemeModel = new AmmoSchemeModel(this, cfgdir->absolutePath() + "/schemes.ini"); - ui.pageScheme->setModel(ammoSchemeModel); - ui.pageMultiplayer->gameCFG->GameSchemes->setModel(ammoSchemeModel); + ammoSchemeModel = new AmmoSchemeModel(this, cfgdir->absolutePath() + "/schemes.ini"); + ui.pageScheme->setModel(ammoSchemeModel); + ui.pageMultiplayer->gameCFG->GameSchemes->setModel(ammoSchemeModel); wBackground = NULL; if (config->isFrontendEffects()) { @@ -208,49 +208,49 @@ wBackground->startAnimation(); } - PagesStack.push(ID_PAGE_MAIN); - GoBack(); + PagesStack.push(ID_PAGE_MAIN); + GoBack(); } #ifdef USE_XFIRE void HWForm::updateXfire(void) { - if(hwnet) - { - xfire_setvalue(XFIRE_SERVER, !hwnet->getHost().compare("netserver.hedgewars.org:46631") ? "Official server" : hwnet->getHost().toAscii()); - switch(hwnet->getClientState()) - { - case 1: // Connecting - xfire_setvalue(XFIRE_STATUS, "Connecting"); - xfire_setvalue(XFIRE_NICKNAME, "-"); - xfire_setvalue(XFIRE_ROOM, "-"); - case 2: // In lobby - xfire_setvalue(XFIRE_STATUS, "Online"); - xfire_setvalue(XFIRE_NICKNAME, hwnet->getNick().toAscii()); - xfire_setvalue(XFIRE_ROOM, "In game lobby"); - break; - case 3: // In room - xfire_setvalue(XFIRE_STATUS, "Online"); - xfire_setvalue(XFIRE_NICKNAME, hwnet->getNick().toAscii()); - xfire_setvalue(XFIRE_ROOM, (hwnet->getRoom() + " (waiting for players)").toAscii()); - break; - case 5: // In game - xfire_setvalue(XFIRE_STATUS, "Online"); - xfire_setvalue(XFIRE_NICKNAME, hwnet->getNick().toAscii()); - xfire_setvalue(XFIRE_ROOM, (hwnet->getRoom() + " (playing or spectating)").toAscii()); - break; - default: - break; - } - } - else - { - xfire_setvalue(XFIRE_STATUS, "Offline"); - xfire_setvalue(XFIRE_NICKNAME, "-"); - xfire_setvalue(XFIRE_ROOM, "-"); - xfire_setvalue(XFIRE_SERVER, "-"); - } - xfire_update(); + if(hwnet) + { + xfire_setvalue(XFIRE_SERVER, !hwnet->getHost().compare("netserver.hedgewars.org:46631") ? "Official server" : hwnet->getHost().toAscii()); + switch(hwnet->getClientState()) + { + case 1: // Connecting + xfire_setvalue(XFIRE_STATUS, "Connecting"); + xfire_setvalue(XFIRE_NICKNAME, "-"); + xfire_setvalue(XFIRE_ROOM, "-"); + case 2: // In lobby + xfire_setvalue(XFIRE_STATUS, "Online"); + xfire_setvalue(XFIRE_NICKNAME, hwnet->getNick().toAscii()); + xfire_setvalue(XFIRE_ROOM, "In game lobby"); + break; + case 3: // In room + xfire_setvalue(XFIRE_STATUS, "Online"); + xfire_setvalue(XFIRE_NICKNAME, hwnet->getNick().toAscii()); + xfire_setvalue(XFIRE_ROOM, (hwnet->getRoom() + " (waiting for players)").toAscii()); + break; + case 5: // In game + xfire_setvalue(XFIRE_STATUS, "Online"); + xfire_setvalue(XFIRE_NICKNAME, hwnet->getNick().toAscii()); + xfire_setvalue(XFIRE_ROOM, (hwnet->getRoom() + " (playing or spectating)").toAscii()); + break; + default: + break; + } + } + else + { + xfire_setvalue(XFIRE_STATUS, "Offline"); + xfire_setvalue(XFIRE_NICKNAME, "-"); + xfire_setvalue(XFIRE_ROOM, "-"); + xfire_setvalue(XFIRE_SERVER, "-"); + } + xfire_update(); } #endif @@ -265,779 +265,779 @@ void HWForm::CustomizePalettes() { - QList allSBars = findChildren(); - QPalette pal = palette(); - pal.setColor(QPalette::WindowText, QColor(0xff, 0xcc, 0x00)); - pal.setColor(QPalette::Button, QColor(0x00, 0x35, 0x1d)); - pal.setColor(QPalette::Base, QColor(0x00, 0x35, 0x1d)); - pal.setColor(QPalette::Window, QColor(0x00, 0x00, 0x00)); + QList allSBars = findChildren(); + QPalette pal = palette(); + pal.setColor(QPalette::WindowText, QColor(0xff, 0xcc, 0x00)); + pal.setColor(QPalette::Button, QColor(0x00, 0x35, 0x1d)); + pal.setColor(QPalette::Base, QColor(0x00, 0x35, 0x1d)); + pal.setColor(QPalette::Window, QColor(0x00, 0x00, 0x00)); - for (int i = 0; i < allSBars.size(); ++i) - allSBars.at(i)->setPalette(pal); + for (int i = 0; i < allSBars.size(); ++i) + allSBars.at(i)->setPalette(pal); } void HWForm::UpdateWeapons() { - QVector combos; - combos.push_back(ui.pageOptions->WeaponsName); - combos.push_back(ui.pageMultiplayer->gameCFG->WeaponsName); - combos.push_back(ui.pageNetGame->pGameCFG->WeaponsName); + QVector combos; + combos.push_back(ui.pageOptions->WeaponsName); + combos.push_back(ui.pageMultiplayer->gameCFG->WeaponsName); + combos.push_back(ui.pageNetGame->pGameCFG->WeaponsName); - QStringList names = ui.pageSelectWeapon->pWeapons->getWeaponNames(); + QStringList names = ui.pageSelectWeapon->pWeapons->getWeaponNames(); - for(QVector::iterator it = combos.begin(); it != combos.end(); ++it) { - (*it)->clear(); + for(QVector::iterator it = combos.begin(); it != combos.end(); ++it) { + (*it)->clear(); - for(int i = 0; i < names.size(); ++i) - (*it)->addItem(names[i], ui.pageSelectWeapon->pWeapons->getWeaponsString(names[i])); + for(int i = 0; i < names.size(); ++i) + (*it)->addItem(names[i], ui.pageSelectWeapon->pWeapons->getWeaponsString(names[i])); - int pos = (*it)->findText("Default"); - if (pos != -1) { - (*it)->setCurrentIndex(pos); - } - } + int pos = (*it)->findText("Default"); + if (pos != -1) { + (*it)->setCurrentIndex(pos); + } + } } void HWForm::UpdateTeamsLists(const QStringList* editable_teams) { - QStringList teamslist; - if(editable_teams) { - teamslist =* editable_teams; - } else { - teamslist = config->GetTeamsList(); - } + QStringList teamslist; + if(editable_teams) { + teamslist =* editable_teams; + } else { + teamslist = config->GetTeamsList(); + } - if(teamslist.empty()) { - HWTeam defaultTeam("DefaultTeam"); - defaultTeam.SaveToFile(); - teamslist.push_back("DefaultTeam"); - } + if(teamslist.empty()) { + HWTeam defaultTeam("DefaultTeam"); + defaultTeam.SaveToFile(); + teamslist.push_back("DefaultTeam"); + } - ui.pageOptions->CBTeamName->clear(); - ui.pageOptions->CBTeamName->addItems(teamslist); + ui.pageOptions->CBTeamName->clear(); + ui.pageOptions->CBTeamName->addItems(teamslist); } void HWForm::GoToMain() { - GoToPage(ID_PAGE_MAIN); + GoToPage(ID_PAGE_MAIN); } void HWForm::GoToSinglePlayer() { - GoToPage(ID_PAGE_SINGLEPLAYER); + GoToPage(ID_PAGE_SINGLEPLAYER); } void HWForm::GoToTraining() { - GoToPage(ID_PAGE_TRAINING); + GoToPage(ID_PAGE_TRAINING); } void HWForm::GoToSetup() { - GoToPage(ID_PAGE_SETUP); + GoToPage(ID_PAGE_SETUP); } void HWForm::GoToSelectNewWeapon() { - ui.pageSelectWeapon->pWeapons->setWeaponsName(tr("new")); - GoToPage(ID_PAGE_SELECTWEAPON); + ui.pageSelectWeapon->pWeapons->setWeaponsName(tr("new")); + GoToPage(ID_PAGE_SELECTWEAPON); } void HWForm::GoToSelectWeapon() { - ui.pageSelectWeapon->pWeapons->setWeaponsName(ui.pageOptions->WeaponsName->currentText()); - GoToPage(ID_PAGE_SELECTWEAPON); + ui.pageSelectWeapon->pWeapons->setWeaponsName(ui.pageOptions->WeaponsName->currentText()); + GoToPage(ID_PAGE_SELECTWEAPON); } void HWForm::GoToSelectWeaponSet(const QString & name) { - ui.pageSelectWeapon->pWeapons->setWeaponsName(name); - GoToPage(ID_PAGE_SELECTWEAPON); + ui.pageSelectWeapon->pWeapons->setWeaponsName(name); + GoToPage(ID_PAGE_SELECTWEAPON); } void HWForm::GoToInfo() { - GoToPage(ID_PAGE_INFO); + GoToPage(ID_PAGE_INFO); } void HWForm::GoToMultiplayer() { - GoToPage(ID_PAGE_MULTIPLAYER); + GoToPage(ID_PAGE_MULTIPLAYER); } void HWForm::GoToSaves() { - ui.pagePlayDemo->FillFromDir(PagePlayDemo::RT_Save); + ui.pagePlayDemo->FillFromDir(PagePlayDemo::RT_Save); - GoToPage(ID_PAGE_DEMOS); + GoToPage(ID_PAGE_DEMOS); } void HWForm::GoToDemos() { - ui.pagePlayDemo->FillFromDir(PagePlayDemo::RT_Demo); + ui.pagePlayDemo->FillFromDir(PagePlayDemo::RT_Demo); - GoToPage(ID_PAGE_DEMOS); + GoToPage(ID_PAGE_DEMOS); } void HWForm::GoToNet() { - ui.pageNet->updateServersList(); + ui.pageNet->updateServersList(); - GoToPage(ID_PAGE_NET); + GoToPage(ID_PAGE_NET); } void HWForm::GoToNetType() { - GoToPage(ID_PAGE_NETTYPE); + GoToPage(ID_PAGE_NETTYPE); } void HWForm::GoToNetServer() { - GoToPage(ID_PAGE_NETSERVER); + GoToPage(ID_PAGE_NETSERVER); } void HWForm::GoToSchemes() { - GoToPage(ID_PAGE_SCHEME); + GoToPage(ID_PAGE_SCHEME); } void HWForm::GoToAdmin() { - GoToPage(ID_PAGE_ADMIN); + GoToPage(ID_PAGE_ADMIN); } void HWForm::OnPageShown(quint8 id, quint8 lastid) { #ifdef USE_XFIRE - updateXfire(); + updateXfire(); #endif - if (id == ID_PAGE_MULTIPLAYER || id == ID_PAGE_NETGAME) { - QStringList tmNames = config->GetTeamsList(); - TeamSelWidget* curTeamSelWidget; + if (id == ID_PAGE_MULTIPLAYER || id == ID_PAGE_NETGAME) { + QStringList tmNames = config->GetTeamsList(); + TeamSelWidget* curTeamSelWidget; - if(id == ID_PAGE_MULTIPLAYER) { - curTeamSelWidget = ui.pageMultiplayer->teamsSelect; - } else { - curTeamSelWidget = ui.pageNetGame->pNetTeamsWidget; - } + if(id == ID_PAGE_MULTIPLAYER) { + curTeamSelWidget = ui.pageMultiplayer->teamsSelect; + } else { + curTeamSelWidget = ui.pageNetGame->pNetTeamsWidget; + } - QList teamsList; - for(QStringList::iterator it = tmNames.begin(); it != tmNames.end(); it++) { - HWTeam team(*it); - team.LoadFromFile(); - teamsList.push_back(team); - } + QList teamsList; + for(QStringList::iterator it = tmNames.begin(); it != tmNames.end(); it++) { + HWTeam team(*it); + team.LoadFromFile(); + teamsList.push_back(team); + } - if(lastid == ID_PAGE_SETUP) { // _TEAM - if (editedTeam) { - curTeamSelWidget->addTeam(*editedTeam); - } - } else if(lastid != ID_PAGE_GAMESTATS - && lastid != ID_PAGE_INGAME - && lastid != ID_PAGE_SCHEME - && lastid != ID_PAGE_SELECTWEAPON) { - curTeamSelWidget->resetPlayingTeams(teamsList); - } - } else - if (id == ID_PAGE_GAMESTATS) - { - ui.pageGameStats->renderStats(); - } + if(lastid == ID_PAGE_SETUP) { // _TEAM + if (editedTeam) { + curTeamSelWidget->addTeam(*editedTeam); + } + } else if(lastid != ID_PAGE_GAMESTATS + && lastid != ID_PAGE_INGAME + && lastid != ID_PAGE_SCHEME + && lastid != ID_PAGE_SELECTWEAPON) { + curTeamSelWidget->resetPlayingTeams(teamsList); + } + } else + if (id == ID_PAGE_GAMESTATS) + { + ui.pageGameStats->renderStats(); + } - // load and save ignore/friends lists - if(lastid == ID_PAGE_MULTIPLAYER || lastid == ID_PAGE_NETGAME) // leaving a room - ui.pageNetGame->pChatWidget->saveLists(ui.pageOptions->editNetNick->text()); - else if(lastid == ID_PAGE_ROOMSLIST) // leaving the lobby - ui.pageRoomsList->chatWidget->saveLists(ui.pageOptions->editNetNick->text()); - if(id == ID_PAGE_MULTIPLAYER || id == ID_PAGE_NETGAME) // joining a room - ui.pageNetGame->pChatWidget->loadLists(ui.pageOptions->editNetNick->text()); - else if(id == ID_PAGE_ROOMSLIST) // joining the lobby - ui.pageRoomsList->chatWidget->loadLists(ui.pageOptions->editNetNick->text()); + // load and save ignore/friends lists + if(lastid == ID_PAGE_MULTIPLAYER || lastid == ID_PAGE_NETGAME) // leaving a room + ui.pageNetGame->pChatWidget->saveLists(ui.pageOptions->editNetNick->text()); + else if(lastid == ID_PAGE_ROOMSLIST) // leaving the lobby + ui.pageRoomsList->chatWidget->saveLists(ui.pageOptions->editNetNick->text()); + if(id == ID_PAGE_MULTIPLAYER || id == ID_PAGE_NETGAME) // joining a room + ui.pageNetGame->pChatWidget->loadLists(ui.pageOptions->editNetNick->text()); + else if(id == ID_PAGE_ROOMSLIST) // joining the lobby + ui.pageRoomsList->chatWidget->loadLists(ui.pageOptions->editNetNick->text()); } void HWForm::GoToPage(quint8 id) { - quint8 lastid = ui.Pages->currentIndex(); - PagesStack.push(ui.Pages->currentIndex()); - OnPageShown(id, lastid); - ui.Pages->setCurrentIndex(id); + quint8 lastid = ui.Pages->currentIndex(); + PagesStack.push(ui.Pages->currentIndex()); + OnPageShown(id, lastid); + ui.Pages->setCurrentIndex(id); } void HWForm::GoBack() { - quint8 id = PagesStack.isEmpty() ? ID_PAGE_MAIN : PagesStack.pop(); - quint8 curid = ui.Pages->currentIndex(); - ui.Pages->setCurrentIndex(id); - OnPageShown(id, curid); + quint8 id = PagesStack.isEmpty() ? ID_PAGE_MAIN : PagesStack.pop(); + quint8 curid = ui.Pages->currentIndex(); + ui.Pages->setCurrentIndex(id); + OnPageShown(id, curid); - if (id == ID_PAGE_CONNECTING) - GoBack(); - if (id == ID_PAGE_NETSERVER) - GoBack(); - if ((!hwnet) && (id == ID_PAGE_ROOMSLIST)) - GoBack(); + if (id == ID_PAGE_CONNECTING) + GoBack(); + if (id == ID_PAGE_NETSERVER) + GoBack(); + if ((!hwnet) && (id == ID_PAGE_ROOMSLIST)) + GoBack(); - if ((!hwnet) || (!hwnet->isInRoom())) - if (id == ID_PAGE_NETGAME || id == ID_PAGE_NETGAME) - GoBack(); + if ((!hwnet) || (!hwnet->isInRoom())) + if (id == ID_PAGE_NETGAME || id == ID_PAGE_NETGAME) + GoBack(); - if (curid == ID_PAGE_ROOMSLIST) NetDisconnect(); + if (curid == ID_PAGE_ROOMSLIST) NetDisconnect(); - if (curid == ID_PAGE_SCHEME) - ammoSchemeModel->Save(); + if (curid == ID_PAGE_SCHEME) + ammoSchemeModel->Save(); } void HWForm::btnExitPressed() { - eggTimer.start(); + eggTimer.start(); } void HWForm::btnExitClicked() { - if (eggTimer.elapsed() < 3000){ + if (eggTimer.elapsed() < 3000){ #ifdef __APPLE__ panel->showInstallController(); #endif - close(); - } + close(); + } else - { - QPushButton * btn = findChild("imageButt"); - if (btn) - { - btn->setIcon(QIcon(":/res/bonus.png")); - } - } + { + QPushButton * btn = findChild("imageButt"); + if (btn) + { + btn->setIcon(QIcon(":/res/bonus.png")); + } + } } void HWForm::IntermediateSetup() { - quint8 id=ui.Pages->currentIndex(); - TeamSelWidget* curTeamSelWidget; + quint8 id=ui.Pages->currentIndex(); + TeamSelWidget* curTeamSelWidget; - if(id == ID_PAGE_MULTIPLAYER) { - curTeamSelWidget = ui.pageMultiplayer->teamsSelect; - } else { - curTeamSelWidget = ui.pageNetGame->pNetTeamsWidget; - } + if(id == ID_PAGE_MULTIPLAYER) { + curTeamSelWidget = ui.pageMultiplayer->teamsSelect; + } else { + curTeamSelWidget = ui.pageNetGame->pNetTeamsWidget; + } - QList teams = curTeamSelWidget->getDontPlayingTeams(); - QStringList tmnames; - for(QList::iterator it = teams.begin(); it != teams.end(); ++it) { - tmnames += it->TeamName; - } - UpdateTeamsLists(&tmnames); // FIXME: still need more work if teamname is updated while configuring + QList teams = curTeamSelWidget->getDontPlayingTeams(); + QStringList tmnames; + for(QList::iterator it = teams.begin(); it != teams.end(); ++it) { + tmnames += it->TeamName; + } + UpdateTeamsLists(&tmnames); // FIXME: still need more work if teamname is updated while configuring - GoToPage(ID_PAGE_SETUP); + GoToPage(ID_PAGE_SETUP); } void HWForm::NewTeam() { - editedTeam = new HWTeam("unnamed"); - editedTeam->SetToPage(this); - GoToPage(ID_PAGE_SETUP_TEAM); + editedTeam = new HWTeam("unnamed"); + editedTeam->SetToPage(this); + GoToPage(ID_PAGE_SETUP_TEAM); } void HWForm::EditTeam() { - editedTeam = new HWTeam(ui.pageOptions->CBTeamName->currentText()); - editedTeam->LoadFromFile(); - editedTeam->SetToPage(this); - GoToPage(ID_PAGE_SETUP_TEAM); + editedTeam = new HWTeam(ui.pageOptions->CBTeamName->currentText()); + editedTeam->LoadFromFile(); + editedTeam->SetToPage(this); + GoToPage(ID_PAGE_SETUP_TEAM); } void HWForm::RandomNames() { - editedTeam->GetFromPage(this); - namegen->TeamRandomNames(editedTeam,FALSE); - editedTeam->SetToPage(this); + editedTeam->GetFromPage(this); + namegen->TeamRandomNames(editedTeam,FALSE); + editedTeam->SetToPage(this); } void HWForm::RandomName(const int &i) { - editedTeam->GetFromPage(this); - namegen->TeamRandomName(editedTeam,i); - editedTeam->SetToPage(this); + editedTeam->GetFromPage(this); + namegen->TeamRandomName(editedTeam,i); + editedTeam->SetToPage(this); } void HWForm::TeamSave() { - editedTeam->GetFromPage(this); - editedTeam->SaveToFile(); - delete editedTeam; - editedTeam=0; - UpdateTeamsLists(); - GoBack(); + editedTeam->GetFromPage(this); + editedTeam->SaveToFile(); + delete editedTeam; + editedTeam=0; + UpdateTeamsLists(); + GoBack(); } void HWForm::TeamDiscard() { - delete editedTeam; - editedTeam=0; - GoBack(); + delete editedTeam; + editedTeam=0; + GoBack(); } void HWForm::SimpleGame() { - CreateGame(0, 0, *cDefaultAmmoStore); - game->StartQuick(); + CreateGame(0, 0, *cDefaultAmmoStore); + game->StartQuick(); } void HWForm::PlayDemo() { - QListWidgetItem * curritem = ui.pagePlayDemo->DemosList->currentItem(); - if (!curritem) - { - QMessageBox::critical(this, - tr("Error"), - tr("Please select record from the list above"), - tr("OK")); - return ; - } - CreateGame(0, 0, 0); - game->PlayDemo(curritem->data(Qt::UserRole).toString()); + QListWidgetItem * curritem = ui.pagePlayDemo->DemosList->currentItem(); + if (!curritem) + { + QMessageBox::critical(this, + tr("Error"), + tr("Please select record from the list above"), + tr("OK")); + return ; + } + CreateGame(0, 0, 0); + game->PlayDemo(curritem->data(Qt::UserRole).toString()); } void HWForm::NetConnectServer(const QString & host, quint16 port) { - _NetConnect(host, port, ui.pageOptions->editNetNick->text()); + _NetConnect(host, port, ui.pageOptions->editNetNick->text()); } void HWForm::NetConnectOfficialServer() { - NetConnectServer("netserver.hedgewars.org", 46631); + NetConnectServer("netserver.hedgewars.org", 46631); } void HWForm::_NetConnect(const QString & hostName, quint16 port, const QString & nick) { - if(hwnet) { - hwnet->Disconnect(); - delete hwnet; - hwnet=0; - } + if(hwnet) { + hwnet->Disconnect(); + delete hwnet; + hwnet=0; + } - ui.pageRoomsList->chatWidget->clear(); + ui.pageRoomsList->chatWidget->clear(); - hwnet = new HWNewNet(config, ui.pageNetGame->pGameCFG, ui.pageNetGame->pNetTeamsWidget); + hwnet = new HWNewNet(config, ui.pageNetGame->pGameCFG, ui.pageNetGame->pNetTeamsWidget); - GoToPage(ID_PAGE_CONNECTING); + GoToPage(ID_PAGE_CONNECTING); - connect(hwnet, SIGNAL(showMessage(const QString &)), this, SLOT(ShowErrorMessage(const QString &)), Qt::QueuedConnection); + connect(hwnet, SIGNAL(showMessage(const QString &)), this, SLOT(ShowErrorMessage(const QString &)), Qt::QueuedConnection); - connect(hwnet, SIGNAL(AskForRunGame()), this, SLOT(CreateNetGame())); - connect(hwnet, SIGNAL(Connected()), this, SLOT(NetConnected())); - connect(hwnet, SIGNAL(EnteredGame()), this, SLOT(NetGameEnter())); - connect(hwnet, SIGNAL(LeftRoom()), this, SLOT(NetLeftRoom())); - connect(hwnet, SIGNAL(AddNetTeam(const HWTeam&)), this, SLOT(AddNetTeam(const HWTeam&))); - connect(ui.pageNetGame->BtnBack, SIGNAL(clicked()), hwnet, SLOT(partRoom())); + connect(hwnet, SIGNAL(AskForRunGame()), this, SLOT(CreateNetGame())); + connect(hwnet, SIGNAL(Connected()), this, SLOT(NetConnected())); + connect(hwnet, SIGNAL(EnteredGame()), this, SLOT(NetGameEnter())); + connect(hwnet, SIGNAL(LeftRoom()), this, SLOT(NetLeftRoom())); + connect(hwnet, SIGNAL(AddNetTeam(const HWTeam&)), this, SLOT(AddNetTeam(const HWTeam&))); + connect(ui.pageNetGame->BtnBack, SIGNAL(clicked()), hwnet, SLOT(partRoom())); // rooms list page stuff - connect(hwnet, SIGNAL(roomsList(const QStringList&)), - ui.pageRoomsList, SLOT(setRoomsList(const QStringList&))); - connect(hwnet, SIGNAL(adminAccess(bool)), - ui.pageRoomsList, SLOT(setAdmin(bool))); - connect(hwnet, SIGNAL(adminAccess(bool)), - ui.pageRoomsList->chatWidget, SLOT(adminAccess(bool))); + connect(hwnet, SIGNAL(roomsList(const QStringList&)), + ui.pageRoomsList, SLOT(setRoomsList(const QStringList&))); + connect(hwnet, SIGNAL(adminAccess(bool)), + ui.pageRoomsList, SLOT(setAdmin(bool))); + connect(hwnet, SIGNAL(adminAccess(bool)), + ui.pageRoomsList->chatWidget, SLOT(adminAccess(bool))); - connect(hwnet, SIGNAL(serverMessage(const QString&)), - ui.pageRoomsList->chatWidget, SLOT(onServerMessage(const QString&))); + connect(hwnet, SIGNAL(serverMessage(const QString&)), + ui.pageRoomsList->chatWidget, SLOT(onServerMessage(const QString&))); - connect(ui.pageRoomsList, SIGNAL(askForCreateRoom(const QString &)), - hwnet, SLOT(CreateRoom(const QString&))); - connect(ui.pageRoomsList, SIGNAL(askForJoinRoom(const QString &)), - hwnet, SLOT(JoinRoom(const QString&))); -// connect(ui.pageRoomsList, SIGNAL(askForCreateRoom(const QString &)), -// this, SLOT(NetGameMaster())); -// connect(ui.pageRoomsList, SIGNAL(askForJoinRoom(const QString &)), -// this, SLOT(NetGameSlave())); - connect(ui.pageRoomsList, SIGNAL(askForRoomList()), - hwnet, SLOT(askRoomsList())); + connect(ui.pageRoomsList, SIGNAL(askForCreateRoom(const QString &)), + hwnet, SLOT(CreateRoom(const QString&))); + connect(ui.pageRoomsList, SIGNAL(askForJoinRoom(const QString &)), + hwnet, SLOT(JoinRoom(const QString&))); +// connect(ui.pageRoomsList, SIGNAL(askForCreateRoom(const QString &)), +// this, SLOT(NetGameMaster())); +// connect(ui.pageRoomsList, SIGNAL(askForJoinRoom(const QString &)), +// this, SLOT(NetGameSlave())); + connect(ui.pageRoomsList, SIGNAL(askForRoomList()), + hwnet, SLOT(askRoomsList())); // room status stuff - connect(hwnet, SIGNAL(roomMaster(bool)), - this, SLOT(NetGameChangeStatus(bool))); + connect(hwnet, SIGNAL(roomMaster(bool)), + this, SLOT(NetGameChangeStatus(bool))); // net page stuff - connect(hwnet, SIGNAL(chatStringFromNet(const QString&)), - ui.pageNetGame->pChatWidget, SLOT(onChatString(const QString&))); - connect(hwnet, SIGNAL(setReadyStatus(const QString &, bool)), - ui.pageNetGame->pChatWidget, SLOT(setReadyStatus(const QString &, bool))); - connect(hwnet, SIGNAL(chatStringFromMe(const QString&)), - ui.pageNetGame->pChatWidget, SLOT(onChatString(const QString&))); - connect(hwnet, SIGNAL(roomMaster(bool)), - ui.pageNetGame->pChatWidget, SLOT(adminAccess(bool))); - connect(ui.pageNetGame->pChatWidget, SIGNAL(chatLine(const QString&)), - hwnet, SLOT(chatLineToNet(const QString&))); - connect(ui.pageNetGame->BtnGo, SIGNAL(clicked()), hwnet, SLOT(ToggleReady())); - connect(hwnet, SIGNAL(setMyReadyStatus(bool)), - ui.pageNetGame, SLOT(setReadyStatus(bool))); + connect(hwnet, SIGNAL(chatStringFromNet(const QString&)), + ui.pageNetGame->pChatWidget, SLOT(onChatString(const QString&))); + connect(hwnet, SIGNAL(setReadyStatus(const QString &, bool)), + ui.pageNetGame->pChatWidget, SLOT(setReadyStatus(const QString &, bool))); + connect(hwnet, SIGNAL(chatStringFromMe(const QString&)), + ui.pageNetGame->pChatWidget, SLOT(onChatString(const QString&))); + connect(hwnet, SIGNAL(roomMaster(bool)), + ui.pageNetGame->pChatWidget, SLOT(adminAccess(bool))); + connect(ui.pageNetGame->pChatWidget, SIGNAL(chatLine(const QString&)), + hwnet, SLOT(chatLineToNet(const QString&))); + connect(ui.pageNetGame->BtnGo, SIGNAL(clicked()), hwnet, SLOT(ToggleReady())); + connect(hwnet, SIGNAL(setMyReadyStatus(bool)), + ui.pageNetGame, SLOT(setReadyStatus(bool))); // chat widget actions - connect(ui.pageNetGame->pChatWidget, SIGNAL(kick(const QString&)), - hwnet, SLOT(kickPlayer(const QString&))); - connect(ui.pageNetGame->pChatWidget, SIGNAL(ban(const QString&)), - hwnet, SLOT(banPlayer(const QString&))); - connect(ui.pageNetGame->pChatWidget, SIGNAL(info(const QString&)), - hwnet, SLOT(infoPlayer(const QString&))); - connect(ui.pageNetGame->pChatWidget, SIGNAL(follow(const QString&)), - hwnet, SLOT(followPlayer(const QString&))); - connect(ui.pageRoomsList->chatWidget, SIGNAL(kick(const QString&)), - hwnet, SLOT(kickPlayer(const QString&))); - connect(ui.pageRoomsList->chatWidget, SIGNAL(ban(const QString&)), - hwnet, SLOT(banPlayer(const QString&))); - connect(ui.pageRoomsList->chatWidget, SIGNAL(info(const QString&)), - hwnet, SLOT(infoPlayer(const QString&))); - connect(ui.pageRoomsList->chatWidget, SIGNAL(follow(const QString&)), - hwnet, SLOT(followPlayer(const QString&))); + connect(ui.pageNetGame->pChatWidget, SIGNAL(kick(const QString&)), + hwnet, SLOT(kickPlayer(const QString&))); + connect(ui.pageNetGame->pChatWidget, SIGNAL(ban(const QString&)), + hwnet, SLOT(banPlayer(const QString&))); + connect(ui.pageNetGame->pChatWidget, SIGNAL(info(const QString&)), + hwnet, SLOT(infoPlayer(const QString&))); + connect(ui.pageNetGame->pChatWidget, SIGNAL(follow(const QString&)), + hwnet, SLOT(followPlayer(const QString&))); + connect(ui.pageRoomsList->chatWidget, SIGNAL(kick(const QString&)), + hwnet, SLOT(kickPlayer(const QString&))); + connect(ui.pageRoomsList->chatWidget, SIGNAL(ban(const QString&)), + hwnet, SLOT(banPlayer(const QString&))); + connect(ui.pageRoomsList->chatWidget, SIGNAL(info(const QString&)), + hwnet, SLOT(infoPlayer(const QString&))); + connect(ui.pageRoomsList->chatWidget, SIGNAL(follow(const QString&)), + hwnet, SLOT(followPlayer(const QString&))); // chatting - connect(ui.pageRoomsList->chatWidget, SIGNAL(chatLine(const QString&)), - hwnet, SLOT(chatLineToLobby(const QString&))); - connect(hwnet, SIGNAL(chatStringLobby(const QString&)), - ui.pageRoomsList->chatWidget, SLOT(onChatString(const QString&))); - connect(hwnet, SIGNAL(chatStringFromMeLobby(const QString&)), - ui.pageRoomsList->chatWidget, SLOT(onChatString(const QString&))); + connect(ui.pageRoomsList->chatWidget, SIGNAL(chatLine(const QString&)), + hwnet, SLOT(chatLineToLobby(const QString&))); + connect(hwnet, SIGNAL(chatStringLobby(const QString&)), + ui.pageRoomsList->chatWidget, SLOT(onChatString(const QString&))); + connect(hwnet, SIGNAL(chatStringFromMeLobby(const QString&)), + ui.pageRoomsList->chatWidget, SLOT(onChatString(const QString&))); // nick list stuff - connect(hwnet, SIGNAL(nickAdded(const QString&, bool)), - ui.pageNetGame->pChatWidget, SLOT(nickAdded(const QString&, bool))); - connect(hwnet, SIGNAL(nickRemoved(const QString&)), - ui.pageNetGame->pChatWidget, SLOT(nickRemoved(const QString&))); - connect(hwnet, SIGNAL(nickAddedLobby(const QString&, bool)), - ui.pageRoomsList->chatWidget, SLOT(nickAdded(const QString&, bool))); - connect(hwnet, SIGNAL(nickRemovedLobby(const QString&)), - ui.pageRoomsList->chatWidget, SLOT(nickRemoved(const QString&))); + connect(hwnet, SIGNAL(nickAdded(const QString&, bool)), + ui.pageNetGame->pChatWidget, SLOT(nickAdded(const QString&, bool))); + connect(hwnet, SIGNAL(nickRemoved(const QString&)), + ui.pageNetGame->pChatWidget, SLOT(nickRemoved(const QString&))); + connect(hwnet, SIGNAL(nickAddedLobby(const QString&, bool)), + ui.pageRoomsList->chatWidget, SLOT(nickAdded(const QString&, bool))); + connect(hwnet, SIGNAL(nickRemovedLobby(const QString&)), + ui.pageRoomsList->chatWidget, SLOT(nickRemoved(const QString&))); // teams selecting stuff - connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(hhogsNumChanged(const HWTeam&)), - hwnet, SLOT(onHedgehogsNumChanged(const HWTeam&))); - connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamColorChanged(const HWTeam&)), - hwnet, SLOT(onTeamColorChanged(const HWTeam&))); - connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamWillPlay(HWTeam)), hwnet, SLOT(AddTeam(HWTeam))); - connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(acceptRequested(HWTeam)), hwnet, SLOT(AddTeam(HWTeam))); - connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamNotPlaying(const HWTeam&)), hwnet, SLOT(RemoveTeam(const HWTeam&))); - connect(hwnet, SIGNAL(hhnumChanged(const HWTeam&)), - ui.pageNetGame->pNetTeamsWidget, SLOT(changeHHNum(const HWTeam&))); - connect(hwnet, SIGNAL(teamColorChanged(const HWTeam&)), - ui.pageNetGame->pNetTeamsWidget, SLOT(changeTeamColor(const HWTeam&))); + connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(hhogsNumChanged(const HWTeam&)), + hwnet, SLOT(onHedgehogsNumChanged(const HWTeam&))); + connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamColorChanged(const HWTeam&)), + hwnet, SLOT(onTeamColorChanged(const HWTeam&))); + connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamWillPlay(HWTeam)), hwnet, SLOT(AddTeam(HWTeam))); + connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(acceptRequested(HWTeam)), hwnet, SLOT(AddTeam(HWTeam))); + connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamNotPlaying(const HWTeam&)), hwnet, SLOT(RemoveTeam(const HWTeam&))); + connect(hwnet, SIGNAL(hhnumChanged(const HWTeam&)), + ui.pageNetGame->pNetTeamsWidget, SLOT(changeHHNum(const HWTeam&))); + connect(hwnet, SIGNAL(teamColorChanged(const HWTeam&)), + ui.pageNetGame->pNetTeamsWidget, SLOT(changeTeamColor(const HWTeam&))); // admin stuff - connect(hwnet, SIGNAL(serverMessage(const QString&)), ui.pageAdmin, SLOT(serverMessage(const QString &))); - connect(ui.pageAdmin, SIGNAL(setServerMessage(const QString&)), hwnet, SLOT(newServerMessage(const QString &))); - connect(ui.pageAdmin->pbClearAccountsCache, SIGNAL(clicked()), hwnet, SLOT(clearAccountsCache())); + connect(hwnet, SIGNAL(serverMessage(const QString&)), ui.pageAdmin, SLOT(serverMessage(const QString &))); + connect(ui.pageAdmin, SIGNAL(setServerMessage(const QString&)), hwnet, SLOT(newServerMessage(const QString &))); + connect(ui.pageAdmin->pbClearAccountsCache, SIGNAL(clicked()), hwnet, SLOT(clearAccountsCache())); // disconnect - connect(hwnet, SIGNAL(Disconnected()), this, SLOT(ForcedDisconnect()), Qt::QueuedConnection); + connect(hwnet, SIGNAL(Disconnected()), this, SLOT(ForcedDisconnect()), Qt::QueuedConnection); - hwnet->Connect(hostName, port, nick); + hwnet->Connect(hostName, port, nick); } void HWForm::NetConnect() { - HWHostPortDialog * hpd = new HWHostPortDialog(this); - hpd->leHost->setText(*netHost); - hpd->sbPort->setValue(netPort); + HWHostPortDialog * hpd = new HWHostPortDialog(this); + hpd->leHost->setText(*netHost); + hpd->sbPort->setValue(netPort); - if (hpd->exec() == QDialog::Accepted) - { - config->SaveOptions(); - delete netHost; - netHost = new QString(hpd->leHost->text()); - netPort = hpd->sbPort->value(); - NetConnectServer(*netHost, netPort); - } + if (hpd->exec() == QDialog::Accepted) + { + config->SaveOptions(); + delete netHost; + netHost = new QString(hpd->leHost->text()); + netPort = hpd->sbPort->value(); + NetConnectServer(*netHost, netPort); + } } void HWForm::NetStartServer() { - config->SaveOptions(); + config->SaveOptions(); - pnetserver = new HWNetServer; - if(!pnetserver->StartServer(ui.pageNetServer->sbPort->value())) - { - QMessageBox::critical(0, tr("Error"), - tr("Unable to start the server")); - delete pnetserver; - pnetserver = 0; - return; - } + pnetserver = new HWNetServer; + if(!pnetserver->StartServer(ui.pageNetServer->sbPort->value())) + { + QMessageBox::critical(0, tr("Error"), + tr("Unable to start the server")); + delete pnetserver; + pnetserver = 0; + return; + } - QTimer::singleShot(250, this, SLOT(AsyncNetServerStart())); + QTimer::singleShot(250, this, SLOT(AsyncNetServerStart())); - pRegisterServer = new HWNetUdpServer(0, - ui.pageNetServer->leServerDescr->text(), - ui.pageNetServer->sbPort->value()); + pRegisterServer = new HWNetUdpServer(0, + ui.pageNetServer->leServerDescr->text(), + ui.pageNetServer->sbPort->value()); } void HWForm::AsyncNetServerStart() { - NetConnectServer("localhost", pnetserver->getRunningPort()); + NetConnectServer("localhost", pnetserver->getRunningPort()); } void HWForm::NetDisconnect() { - //qDebug("NetDisconnect"); - if(hwnet) { - hwnet->Disconnect(); - delete hwnet; - hwnet = 0; - } - if(pnetserver) { - if (pRegisterServer) - { - pRegisterServer->unregister(); - pRegisterServer = 0; - } + //qDebug("NetDisconnect"); + if(hwnet) { + hwnet->Disconnect(); + delete hwnet; + hwnet = 0; + } + if(pnetserver) { + if (pRegisterServer) + { + pRegisterServer->unregister(); + pRegisterServer = 0; + } - pnetserver->StopServer(); - delete pnetserver; - pnetserver = 0; - } + pnetserver->StopServer(); + delete pnetserver; + pnetserver = 0; + } } void HWForm::ForcedDisconnect() { - if(pnetserver) return; // we have server - let it care of all things - if (hwnet) { - hwnet->deleteLater(); - hwnet = 0; - QMessageBox::warning(this, QMessageBox::tr("Network"), - QMessageBox::tr("Connection to server is lost")); + if(pnetserver) return; // we have server - let it care of all things + if (hwnet) { + hwnet->deleteLater(); + hwnet = 0; + QMessageBox::warning(this, QMessageBox::tr("Network"), + QMessageBox::tr("Connection to server is lost")); - } - if (ui.Pages->currentIndex() != ID_PAGE_NET) GoBack(); + } + if (ui.Pages->currentIndex() != ID_PAGE_NET) GoBack(); } void HWForm::NetConnected() { - GoToPage(ID_PAGE_ROOMSLIST); + GoToPage(ID_PAGE_ROOMSLIST); } void HWForm::NetGameEnter() { - ui.pageNetGame->pChatWidget->clear(); - GoToPage(ID_PAGE_NETGAME); + ui.pageNetGame->pChatWidget->clear(); + GoToPage(ID_PAGE_NETGAME); } void HWForm::AddNetTeam(const HWTeam& team) { - ui.pageNetGame->pNetTeamsWidget->addTeam(team); + ui.pageNetGame->pNetTeamsWidget->addTeam(team); } void HWForm::StartMPGame() { - QString ammo; - ammo = ui.pageMultiplayer->gameCFG->WeaponsName->itemData( - ui.pageMultiplayer->gameCFG->WeaponsName->currentIndex() - ).toString(); + QString ammo; + ammo = ui.pageMultiplayer->gameCFG->WeaponsName->itemData( + ui.pageMultiplayer->gameCFG->WeaponsName->currentIndex() + ).toString(); - CreateGame(ui.pageMultiplayer->gameCFG, ui.pageMultiplayer->teamsSelect, ammo); + CreateGame(ui.pageMultiplayer->gameCFG, ui.pageMultiplayer->teamsSelect, ammo); - game->StartLocal(); + game->StartLocal(); } void HWForm::GameStateChanged(GameState gameState) { - switch(gameState) { - case gsStarted: { - Music(false); - if (wBackground) wBackground->stopAnimation(); - GoToPage(ID_PAGE_INGAME); - ui.pageGameStats->clear(); - if (pRegisterServer) - { - pRegisterServer->unregister(); - pRegisterServer = 0; - } - //setVisible(false); - setFocusPolicy(Qt::NoFocus); - break; - } - case gsFinished: { - //setVisible(true); - setFocusPolicy(Qt::StrongFocus); - GoBack(); - Music(ui.pageOptions->CBEnableFrontendMusic->isChecked()); - if (wBackground) wBackground->startAnimation(); - GoToPage(ID_PAGE_GAMESTATS); - if (hwnet) hwnet->gameFinished(); - break; - } - default: { - //setVisible(true); - setFocusPolicy(Qt::StrongFocus); - quint8 id = ui.Pages->currentIndex(); - if (id == ID_PAGE_INGAME) { - GoBack(); - Music(ui.pageOptions->CBEnableFrontendMusic->isChecked()); - if (wBackground) wBackground->startAnimation(); - if (hwnet) hwnet->gameFinished(); - } - }; - } + switch(gameState) { + case gsStarted: { + Music(false); + if (wBackground) wBackground->stopAnimation(); + GoToPage(ID_PAGE_INGAME); + ui.pageGameStats->clear(); + if (pRegisterServer) + { + pRegisterServer->unregister(); + pRegisterServer = 0; + } + //setVisible(false); + setFocusPolicy(Qt::NoFocus); + break; + } + case gsFinished: { + //setVisible(true); + setFocusPolicy(Qt::StrongFocus); + GoBack(); + Music(ui.pageOptions->CBEnableFrontendMusic->isChecked()); + if (wBackground) wBackground->startAnimation(); + GoToPage(ID_PAGE_GAMESTATS); + if (hwnet) hwnet->gameFinished(); + break; + } + default: { + //setVisible(true); + setFocusPolicy(Qt::StrongFocus); + quint8 id = ui.Pages->currentIndex(); + if (id == ID_PAGE_INGAME) { + GoBack(); + Music(ui.pageOptions->CBEnableFrontendMusic->isChecked()); + if (wBackground) wBackground->startAnimation(); + if (hwnet) hwnet->gameFinished(); + } + }; + } } void HWForm::CreateGame(GameCFGWidget * gamecfg, TeamSelWidget* pTeamSelWidget, QString ammo) { - game = new HWGame(config, gamecfg, ammo, pTeamSelWidget); - connect(game, SIGNAL(GameStateChanged(GameState)), this, SLOT(GameStateChanged(GameState))); - connect(game, SIGNAL(GameStats(char, const QString &)), ui.pageGameStats, SLOT(GameStats(char, const QString &))); - connect(game, SIGNAL(ErrorMessage(const QString &)), this, SLOT(ShowErrorMessage(const QString &)), Qt::QueuedConnection); - connect(game, SIGNAL(HaveRecord(bool, const QByteArray &)), this, SLOT(GetRecord(bool, const QByteArray &))); + game = new HWGame(config, gamecfg, ammo, pTeamSelWidget); + connect(game, SIGNAL(GameStateChanged(GameState)), this, SLOT(GameStateChanged(GameState))); + connect(game, SIGNAL(GameStats(char, const QString &)), ui.pageGameStats, SLOT(GameStats(char, const QString &))); + connect(game, SIGNAL(ErrorMessage(const QString &)), this, SLOT(ShowErrorMessage(const QString &)), Qt::QueuedConnection); + connect(game, SIGNAL(HaveRecord(bool, const QByteArray &)), this, SLOT(GetRecord(bool, const QByteArray &))); } void HWForm::ShowErrorMessage(const QString & msg) { - QMessageBox::warning(this, - "Hedgewars", - msg); + QMessageBox::warning(this, + "Hedgewars", + msg); } void HWForm::GetRecord(bool isDemo, const QByteArray & record) { - QString filename; - QByteArray demo = record; - QString recordFileName = - config->appendDateTimeToRecordName() ? - QDateTime::currentDateTime().toString("yyyy-MM-dd_hh-mm") : - "LastRound"; + QString filename; + QByteArray demo = record; + QString recordFileName = + config->appendDateTimeToRecordName() ? + QDateTime::currentDateTime().toString("yyyy-MM-dd_hh-mm") : + "LastRound"; - if (isDemo) - { - demo.replace(QByteArray("\x02TL"), QByteArray("\x02TD")); - demo.replace(QByteArray("\x02TN"), QByteArray("\x02TD")); - demo.replace(QByteArray("\x02TS"), QByteArray("\x02TD")); - filename = cfgdir->absolutePath() + "/Demos/" + recordFileName + "." + *cProtoVer + ".hwd"; - } else - { - demo.replace(QByteArray("\x02TL"), QByteArray("\x02TS")); - demo.replace(QByteArray("\x02TN"), QByteArray("\x02TS")); - filename = cfgdir->absolutePath() + "/Saves/" + recordFileName + "." + *cProtoVer + ".hws"; - } + if (isDemo) + { + demo.replace(QByteArray("\x02TL"), QByteArray("\x02TD")); + demo.replace(QByteArray("\x02TN"), QByteArray("\x02TD")); + demo.replace(QByteArray("\x02TS"), QByteArray("\x02TD")); + filename = cfgdir->absolutePath() + "/Demos/" + recordFileName + "." + *cProtoVer + ".hwd"; + } else + { + demo.replace(QByteArray("\x02TL"), QByteArray("\x02TS")); + demo.replace(QByteArray("\x02TN"), QByteArray("\x02TS")); + filename = cfgdir->absolutePath() + "/Saves/" + recordFileName + "." + *cProtoVer + ".hws"; + } - QFile demofile(filename); - if (!demofile.open(QIODevice::WriteOnly)) - { - ShowErrorMessage(tr("Cannot save record to file %1").arg(filename)); - return ; - } - demofile.write(demo.constData(), demo.size()); - demofile.close(); + QFile demofile(filename); + if (!demofile.open(QIODevice::WriteOnly)) + { + ShowErrorMessage(tr("Cannot save record to file %1").arg(filename)); + return ; + } + demofile.write(demo.constData(), demo.size()); + demofile.close(); } void HWForm::StartTraining() { - CreateGame(0, 0, 0); + CreateGame(0, 0, 0); - game->StartTraining(ui.pageTraining->CBSelect->currentText()); + game->StartTraining(ui.pageTraining->CBSelect->currentText()); } void HWForm::CreateNetGame() { - QString ammo; - ammo = ui.pageNetGame->pGameCFG->WeaponsName->itemData( - ui.pageNetGame->pGameCFG->WeaponsName->currentIndex() - ).toString(); + QString ammo; + ammo = ui.pageNetGame->pGameCFG->WeaponsName->itemData( + ui.pageNetGame->pGameCFG->WeaponsName->currentIndex() + ).toString(); - CreateGame(ui.pageNetGame->pGameCFG, ui.pageNetGame->pNetTeamsWidget, ammo); + CreateGame(ui.pageNetGame->pGameCFG, ui.pageNetGame->pNetTeamsWidget, ammo); - connect(game, SIGNAL(SendNet(const QByteArray &)), hwnet, SLOT(SendNet(const QByteArray &))); - connect(game, SIGNAL(SendChat(const QString &)), hwnet, SLOT(chatLineToNet(const QString &))); - connect(game, SIGNAL(SendTeamMessage(const QString &)), hwnet, SLOT(SendTeamMessage(const QString &))); - connect(hwnet, SIGNAL(FromNet(const QByteArray &)), game, SLOT(FromNet(const QByteArray &))); - connect(hwnet, SIGNAL(chatStringFromNet(const QString &)), game, SLOT(FromNetChat(const QString &))); + connect(game, SIGNAL(SendNet(const QByteArray &)), hwnet, SLOT(SendNet(const QByteArray &))); + connect(game, SIGNAL(SendChat(const QString &)), hwnet, SLOT(chatLineToNet(const QString &))); + connect(game, SIGNAL(SendTeamMessage(const QString &)), hwnet, SLOT(SendTeamMessage(const QString &))); + connect(hwnet, SIGNAL(FromNet(const QByteArray &)), game, SLOT(FromNet(const QByteArray &))); + connect(hwnet, SIGNAL(chatStringFromNet(const QString &)), game, SLOT(FromNetChat(const QString &))); - game->StartNet(); + game->StartNet(); } void HWForm::closeEvent(QCloseEvent *event) { #ifdef USE_XFIRE - xfire_free(); + xfire_free(); #endif - config->SaveOptions(); - event->accept(); + config->SaveOptions(); + event->accept(); } void HWForm::Music(bool checked) { - if (checked) - sdli.StartMusic(); - else - sdli.StopMusic(); + if (checked) + sdli.StartMusic(); + else + sdli.StopMusic(); } void HWForm::NetGameChangeStatus(bool isMaster) { - if (isMaster) - NetGameMaster(); - else - NetGameSlave(); + if (isMaster) + NetGameMaster(); + else + NetGameSlave(); } void HWForm::NetGameMaster() { - ui.pageNetGame->setMasterMode(true); - ui.pageNetGame->restrictJoins->setChecked(false); - ui.pageNetGame->restrictTeamAdds->setChecked(false); - ui.pageNetGame->pGameCFG->GameSchemes->setModel(ammoSchemeModel); - ui.pageNetGame->pGameCFG->setEnabled(true); - ui.pageNetGame->pNetTeamsWidget->setInteractivity(true); + ui.pageNetGame->setMasterMode(true); + ui.pageNetGame->restrictJoins->setChecked(false); + ui.pageNetGame->restrictTeamAdds->setChecked(false); + ui.pageNetGame->pGameCFG->GameSchemes->setModel(ammoSchemeModel); + ui.pageNetGame->pGameCFG->setEnabled(true); + ui.pageNetGame->pNetTeamsWidget->setInteractivity(true); - if (hwnet) - { - // disconnect connections first to ensure their inexistance and not to connect twice - ui.pageNetGame->BtnStart->disconnect(hwnet); - ui.pageNetGame->restrictJoins->disconnect(hwnet); - ui.pageNetGame->restrictTeamAdds->disconnect(hwnet); - connect(ui.pageNetGame->BtnStart, SIGNAL(clicked()), hwnet, SLOT(startGame())); - connect(ui.pageNetGame->restrictJoins, SIGNAL(triggered()), hwnet, SLOT(toggleRestrictJoins())); - connect(ui.pageNetGame->restrictTeamAdds, SIGNAL(triggered()), hwnet, SLOT(toggleRestrictTeamAdds())); - connect(ui.pageNetGame->pGameCFG->GameSchemes->model(), - SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), - ui.pageNetGame->pGameCFG, - SLOT(resendSchemeData()) - ); - } + if (hwnet) + { + // disconnect connections first to ensure their inexistance and not to connect twice + ui.pageNetGame->BtnStart->disconnect(hwnet); + ui.pageNetGame->restrictJoins->disconnect(hwnet); + ui.pageNetGame->restrictTeamAdds->disconnect(hwnet); + connect(ui.pageNetGame->BtnStart, SIGNAL(clicked()), hwnet, SLOT(startGame())); + connect(ui.pageNetGame->restrictJoins, SIGNAL(triggered()), hwnet, SLOT(toggleRestrictJoins())); + connect(ui.pageNetGame->restrictTeamAdds, SIGNAL(triggered()), hwnet, SLOT(toggleRestrictTeamAdds())); + connect(ui.pageNetGame->pGameCFG->GameSchemes->model(), + SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), + ui.pageNetGame->pGameCFG, + SLOT(resendSchemeData()) + ); + } } void HWForm::NetGameSlave() { - ui.pageNetGame->pGameCFG->setEnabled(false); - ui.pageNetGame->pNetTeamsWidget->setInteractivity(false); + ui.pageNetGame->pGameCFG->setEnabled(false); + ui.pageNetGame->pNetTeamsWidget->setInteractivity(false); - if (hwnet) - { - NetAmmoSchemeModel * netAmmo = new NetAmmoSchemeModel(hwnet); - connect(hwnet, SIGNAL(netSchemeConfig(QStringList &)), netAmmo, SLOT(setNetSchemeConfig(QStringList &))); - ui.pageNetGame->pGameCFG->GameSchemes->setModel(netAmmo); + if (hwnet) + { + NetAmmoSchemeModel * netAmmo = new NetAmmoSchemeModel(hwnet); + connect(hwnet, SIGNAL(netSchemeConfig(QStringList &)), netAmmo, SLOT(setNetSchemeConfig(QStringList &))); + ui.pageNetGame->pGameCFG->GameSchemes->setModel(netAmmo); - ui.pageNetGame->pGameCFG->GameSchemes->view()->disconnect(hwnet); - connect(hwnet, SIGNAL(netSchemeConfig(QStringList &)), - this, SLOT(selectFirstNetScheme())); - } + ui.pageNetGame->pGameCFG->GameSchemes->view()->disconnect(hwnet); + connect(hwnet, SIGNAL(netSchemeConfig(QStringList &)), + this, SLOT(selectFirstNetScheme())); + } - ui.pageNetGame->setMasterMode(false); + ui.pageNetGame->setMasterMode(false); } void HWForm::selectFirstNetScheme() { - ui.pageNetGame->pGameCFG->GameSchemes->setCurrentIndex(0); + ui.pageNetGame->pGameCFG->GameSchemes->setCurrentIndex(0); } void HWForm::NetLeftRoom() { - if (ui.Pages->currentIndex() == ID_PAGE_NETGAME) - GoBack(); - else - qWarning("Left room while not in room"); + if (ui.Pages->currentIndex() == ID_PAGE_NETGAME) + GoBack(); + else + qWarning("Left room while not in room"); } void HWForm::resizeEvent(QResizeEvent * event) { - int w = event->size().width(); - int h = event->size().height(); + int w = event->size().width(); + int h = event->size().height(); if (wBackground) { wBackground->setFixedSize(w, h); wBackground->move(0, 0); diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/hwform.h --- a/QTfrontend/hwform.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/hwform.h Sat Mar 06 10:59:20 2010 +0000 @@ -48,118 +48,118 @@ class HWForm : public QMainWindow { - Q_OBJECT + Q_OBJECT public: - HWForm(QWidget *parent = 0); - Ui_HWForm ui; - SDLInteraction sdli; - GameUIConfig * config; + HWForm(QWidget *parent = 0); + Ui_HWForm ui; + SDLInteraction sdli; + GameUIConfig * config; QSettings * gameSettings; // Same file GameUIConfig points to but without the baggage. Needs sync() calls if you want to get GameUIConfig changes though - void updateXfire(); + void updateXfire(); private slots: - void GoToMain(); - void GoToSinglePlayer(); - void GoToSetup(); - void GoToMultiplayer(); - void GoToSaves(); - void GoToDemos(); - void GoToNet(); - void GoToNetType(); - void GoToInfo(); - void GoToTraining(); - void GoToSelectWeapon(); - void GoToSelectWeaponSet(const QString & name); - void GoToSelectNewWeapon(); - void GoToNetServer(); - void GoToSchemes(); - void GoToAdmin(); - void GoToPage(quint8 id); - void GoBack(); - void btnExitPressed(); - void btnExitClicked(); - void IntermediateSetup(); - void NewTeam(); - void EditTeam(); - void RandomNames(); - void RandomName(const int &i); - void TeamSave(); - void TeamDiscard(); - void SimpleGame(); - void PlayDemo(); - void StartTraining(); - void NetConnect(); - void NetConnectServer(const QString & host, quint16 port); - void NetConnectOfficialServer(); - void NetStartServer(); - void NetDisconnect(); - void NetConnected(); - void NetGameEnter(); - void AddNetTeam(const HWTeam& team); - void StartMPGame(); - void GameStateChanged(GameState gameState); - void ForcedDisconnect(); - void ShowErrorMessage(const QString &); - void GetRecord(bool isDemo, const QByteArray & record); - void CreateNetGame(); - void UpdateWeapons(); - void onFrontendFullscreen(bool value); - void Music(bool checked); + void GoToMain(); + void GoToSinglePlayer(); + void GoToSetup(); + void GoToMultiplayer(); + void GoToSaves(); + void GoToDemos(); + void GoToNet(); + void GoToNetType(); + void GoToInfo(); + void GoToTraining(); + void GoToSelectWeapon(); + void GoToSelectWeaponSet(const QString & name); + void GoToSelectNewWeapon(); + void GoToNetServer(); + void GoToSchemes(); + void GoToAdmin(); + void GoToPage(quint8 id); + void GoBack(); + void btnExitPressed(); + void btnExitClicked(); + void IntermediateSetup(); + void NewTeam(); + void EditTeam(); + void RandomNames(); + void RandomName(const int &i); + void TeamSave(); + void TeamDiscard(); + void SimpleGame(); + void PlayDemo(); + void StartTraining(); + void NetConnect(); + void NetConnectServer(const QString & host, quint16 port); + void NetConnectOfficialServer(); + void NetStartServer(); + void NetDisconnect(); + void NetConnected(); + void NetGameEnter(); + void AddNetTeam(const HWTeam& team); + void StartMPGame(); + void GameStateChanged(GameState gameState); + void ForcedDisconnect(); + void ShowErrorMessage(const QString &); + void GetRecord(bool isDemo, const QByteArray & record); + void CreateNetGame(); + void UpdateWeapons(); + void onFrontendFullscreen(bool value); + void Music(bool checked); - void NetGameChangeStatus(bool isMaster); - void NetGameMaster(); - void NetGameSlave(); + void NetGameChangeStatus(bool isMaster); + void NetGameMaster(); + void NetGameSlave(); - void AsyncNetServerStart(); - void NetLeftRoom(); - void selectFirstNetScheme(); + void AsyncNetServerStart(); + void NetLeftRoom(); + void selectFirstNetScheme(); private: - void _NetConnect(const QString & hostName, quint16 port, const QString & nick); - void UpdateTeamsLists(const QStringList* editable_teams=0); - void CreateGame(GameCFGWidget * gamecfg, TeamSelWidget* pTeamSelWidget, QString ammo); - void closeEvent(QCloseEvent *event); - void CustomizePalettes(); - void resizeEvent(QResizeEvent * event); + void _NetConnect(const QString & hostName, quint16 port, const QString & nick); + void UpdateTeamsLists(const QStringList* editable_teams=0); + void CreateGame(GameCFGWidget * gamecfg, TeamSelWidget* pTeamSelWidget, QString ammo); + void closeEvent(QCloseEvent *event); + void CustomizePalettes(); + void resizeEvent(QResizeEvent * event); - enum PageIDs { - ID_PAGE_SETUP_TEAM = 0, - ID_PAGE_SETUP = 1, - ID_PAGE_MULTIPLAYER = 2, - ID_PAGE_DEMOS = 3, - ID_PAGE_NET = 4, - ID_PAGE_NETGAME = 5, - ID_PAGE_INFO = 6, - ID_PAGE_MAIN = 7, - ID_PAGE_GAMESTATS = 8, - ID_PAGE_SINGLEPLAYER = 9, - ID_PAGE_TRAINING = 10, - ID_PAGE_SELECTWEAPON = 11, - ID_PAGE_NETSERVER = 12, - ID_PAGE_INGAME = 13, - ID_PAGE_ROOMSLIST = 14, - ID_PAGE_CONNECTING = 15, - ID_PAGE_SCHEME = 16, - ID_PAGE_ADMIN = 17, - ID_PAGE_NETTYPE = 18 - }; - HWGame * game; - HWNetServer* pnetserver; - HWNetRegisterServer* pRegisterServer; - HWTeam * editedTeam; - HWNewNet * hwnet; - HWNamegen * namegen; - AmmoSchemeModel * ammoSchemeModel; - QStack PagesStack; - QTime eggTimer; - BGWidget * wBackground; + enum PageIDs { + ID_PAGE_SETUP_TEAM = 0, + ID_PAGE_SETUP = 1, + ID_PAGE_MULTIPLAYER = 2, + ID_PAGE_DEMOS = 3, + ID_PAGE_NET = 4, + ID_PAGE_NETGAME = 5, + ID_PAGE_INFO = 6, + ID_PAGE_MAIN = 7, + ID_PAGE_GAMESTATS = 8, + ID_PAGE_SINGLEPLAYER = 9, + ID_PAGE_TRAINING = 10, + ID_PAGE_SELECTWEAPON = 11, + ID_PAGE_NETSERVER = 12, + ID_PAGE_INGAME = 13, + ID_PAGE_ROOMSLIST = 14, + ID_PAGE_CONNECTING = 15, + ID_PAGE_SCHEME = 16, + ID_PAGE_ADMIN = 17, + ID_PAGE_NETTYPE = 18 + }; + HWGame * game; + HWNetServer* pnetserver; + HWNetRegisterServer* pRegisterServer; + HWTeam * editedTeam; + HWNewNet * hwnet; + HWNamegen * namegen; + AmmoSchemeModel * ammoSchemeModel; + QStack PagesStack; + QTime eggTimer; + BGWidget * wBackground; #ifdef __APPLE__ InstallController * panel; #endif - void OnPageShown(quint8 id, quint8 lastid=0); + void OnPageShown(quint8 id, quint8 lastid=0); }; #endif diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/hwmap.cpp --- a/QTfrontend/hwmap.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/hwmap.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -29,35 +29,35 @@ void HWMap::getImage(std::string seed, int filter) { - m_seed = seed; - templateFilter = filter; - Start(); + m_seed = seed; + templateFilter = filter; + Start(); } QStringList HWMap::setArguments() { - QStringList arguments; - arguments << cfgdir->absolutePath(); - arguments << QString("%1").arg(ipc_port); - arguments << "landpreview"; - return arguments; + QStringList arguments; + arguments << cfgdir->absolutePath(); + arguments << QString("%1").arg(ipc_port); + arguments << "landpreview"; + return arguments; } void HWMap::onClientDisconnect() { - if (readbuffer.size() == 128 * 32 + 1) - { - quint8 *buf = (quint8*) readbuffer.constData(); - QImage im(buf, 256, 128, QImage::Format_Mono); - im.setNumColors(2); - emit HHLimitReceived(buf[128 * 32]); - emit ImageReceived(im); - } + if (readbuffer.size() == 128 * 32 + 1) + { + quint8 *buf = (quint8*) readbuffer.constData(); + QImage im(buf, 256, 128, QImage::Format_Mono); + im.setNumColors(2); + emit HHLimitReceived(buf[128 * 32]); + emit ImageReceived(im); + } } void HWMap::SendToClientFirst() { - SendIPC(QString("eseed %1").arg(m_seed.c_str()).toLatin1()); - SendIPC(QString("e$template_filter %1").arg(templateFilter).toLatin1()); - SendIPC("!"); + SendIPC(QString("eseed %1").arg(m_seed.c_str()).toLatin1()); + SendIPC(QString("e$template_filter %1").arg(templateFilter).toLatin1()); + SendIPC("!"); } diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/igbox.cpp --- a/QTfrontend/igbox.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/igbox.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -27,50 +27,50 @@ { // Has issues with border-radius on children // setAttribute(Qt::WA_PaintOnScreen, true); - titleLeftPadding = 82; + titleLeftPadding = 82; contentTopPadding = 22; } void IconedGroupBox::setIcon(const QIcon & icon) { - if (this->icon.isNull()) - setStyleSheet(QString( - "IconedGroupBox{" - "margin-top: 46px;" - "margin-left: 12px;" + if (this->icon.isNull()) + setStyleSheet(QString( + "IconedGroupBox{" + "margin-top: 46px;" + "margin-left: 12px;" "padding: %1px 2px 5px 2px;" - "}" - "IconedGroupBox::title{" - "subcontrol-origin: margin;" - "subcontrol-position: top left;" - "padding-left: %2px;" - "padding-top: 25px;" - "text-align: left;" - "}" - ).arg(contentTopPadding).arg(titleLeftPadding) - ); + "}" + "IconedGroupBox::title{" + "subcontrol-origin: margin;" + "subcontrol-position: top left;" + "padding-left: %2px;" + "padding-top: 25px;" + "text-align: left;" + "}" + ).arg(contentTopPadding).arg(titleLeftPadding) + ); - this->icon = icon; - repaint(); + this->icon = icon; + repaint(); } void IconedGroupBox::paintEvent(QPaintEvent * event) { - QStylePainter painter(this); + QStylePainter painter(this); - QStyleOptionGroupBox option; - initStyleOption(&option); - painter.drawComplexControl(QStyle::CC_GroupBox, option); + QStyleOptionGroupBox option; + initStyleOption(&option); + painter.drawComplexControl(QStyle::CC_GroupBox, option); - icon.paint(&painter, QRect(QPoint(0, 0), icon.actualSize(size()))); + icon.paint(&painter, QRect(QPoint(0, 0), icon.actualSize(size()))); } void IconedGroupBox::setTitleTextPadding(int px) { - titleLeftPadding = px; + titleLeftPadding = px; } void IconedGroupBox::setContentTopPadding(int px) { - contentTopPadding = px; + contentTopPadding = px; } diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/igbox.h --- a/QTfrontend/igbox.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/igbox.h Sat Mar 06 10:59:20 2010 +0000 @@ -24,21 +24,21 @@ class IconedGroupBox : public QGroupBox { - Q_OBJECT + Q_OBJECT public: - IconedGroupBox(QWidget * parent = 0); + IconedGroupBox(QWidget * parent = 0); - void setIcon(const QIcon & icon); - void setTitleTextPadding(int px); - void setContentTopPadding(int px); + void setIcon(const QIcon & icon); + void setTitleTextPadding(int px); + void setContentTopPadding(int px); protected: - virtual void paintEvent(QPaintEvent * event); + virtual void paintEvent(QPaintEvent * event); private: - QIcon icon; - int titleLeftPadding; - int contentTopPadding; + QIcon icon; + int titleLeftPadding; + int contentTopPadding; }; #endif // _IGBOX_H diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/input_ip.cpp --- a/QTfrontend/input_ip.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/input_ip.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -26,43 +26,43 @@ HWHostPortDialog::HWHostPortDialog(QWidget* parent) : QDialog(parent) { - QGridLayout * layout = new QGridLayout(this); + QGridLayout * layout = new QGridLayout(this); - QLabel * lbHost = new QLabel(this); - lbHost->setText(QLabel::tr("Host:")); - layout->addWidget(lbHost, 0, 0); + QLabel * lbHost = new QLabel(this); + lbHost->setText(QLabel::tr("Host:")); + layout->addWidget(lbHost, 0, 0); - QLabel * lbPort = new QLabel(this); - lbPort->setText(QLabel::tr("Port:")); - layout->addWidget(lbPort, 1, 0); + QLabel * lbPort = new QLabel(this); + lbPort->setText(QLabel::tr("Port:")); + layout->addWidget(lbPort, 1, 0); - leHost = new QLineEdit(this); - layout->addWidget(leHost, 0, 1, 1, 2); + leHost = new QLineEdit(this); + layout->addWidget(leHost, 0, 1, 1, 2); - sbPort = new QSpinBox(this); - sbPort->setMinimum(0); - sbPort->setMaximum(65535); - layout->addWidget(sbPort, 1, 1, 1, 2); + sbPort = new QSpinBox(this); + sbPort->setMinimum(0); + sbPort->setMaximum(65535); + layout->addWidget(sbPort, 1, 1, 1, 2); - pbDefault = new QPushButton(this); - pbDefault->setText(QPushButton::tr("default")); - layout->addWidget(pbDefault, 1, 3); + pbDefault = new QPushButton(this); + pbDefault->setText(QPushButton::tr("default")); + layout->addWidget(pbDefault, 1, 3); - pbOK = new QPushButton(this); - pbOK->setText(QPushButton::tr("OK")); - pbOK->setDefault(true); - layout->addWidget(pbOK, 3, 1); + pbOK = new QPushButton(this); + pbOK->setText(QPushButton::tr("OK")); + pbOK->setDefault(true); + layout->addWidget(pbOK, 3, 1); - pbCancel = new QPushButton(this); - pbCancel->setText(QPushButton::tr("Cancel")); - layout->addWidget(pbCancel, 3, 2); + pbCancel = new QPushButton(this); + pbCancel->setText(QPushButton::tr("Cancel")); + layout->addWidget(pbCancel, 3, 2); - connect(pbOK, SIGNAL(clicked()), this, SLOT(accept())); - connect(pbCancel, SIGNAL(clicked()), this, SLOT(reject())); - connect(pbDefault, SIGNAL(clicked()), this, SLOT(setDefaultPort())); + connect(pbOK, SIGNAL(clicked()), this, SLOT(accept())); + connect(pbCancel, SIGNAL(clicked()), this, SLOT(reject())); + connect(pbDefault, SIGNAL(clicked()), this, SLOT(setDefaultPort())); } void HWHostPortDialog::setDefaultPort() { - sbPort->setValue(46631); + sbPort->setValue(46631); } diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/input_ip.h --- a/QTfrontend/input_ip.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/input_ip.h Sat Mar 06 10:59:20 2010 +0000 @@ -29,20 +29,20 @@ class HWHostPortDialog : public QDialog { - Q_OBJECT + Q_OBJECT public: - HWHostPortDialog(QWidget* parent = 0); + HWHostPortDialog(QWidget* parent = 0); - QLineEdit* leHost; - QSpinBox* sbPort; + QLineEdit* leHost; + QSpinBox* sbPort; private: - QPushButton* pbOK; - QPushButton* pbCancel; - QPushButton * pbDefault; + QPushButton* pbOK; + QPushButton* pbCancel; + QPushButton * pbDefault; private slots: - void setDefaultPort(); + void setDefaultPort(); }; diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/main.cpp --- a/QTfrontend/main.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/main.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -30,17 +30,17 @@ bool checkForDir(const QString & dir) { - QDir tmpdir; - if (!tmpdir.exists(dir)) - if (!tmpdir.mkdir(dir)) - { - QMessageBox::critical(0, - QObject::tr("Error"), - QObject::tr("Cannot create directory %1").arg(dir), - QObject::tr("OK")); - return false; - } - return true; + QDir tmpdir; + if (!tmpdir.exists(dir)) + if (!tmpdir.mkdir(dir)) + { + QMessageBox::critical(0, + QObject::tr("Error"), + QObject::tr("Cannot create directory %1").arg(dir), + QObject::tr("OK")); + return false; + } + return true; } int main(int argc, char *argv[]) { @@ -76,103 +76,103 @@ *cConfigDir = f.absoluteFilePath(); } - app.setStyle(new QPlastiqueStyle); + app.setStyle(new QPlastiqueStyle); - QDateTime now = QDateTime::currentDateTime(); - srand(now.toTime_t()); - rand(); + QDateTime now = QDateTime::currentDateTime(); + srand(now.toTime_t()); + rand(); - Q_INIT_RESOURCE(hedgewars); + Q_INIT_RESOURCE(hedgewars); - qApp->setStyleSheet - (QString( - "HWForm,QDialog{" - "background-image: url(\":/res/Background.png\");" - "background-position: bottom center;" - "background-repeat: repeat-x;" - "background-color: #141250;" - "}" + qApp->setStyleSheet + (QString( + "HWForm,QDialog{" + "background-image: url(\":/res/Background.png\");" + "background-position: bottom center;" + "background-repeat: repeat-x;" + "background-color: #141250;" + "}" - "* {" - "color: #ffcc00;" - "selection-background-color: #ffcc00;" - "selection-color: #00351d;" - "}" + "* {" + "color: #ffcc00;" + "selection-background-color: #ffcc00;" + "selection-color: #00351d;" + "}" - "QLineEdit, QListWidget, QTableView, QTextBrowser, QSpinBox, QComboBox, " + "QLineEdit, QListWidget, QTableView, QTextBrowser, QSpinBox, QComboBox, " "QComboBox QAbstractItemView, QMenu::item {" - "background-color: rgba(13, 5, 68, 70%);" - "}" + "background-color: rgba(13, 5, 68, 70%);" + "}" - "QPushButton, QListWidget, QTableView, QLineEdit, QHeaderView, " - "QTextBrowser, QSpinBox, QToolBox, QComboBox, " + "QPushButton, QListWidget, QTableView, QLineEdit, QHeaderView, " + "QTextBrowser, QSpinBox, QToolBox, QComboBox, " "QComboBox QAbstractItemView, IconedGroupBox, " - ".QGroupBox, GameCFGWidget, TeamSelWidget, SelWeaponWidget, " + ".QGroupBox, GameCFGWidget, TeamSelWidget, SelWeaponWidget, " "QTabWidget::pane, QTabBar::tab {" - "border: solid;" - "border-width: 3px;" - "border-color: #ffcc00;" - "}" + "border: solid;" + "border-width: 3px;" + "border-color: #ffcc00;" + "}" - "QPushButton:hover, QLineEdit:hover, QListWidget:hover, " - "QSpinBox:hover, QToolBox:hover, QComboBox:hover {" - "border-color: yellow;" - "}" + "QPushButton:hover, QLineEdit:hover, QListWidget:hover, " + "QSpinBox:hover, QToolBox:hover, QComboBox:hover {" + "border-color: yellow;" + "}" - "QLineEdit, QListWidget,QTableView, QTextBrowser, " - "QSpinBox, QToolBox { " - "border-radius: 12px;" - "}" + "QLineEdit, QListWidget,QTableView, QTextBrowser, " + "QSpinBox, QToolBox { " + "border-radius: 12px;" + "}" - "QLineEdit, QLabel, QHeaderView, QListWidget, QTableView, " - "QSpinBox, QToolBox::tab, QComboBox, QComboBox QAbstractItemView, " - "IconedGroupBox, .QGroupBox, GameCFGWidget, TeamSelWidget, " + "QLineEdit, QLabel, QHeaderView, QListWidget, QTableView, " + "QSpinBox, QToolBox::tab, QComboBox, QComboBox QAbstractItemView, " + "IconedGroupBox, .QGroupBox, GameCFGWidget, TeamSelWidget, " "SelWeaponWidget, QCheckBox, QRadioButton {" - "font: bold 14px;" - "}" + "font: bold 14px;" + "}" "SelWeaponWidget QTabWidget::pane, SelWeaponWidget QTabBar::tab:selected {" - "background-position: bottom center;" - "background-repeat: repeat-x;" - "background-color: #000000;" - "}" - ".QGroupBox,GameCFGWidget,TeamSelWidget,SelWeaponWidget {" - "background-position: bottom center;" - "background-repeat: repeat-x;" - "border-radius: 16px;" - "background-color: rgba(13, 5, 68, 70%);" - "padding: 6px;" - "}" + "background-position: bottom center;" + "background-repeat: repeat-x;" + "background-color: #000000;" + "}" + ".QGroupBox,GameCFGWidget,TeamSelWidget,SelWeaponWidget {" + "background-position: bottom center;" + "background-repeat: repeat-x;" + "border-radius: 16px;" + "background-color: rgba(13, 5, 68, 70%);" + "padding: 6px;" + "}" /* Experimenting with PaintOnScreen and border-radius on IconedGroupBox children didn't work out well - "IconedGroupBox QComboBox, IconedGroupBox QPushButton, IconedGroupBox QLineEdit, " + "IconedGroupBox QComboBox, IconedGroupBox QPushButton, IconedGroupBox QLineEdit, " "IconedGroupBox QSpinBox {" - "border-radius: 0;" - "}" - "IconedGroupBox, IconedGroupBox *, QTabWidget::pane, QTabBar::tab:selected, QToolBox::tab QWidget{" */ - "IconedGroupBox, QTabWidget::pane, QTabBar::tab:selected, QToolBox::tab QWidget{" - "background-color: #130f2c;" - "}" + "border-radius: 0;" + "}" + "IconedGroupBox, IconedGroupBox *, QTabWidget::pane, QTabBar::tab:selected, QToolBox::tab QWidget{" */ + "IconedGroupBox, QTabWidget::pane, QTabBar::tab:selected, QToolBox::tab QWidget{" + "background-color: #130f2c;" + "}" - "QPushButton {" - "border-radius: 10px;" - "background-origin: margin;" - "background-position: top left;" - "background-color: rgba(18, 42, 5, 70%);" - "}" + "QPushButton {" + "border-radius: 10px;" + "background-origin: margin;" + "background-position: top left;" + "background-color: rgba(18, 42, 5, 70%);" + "}" - "QPushButton:pressed{" - "border-color: white;" - "}" + "QPushButton:pressed{" + "border-color: white;" + "}" - "QHeaderView {" - "border-radius: 0;" - "border-width: 0;" - "border-bottom-width: 3px;" - "background-color: #00351d;" - "}" - "QTableView {" - "alternate-background-color: #2f213a;" - "}" + "QHeaderView {" + "border-radius: 0;" + "border-width: 0;" + "border-bottom-width: 3px;" + "background-color: #00351d;" + "}" + "QTableView {" + "alternate-background-color: #2f213a;" + "}" "QTabBar::tab {" "border-bottom-width: 0;" @@ -185,189 +185,189 @@ "color: #0d0544;" "background-color: #ffcc00;" "}" - "QSpinBox::up-button{" - "background: transparent;" - "width: 16px;" - "height: 10px;" - "}" + "QSpinBox::up-button{" + "background: transparent;" + "width: 16px;" + "height: 10px;" + "}" - "QSpinBox::up-arrow {" - "image: url(\":/res/spin_up.png\");" - "}" + "QSpinBox::up-arrow {" + "image: url(\":/res/spin_up.png\");" + "}" - "QSpinBox::down-arrow {" - "image: url(\":/res/spin_down.png\");" - "}" + "QSpinBox::down-arrow {" + "image: url(\":/res/spin_down.png\");" + "}" - "QSpinBox::down-button {" - "background: transparent;" - "width: 16px;" - "height: 10px;" - "}" + "QSpinBox::down-button {" + "background: transparent;" + "width: 16px;" + "height: 10px;" + "}" - "QComboBox {" - "border-radius: 15px;" - "padding: 3px;" - "}" - "QComboBox:pressed{" - "border-color: white;" - "}" - "QComboBox::drop-down{" - "border: transparent;" - "width: 25px;" - "}" - "QComboBox::down-arrow {" - "image: url(\":/res/dropdown.png\");" - "}" + "QComboBox {" + "border-radius: 15px;" + "padding: 3px;" + "}" + "QComboBox:pressed{" + "border-color: white;" + "}" + "QComboBox::drop-down{" + "border: transparent;" + "width: 25px;" + "}" + "QComboBox::down-arrow {" + "image: url(\":/res/dropdown.png\");" + "}" - "VertScrArea {" - "background-position: bottom center;" - "background-repeat: repeat-x;" - "}" + "VertScrArea {" + "background-position: bottom center;" + "background-repeat: repeat-x;" + "}" - "IconedGroupBox {" - "border-radius: 16px;" - "padding: 2px;" - "}" + "IconedGroupBox {" + "border-radius: 16px;" + "padding: 2px;" + "}" - "QGroupBox::title{" - "subcontrol-origin: margin;" - "subcontrol-position: top left;" - "text-align: left;" - "}" + "QGroupBox::title{" + "subcontrol-origin: margin;" + "subcontrol-position: top left;" + "text-align: left;" + "}" - "QCheckBox::indicator:checked{" - "image: url(\":/res/checked.png\");" - "}" - "QCheckBox::indicator:unchecked{" - "image: url(\":/res/unchecked.png\");" - "}" + "QCheckBox::indicator:checked{" + "image: url(\":/res/checked.png\");" + "}" + "QCheckBox::indicator:unchecked{" + "image: url(\":/res/unchecked.png\");" + "}" - ".QWidget{" - "background: transparent;" - "}" + ".QWidget{" + "background: transparent;" + "}" - "QTabWidget::pane {" + "QTabWidget::pane {" "border-top-width: 2px;" - "}" + "}" - "QMenu{" - "background-color: #ffcc00;" - "margin: 3px;" - "}" - "QMenu::item {" - "background-color: #0d0544;" - "border: 1px solid transparent;" - "font: bold;" - "padding: 2px 25px 2px 20px;" - "}" - "QMenu::item:selected {" - "background-color: #2d2564;" - "}" - "QMenu::indicator {" - "width: 16px;" - "height: 16px;" - "}" - "QMenu::indicator:non-exclusive:checked{" - "image: url(\":/res/checked.png\");" - "}" - "QMenu::indicator:non-exclusive:unchecked{" - "image: url(\":/res/unchecked.png\");" - "}" + "QMenu{" + "background-color: #ffcc00;" + "margin: 3px;" + "}" + "QMenu::item {" + "background-color: #0d0544;" + "border: 1px solid transparent;" + "font: bold;" + "padding: 2px 25px 2px 20px;" + "}" + "QMenu::item:selected {" + "background-color: #2d2564;" + "}" + "QMenu::indicator {" + "width: 16px;" + "height: 16px;" + "}" + "QMenu::indicator:non-exclusive:checked{" + "image: url(\":/res/checked.png\");" + "}" + "QMenu::indicator:non-exclusive:unchecked{" + "image: url(\":/res/unchecked.png\");" + "}" - "QToolTip{" - "background-color: #0d0544;" - "}" + "QToolTip{" + "background-color: #0d0544;" + "}" - ":disabled{" - "color: #a0a0a0;" - "}" + ":disabled{" + "color: #a0a0a0;" + "}" "SquareLabel, ItemNum {" - "background-color: #000000;" - "}" - ) - ); + "background-color: #000000;" + "}" + ) + ); - bindir->cd("bin"); // workaround over NSIS installer + bindir->cd("bin"); // workaround over NSIS installer - if(cConfigDir->length() == 0) - cfgdir->setPath(cfgdir->homePath()); - else - cfgdir->setPath(*cConfigDir); + if(cConfigDir->length() == 0) + cfgdir->setPath(cfgdir->homePath()); + else + cfgdir->setPath(*cConfigDir); - if(cConfigDir->length() == 0) - { + if(cConfigDir->length() == 0) + { #ifdef __APPLE__ - if (checkForDir(cfgdir->absolutePath() + "/Library/Application Support/Hedgewars")) - { - checkForDir(cfgdir->absolutePath() + "/Library/Application Support/Hedgewars/Demos"); - checkForDir(cfgdir->absolutePath() + "/Library/Application Support/Hedgewars/Saves"); - } - cfgdir->cd("Library/Application Support/Hedgewars"); + if (checkForDir(cfgdir->absolutePath() + "/Library/Application Support/Hedgewars")) + { + checkForDir(cfgdir->absolutePath() + "/Library/Application Support/Hedgewars/Demos"); + checkForDir(cfgdir->absolutePath() + "/Library/Application Support/Hedgewars/Saves"); + } + cfgdir->cd("Library/Application Support/Hedgewars"); #else - if (checkForDir(cfgdir->absolutePath() + "/.hedgewars")) - { - checkForDir(cfgdir->absolutePath() + "/.hedgewars/Demos"); - checkForDir(cfgdir->absolutePath() + "/.hedgewars/Saves"); - } - cfgdir->cd(".hedgewars"); + if (checkForDir(cfgdir->absolutePath() + "/.hedgewars")) + { + checkForDir(cfgdir->absolutePath() + "/.hedgewars/Demos"); + checkForDir(cfgdir->absolutePath() + "/.hedgewars/Saves"); + } + cfgdir->cd(".hedgewars"); #endif - } - else - { - if (checkForDir(cfgdir->absolutePath())) - { - checkForDir(cfgdir->absolutePath() + "/Demos"); - checkForDir(cfgdir->absolutePath() + "/Saves"); - } - } + } + else + { + if (checkForDir(cfgdir->absolutePath())) + { + checkForDir(cfgdir->absolutePath() + "/Demos"); + checkForDir(cfgdir->absolutePath() + "/Saves"); + } + } - datadir->cd(bindir->absolutePath()); - datadir->cd(*cDataDir); - if(!datadir->cd("hedgewars/Data")) { - QMessageBox::critical(0, QMessageBox::tr("Error"), - QMessageBox::tr("Failed to open data directory:\n%1\n" - "Please check your installation"). - arg(datadir->absolutePath()+"/hedgewars/Data")); - return 1; - } + datadir->cd(bindir->absolutePath()); + datadir->cd(*cDataDir); + if(!datadir->cd("hedgewars/Data")) { + QMessageBox::critical(0, QMessageBox::tr("Error"), + QMessageBox::tr("Failed to open data directory:\n%1\n" + "Please check your installation"). + arg(datadir->absolutePath()+"/hedgewars/Data")); + return 1; + } - Themes = new QStringList(); - QFile themesfile(datadir->absolutePath() + "/Themes/themes.cfg"); - if (themesfile.open(QIODevice::ReadOnly)) { - QTextStream stream(&themesfile); - QString str; - while (!stream.atEnd()) - { - Themes->append(stream.readLine()); - } - themesfile.close(); - } else { - QMessageBox::critical(0, "Error", "Cannot access themes.cfg", "OK"); - } + Themes = new QStringList(); + QFile themesfile(datadir->absolutePath() + "/Themes/themes.cfg"); + if (themesfile.open(QIODevice::ReadOnly)) { + QTextStream stream(&themesfile); + QString str; + while (!stream.atEnd()) + { + Themes->append(stream.readLine()); + } + themesfile.close(); + } else { + QMessageBox::critical(0, "Error", "Cannot access themes.cfg", "OK"); + } - QDir tmpdir; - tmpdir.cd(datadir->absolutePath()); - tmpdir.cd("Maps"); - tmpdir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); - mapList = new QStringList(tmpdir.entryList(QStringList("*"))); + QDir tmpdir; + tmpdir.cd(datadir->absolutePath()); + tmpdir.cd("Maps"); + tmpdir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); + mapList = new QStringList(tmpdir.entryList(QStringList("*"))); - QTranslator Translator; - { - QSettings settings(cfgdir->absolutePath() + "/hedgewars.ini", QSettings::IniFormat); - QString cc = settings.value("misc/locale", "").toString(); - if(!cc.compare("")) - cc = QLocale::system().name(); - Translator.load(datadir->absolutePath() + "/Locale/hedgewars_" + cc); - app.installTranslator(&Translator); - } + QTranslator Translator; + { + QSettings settings(cfgdir->absolutePath() + "/hedgewars.ini", QSettings::IniFormat); + QString cc = settings.value("misc/locale", "").toString(); + if(!cc.compare("")) + cc = QLocale::system().name(); + Translator.load(datadir->absolutePath() + "/Locale/hedgewars_" + cc); + app.installTranslator(&Translator); + } - HWForm *Form = new HWForm(); + HWForm *Form = new HWForm(); - Form->show(); - return app.exec(); + Form->show(); + return app.exec(); } diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/mapContainer.cpp --- a/QTfrontend/mapContainer.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/mapContainer.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -35,139 +35,139 @@ #include "igbox.h" HWMapContainer::HWMapContainer(QWidget * parent) : - QWidget(parent), - mainLayout(this), - pMap(0) + QWidget(parent), + mainLayout(this), + pMap(0) { - hhSmall.load(":/res/hh_small.png"); - hhLimit = 18; + hhSmall.load(":/res/hh_small.png"); + hhLimit = 18; templateFilter = 0; - mainLayout.setContentsMargins(QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin), - 1, - QApplication::style()->pixelMetric(QStyle::PM_LayoutRightMargin), - QApplication::style()->pixelMetric(QStyle::PM_LayoutBottomMargin)); + mainLayout.setContentsMargins(QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin), + 1, + QApplication::style()->pixelMetric(QStyle::PM_LayoutRightMargin), + QApplication::style()->pixelMetric(QStyle::PM_LayoutBottomMargin)); - imageButt = new QPushButton(this); - imageButt->setObjectName("imageButt"); - imageButt->setFixedSize(256 + 6, 128 + 6); - imageButt->setFlat(true); - imageButt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);//QSizePolicy::Minimum, QSizePolicy::Minimum); - mainLayout.addWidget(imageButt, 0, 0, 1, 2); - connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomSeed())); - connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomTheme())); + imageButt = new QPushButton(this); + imageButt->setObjectName("imageButt"); + imageButt->setFixedSize(256 + 6, 128 + 6); + imageButt->setFlat(true); + imageButt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);//QSizePolicy::Minimum, QSizePolicy::Minimum); + mainLayout.addWidget(imageButt, 0, 0, 1, 2); + connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomSeed())); + connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomTheme())); - chooseMap = new QComboBox(this); - chooseMap->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - chooseMap->addItem(QComboBox::tr("generated map...")); - for (int i = 0; i < mapList->size(); ++i) { - QString map = (*mapList)[i]; - QFile mapCfgFile( - QString("%1/Maps/%2/map.cfg") - .arg(datadir->absolutePath()) - .arg(map)); + chooseMap = new QComboBox(this); + chooseMap->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + chooseMap->addItem(QComboBox::tr("generated map...")); + for (int i = 0; i < mapList->size(); ++i) { + QString map = (*mapList)[i]; + QFile mapCfgFile( + QString("%1/Maps/%2/map.cfg") + .arg(datadir->absolutePath()) + .arg(map)); - if (mapCfgFile.open(QFile::ReadOnly)) { - QString theme; - quint32 limit = 0; - QList mapInfo; - QTextStream input(&mapCfgFile); - input >> theme; - input >> limit; - mapInfo.push_back(theme); - if (limit) - mapInfo.push_back(limit); - else - mapInfo.push_back(18); - chooseMap->addItem(map, mapInfo); - mapCfgFile.close(); - } - } + if (mapCfgFile.open(QFile::ReadOnly)) { + QString theme; + quint32 limit = 0; + QList mapInfo; + QTextStream input(&mapCfgFile); + input >> theme; + input >> limit; + mapInfo.push_back(theme); + if (limit) + mapInfo.push_back(limit); + else + mapInfo.push_back(18); + chooseMap->addItem(map, mapInfo); + mapCfgFile.close(); + } + } - connect(chooseMap, SIGNAL(currentIndexChanged(int)), this, SLOT(mapChanged(int))); - mainLayout.addWidget(chooseMap, 1, 1); + connect(chooseMap, SIGNAL(currentIndexChanged(int)), this, SLOT(mapChanged(int))); + mainLayout.addWidget(chooseMap, 1, 1); - QLabel * lblMap = new QLabel(tr("Map"), this); - mainLayout.addWidget(lblMap, 1, 0); + QLabel * lblMap = new QLabel(tr("Map"), this); + mainLayout.addWidget(lblMap, 1, 0); - lblFilter = new QLabel(tr("Filter"), this); - mainLayout.addWidget(lblFilter, 2, 0); + lblFilter = new QLabel(tr("Filter"), this); + mainLayout.addWidget(lblFilter, 2, 0); - CB_TemplateFilter = new QComboBox(this); + CB_TemplateFilter = new QComboBox(this); CB_TemplateFilter->addItem(tr("All"), 0); CB_TemplateFilter->addItem(tr("Small"), 1); CB_TemplateFilter->addItem(tr("Medium"), 2); CB_TemplateFilter->addItem(tr("Large"), 3); CB_TemplateFilter->addItem(tr("Cavern"), 4); CB_TemplateFilter->addItem(tr("Wacky"), 5); - mainLayout.addWidget(CB_TemplateFilter, 2, 1); + mainLayout.addWidget(CB_TemplateFilter, 2, 1); - connect(CB_TemplateFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(templateFilterChanged(int))); + connect(CB_TemplateFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(templateFilterChanged(int))); - gbThemes = new IconedGroupBox(this); - gbThemes->setTitleTextPadding(60); - gbThemes->setContentTopPadding(6); - gbThemes->setTitle(tr("Themes")); + gbThemes = new IconedGroupBox(this); + gbThemes->setTitleTextPadding(60); + gbThemes->setContentTopPadding(6); + gbThemes->setTitle(tr("Themes")); - //gbThemes->setStyleSheet("padding: 0px"); // doesn't work - stylesheet is set with icon - mainLayout.addWidget(gbThemes, 0, 2, 3, 1); + //gbThemes->setStyleSheet("padding: 0px"); // doesn't work - stylesheet is set with icon + mainLayout.addWidget(gbThemes, 0, 2, 3, 1); - QVBoxLayout * gbTLayout = new QVBoxLayout(gbThemes); - gbTLayout->setContentsMargins(0, 0, 0 ,0); - gbTLayout->setSpacing(0); - lwThemes = new QListWidget(this); - lwThemes->setMinimumHeight(30); - lwThemes->setFixedWidth(120); - for (int i = 0; i < Themes->size(); ++i) { - QListWidgetItem * lwi = new QListWidgetItem(); - lwi->setText(Themes->at(i)); - lwi->setTextAlignment(Qt::AlignHCenter); - lwThemes->addItem(lwi); - } - connect(lwThemes, SIGNAL(currentRowChanged(int)), this, SLOT(themeSelected(int))); + QVBoxLayout * gbTLayout = new QVBoxLayout(gbThemes); + gbTLayout->setContentsMargins(0, 0, 0 ,0); + gbTLayout->setSpacing(0); + lwThemes = new QListWidget(this); + lwThemes->setMinimumHeight(30); + lwThemes->setFixedWidth(120); + for (int i = 0; i < Themes->size(); ++i) { + QListWidgetItem * lwi = new QListWidgetItem(); + lwi->setText(Themes->at(i)); + lwi->setTextAlignment(Qt::AlignHCenter); + lwThemes->addItem(lwi); + } + connect(lwThemes, SIGNAL(currentRowChanged(int)), this, SLOT(themeSelected(int))); // override default style to tighten up theme scroller - lwThemes->setStyleSheet(QString( - "QListWidget{" - "border: solid;" - "border-width: 0px;" - "border-radius: 0px;" - "border-color: transparent;" - "background-color: #0d0544;" - "color: #ffcc00;" - "font: bold 14px;" - "}" - ) - ); + lwThemes->setStyleSheet(QString( + "QListWidget{" + "border: solid;" + "border-width: 0px;" + "border-radius: 0px;" + "border-color: transparent;" + "background-color: #0d0544;" + "color: #ffcc00;" + "font: bold 14px;" + "}" + ) + ); - gbTLayout->addWidget(lwThemes); - lwThemes->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum); + gbTLayout->addWidget(lwThemes); + lwThemes->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum); - mainLayout.setSizeConstraint(QLayout::SetFixedSize);//SetMinimumSize + mainLayout.setSizeConstraint(QLayout::SetFixedSize);//SetMinimumSize - setRandomSeed(); - setRandomTheme(); + setRandomSeed(); + setRandomTheme(); } void HWMapContainer::setImage(const QImage newImage) { - QPixmap px(256, 128); - QPixmap pxres(256, 128); - QPainter p(&pxres); + QPixmap px(256, 128); + QPixmap pxres(256, 128); + QPainter p(&pxres); - px.fill(Qt::yellow); - QBitmap bm = QBitmap::fromImage(newImage); - px.setMask(bm); + px.fill(Qt::yellow); + QBitmap bm = QBitmap::fromImage(newImage); + px.setMask(bm); - QLinearGradient linearGrad(QPoint(128, 0), QPoint(128, 128)); - linearGrad.setColorAt(1, QColor(0, 0, 192)); - linearGrad.setColorAt(0, QColor(66, 115, 225)); - p.fillRect(QRect(0, 0, 256, 128), linearGrad); - p.drawPixmap(QPoint(0, 0), px); + QLinearGradient linearGrad(QPoint(128, 0), QPoint(128, 128)); + linearGrad.setColorAt(1, QColor(0, 0, 192)); + linearGrad.setColorAt(0, QColor(66, 115, 225)); + p.fillRect(QRect(0, 0, 256, 128), linearGrad); + p.drawPixmap(QPoint(0, 0), px); addInfoToPreview(pxres); - chooseMap->setCurrentIndex(0); - pMap = 0; + chooseMap->setCurrentIndex(0); + pMap = 0; } void HWMapContainer::setHHLimit(int newHHLimit) @@ -177,31 +177,31 @@ void HWMapContainer::mapChanged(int index) { - if(!index) { - changeImage(); - gbThemes->show(); + if(!index) { + changeImage(); + gbThemes->show(); lblFilter->show(); CB_TemplateFilter->show(); - emit mapChanged("+rnd+"); - emit themeChanged(chooseMap->itemData(0).toList()[0].toString()); - } else - { - loadMap(index); - gbThemes->hide(); + emit mapChanged("+rnd+"); + emit themeChanged(chooseMap->itemData(0).toList()[0].toString()); + } else + { + loadMap(index); + gbThemes->hide(); lblFilter->hide(); CB_TemplateFilter->hide(); - emit mapChanged(chooseMap->currentText()); - } + emit mapChanged(chooseMap->currentText()); + } } void HWMapContainer::loadMap(int index) { - QPixmap mapImage; - if(!mapImage.load(datadir->absolutePath() + "/Maps/" + chooseMap->currentText() + "/preview.png")) { - changeImage(); - chooseMap->setCurrentIndex(0); - return; - } + QPixmap mapImage; + if(!mapImage.load(datadir->absolutePath() + "/Maps/" + chooseMap->currentText() + "/preview.png")) { + changeImage(); + chooseMap->setCurrentIndex(0); + return; + } hhLimit = chooseMap->itemData(index).toList()[1].toInt(); addInfoToPreview(mapImage); @@ -210,73 +210,73 @@ // Should this add text to identify map size? void HWMapContainer::addInfoToPreview(QPixmap image) { - QPixmap finalImage = QPixmap(image.size()); - finalImage.fill(QColor(0, 0, 0, 0)); + QPixmap finalImage = QPixmap(image.size()); + finalImage.fill(QColor(0, 0, 0, 0)); - QPainter p(&finalImage); - p.drawPixmap(image.rect(), image); - //p.setPen(QColor(0xf4,0x9e,0xe9)); - p.setPen(QColor(0xff,0xcc,0x00)); - p.setBrush(QColor(0, 0, 0)); - p.drawRect(image.rect().width() - hhSmall.rect().width() - 28, 3, 40, 20); - p.setFont(QFont("MS Shell Dlg", 10)); - p.drawText(image.rect().width() - hhSmall.rect().width() - 14 - (hhLimit > 9 ? 10 : 0), 18, QString::number(hhLimit)); - p.drawPixmap(image.rect().width() - hhSmall.rect().width() - 5, 5, hhSmall.rect().width(), hhSmall.rect().height(), hhSmall); + QPainter p(&finalImage); + p.drawPixmap(image.rect(), image); + //p.setPen(QColor(0xf4,0x9e,0xe9)); + p.setPen(QColor(0xff,0xcc,0x00)); + p.setBrush(QColor(0, 0, 0)); + p.drawRect(image.rect().width() - hhSmall.rect().width() - 28, 3, 40, 20); + p.setFont(QFont("MS Shell Dlg", 10)); + p.drawText(image.rect().width() - hhSmall.rect().width() - 14 - (hhLimit > 9 ? 10 : 0), 18, QString::number(hhLimit)); + p.drawPixmap(image.rect().width() - hhSmall.rect().width() - 5, 5, hhSmall.rect().width(), hhSmall.rect().height(), hhSmall); - imageButt->setIcon(finalImage); - imageButt->setIconSize(image.size()); + imageButt->setIcon(finalImage); + imageButt->setIconSize(image.size()); } void HWMapContainer::changeImage() { - if (pMap) - { - disconnect(pMap, 0, this, SLOT(setImage(const QImage))); - disconnect(pMap, 0, this, SLOT(setHHLimit(int))); - pMap = 0; - } + if (pMap) + { + disconnect(pMap, 0, this, SLOT(setImage(const QImage))); + disconnect(pMap, 0, this, SLOT(setHHLimit(int))); + pMap = 0; + } - pMap = new HWMap(); - connect(pMap, SIGNAL(ImageReceived(const QImage)), this, SLOT(setImage(const QImage))); - connect(pMap, SIGNAL(HHLimitReceived(int)), this, SLOT(setHHLimit(int))); - pMap->getImage(m_seed.toStdString(), getTemplateFilter()); + pMap = new HWMap(); + connect(pMap, SIGNAL(ImageReceived(const QImage)), this, SLOT(setImage(const QImage))); + connect(pMap, SIGNAL(HHLimitReceived(int)), this, SLOT(setHHLimit(int))); + pMap->getImage(m_seed.toStdString(), getTemplateFilter()); } void HWMapContainer::themeSelected(int currentRow) { - QString theme = Themes->at(currentRow); - QList mapInfo; - mapInfo.push_back(theme); - mapInfo.push_back(18); - chooseMap->setItemData(0, mapInfo); - gbThemes->setIcon(QIcon(QString("%1/Themes/%2/icon.png").arg(datadir->absolutePath()).arg(theme))); - emit themeChanged(theme); + QString theme = Themes->at(currentRow); + QList mapInfo; + mapInfo.push_back(theme); + mapInfo.push_back(18); + chooseMap->setItemData(0, mapInfo); + gbThemes->setIcon(QIcon(QString("%1/Themes/%2/icon.png").arg(datadir->absolutePath()).arg(theme))); + emit themeChanged(theme); } QString HWMapContainer::getCurrentSeed() const { - return m_seed; + return m_seed; } QString HWMapContainer::getCurrentMap() const { - if(!chooseMap->currentIndex()) return QString(); - return chooseMap->currentText(); + if(!chooseMap->currentIndex()) return QString(); + return chooseMap->currentText(); } QString HWMapContainer::getCurrentTheme() const { - return chooseMap->itemData(chooseMap->currentIndex()).toList()[0].toString(); + return chooseMap->itemData(chooseMap->currentIndex()).toList()[0].toString(); } int HWMapContainer::getCurrentHHLimit() const { - return hhLimit; + return hhLimit; } quint32 HWMapContainer::getTemplateFilter() const { - return CB_TemplateFilter->itemData(CB_TemplateFilter->currentIndex()).toInt(); + return CB_TemplateFilter->itemData(CB_TemplateFilter->currentIndex()).toInt(); } void HWMapContainer::resizeEvent ( QResizeEvent * event ) @@ -286,60 +286,60 @@ void HWMapContainer::setSeed(const QString & seed) { - m_seed = seed; - changeImage(); + m_seed = seed; + changeImage(); } void HWMapContainer::setMap(const QString & map) { - if(map == "+rnd+") - { - changeImage(); - return; - } + if(map == "+rnd+") + { + changeImage(); + return; + } - int id = chooseMap->findText(map); - if(id > 0) { - if (pMap) - { - disconnect(pMap, 0, this, SLOT(setImage(const QImage))); - disconnect(pMap, 0, this, SLOT(setHHLimit(int))); - pMap = 0; - } - chooseMap->setCurrentIndex(id); - loadMap(id); - } + int id = chooseMap->findText(map); + if(id > 0) { + if (pMap) + { + disconnect(pMap, 0, this, SLOT(setImage(const QImage))); + disconnect(pMap, 0, this, SLOT(setHHLimit(int))); + pMap = 0; + } + chooseMap->setCurrentIndex(id); + loadMap(id); + } } void HWMapContainer::setTheme(const QString & theme) { - QList items = lwThemes->findItems(theme, Qt::MatchExactly); - if(items.size()) - lwThemes->setCurrentItem(items.at(0)); + QList items = lwThemes->findItems(theme, Qt::MatchExactly); + if(items.size()) + lwThemes->setCurrentItem(items.at(0)); } void HWMapContainer::setRandomSeed() { - m_seed = QUuid::createUuid().toString(); - emit seedChanged(m_seed); - changeImage(); + m_seed = QUuid::createUuid().toString(); + emit seedChanged(m_seed); + changeImage(); } void HWMapContainer::setRandomTheme() { - if(!Themes->size()) return; - quint32 themeNum = rand() % Themes->size(); - lwThemes->setCurrentRow(themeNum); + if(!Themes->size()) return; + quint32 themeNum = rand() % Themes->size(); + lwThemes->setCurrentRow(themeNum); } void HWMapContainer::setTemplateFilter(int filter) { - CB_TemplateFilter->setCurrentIndex(filter); + CB_TemplateFilter->setCurrentIndex(filter); } void HWMapContainer::templateFilterChanged(int filter) { - emit newTemplateFilter(filter); - changeImage(); + emit newTemplateFilter(filter); + changeImage(); } diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/misc.h --- a/QTfrontend/misc.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/misc.h Sat Mar 06 10:59:20 2010 +0000 @@ -24,21 +24,21 @@ class FreqSpinBox : public QSpinBox { - Q_OBJECT + Q_OBJECT public: - FreqSpinBox(QWidget* parent) : QSpinBox(parent) - { + FreqSpinBox(QWidget* parent) : QSpinBox(parent) + { - } + } - QString textFromValue(int value) const - { - if (!value) - return tr("Never"); - else - return tr("Every %1 turn", "", value).arg(value); - } + QString textFromValue(int value) const + { + if (!value) + return tr("Never"); + else + return tr("Every %1 turn", "", value).arg(value); + } }; diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/namegen.cpp --- a/QTfrontend/namegen.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/namegen.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -27,10 +27,10 @@ HWNamegen::HWNamegen() : - TypesAvliable(false) + TypesAvliable(false) { - TypesLoad(); + TypesLoad(); } HWNamegen::~HWNamegen() @@ -41,46 +41,46 @@ void HWNamegen::TeamRandomName(HWTeam*& team, const int &i) { - RandomNameByHat(team,i); + RandomNameByHat(team,i); } void HWNamegen::TeamRandomNames(HWTeam*& team, const bool changeteamname) { - if ((TypesHatnames.size() > 0) && TypesAvliable){ + if ((TypesHatnames.size() > 0) && TypesAvliable){ - int kind = (rand()%(TypesHatnames.size())); + int kind = (rand()%(TypesHatnames.size())); - if (changeteamname){ - if (TypesTeamnames[kind].size() > 0){ - team->TeamName = TypesTeamnames[kind][rand()%(TypesTeamnames[kind].size())]; - } - team->Grave = "Simple"; // Todo: make it semi-random - team->Fort = "Island"; // Todo: make it semi-random - team->Voicepack = "Default"; - } + if (changeteamname){ + if (TypesTeamnames[kind].size() > 0){ + team->TeamName = TypesTeamnames[kind][rand()%(TypesTeamnames[kind].size())]; + } + team->Grave = "Simple"; // Todo: make it semi-random + team->Fort = "Island"; // Todo: make it semi-random + team->Voicepack = "Default"; + } - for(int i = 0; i < 8; i++) - { - if ((TypesHatnames[kind].size()) > 0){ - team->HHHat[i] = TypesHatnames[kind][rand()%(TypesHatnames[kind].size())]; - } - RandomNameByHat(team,i); - } + for(int i = 0; i < 8; i++) + { + if ((TypesHatnames[kind].size()) > 0){ + team->HHHat[i] = TypesHatnames[kind][rand()%(TypesHatnames[kind].size())]; + } + RandomNameByHat(team,i); + } - } + } } void HWNamegen::RandomNameByHat(HWTeam*& team, const int &i) { - QStringList Dictionaries; - HatCfgLoad(team->HHHat[i],Dictionaries); + QStringList Dictionaries; + HatCfgLoad(team->HHHat[i],Dictionaries); - QStringList Dictionary; - DictLoad(Dictionaries[rand()%(Dictionaries.size())],Dictionary); + QStringList Dictionary; + DictLoad(Dictionaries[rand()%(Dictionaries.size())],Dictionary); - team->HHName[i] = Dictionary[rand()%(Dictionary.size())]; + team->HHName[i] = Dictionary[rand()%(Dictionary.size())]; } void HWNamegen::DictLoad(const QString filename, QStringList &list) diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/namegen.h --- a/QTfrontend/namegen.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/namegen.h Sat Mar 06 10:59:20 2010 +0000 @@ -27,21 +27,21 @@ class HWNamegen { public: - HWNamegen(); - ~HWNamegen(); + HWNamegen(); + ~HWNamegen(); - void TeamRandomName(HWTeam*& team, const int &i); - void TeamRandomNames(HWTeam*& team, const bool changeteamname); - void RandomNameByHat(HWTeam*& team, const int &i); + void TeamRandomName(HWTeam*& team, const int &i); + void TeamRandomNames(HWTeam*& team, const bool changeteamname); + void RandomNameByHat(HWTeam*& team, const int &i); private: - QList TypesTeamnames; - QList TypesHatnames; - bool TypesAvliable; - void TypesLoad(); - void DictLoad(const QString filename, QStringList &list); - void HatCfgLoad(const QString hatname, QStringList &list); + QList TypesTeamnames; + QList TypesHatnames; + bool TypesAvliable; + void TypesLoad(); + void DictLoad(const QString filename, QStringList &list); + void HatCfgLoad(const QString hatname, QStringList &list); }; diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/netregister.h --- a/QTfrontend/netregister.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/netregister.h Sat Mar 06 10:59:20 2010 +0000 @@ -23,13 +23,13 @@ class HWNetRegisterServer : public QObject { - Q_OBJECT + Q_OBJECT public: - HWNetRegisterServer(QObject *parent, const QString & descr, quint16 port); + HWNetRegisterServer(QObject *parent, const QString & descr, quint16 port); public slots: - virtual void unregister(); + virtual void unregister(); }; #endif // _NET_REGISTER_INCLUDED diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/netserver.cpp --- a/QTfrontend/netserver.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/netserver.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -24,25 +24,25 @@ HWNetServer::~HWNetServer() { - StopServer(); + StopServer(); } bool HWNetServer::StartServer(quint16 port) { - ds_port = port; + ds_port = port; - QStringList params; - params << QString("--port=%1").arg(port); - params << "--dedicated=False"; + QStringList params; + params << QString("--port=%1").arg(port); + params << "--dedicated=False"; - process.start(bindir->absolutePath() + "/hedgewars-server", params); + process.start(bindir->absolutePath() + "/hedgewars-server", params); - return process.waitForStarted(5000); + return process.waitForStarted(5000); } void HWNetServer::StopServer() { - process.close(); + process.close(); } diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/netserver.h --- a/QTfrontend/netserver.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/netserver.h Sat Mar 06 10:59:20 2010 +0000 @@ -24,18 +24,18 @@ class HWNetServer : public QObject { - Q_OBJECT + Q_OBJECT public: - ~HWNetServer(); - bool StartServer(quint16 port); - void StopServer(); - QString getRunningHostName() const; - quint16 getRunningPort() const; + ~HWNetServer(); + bool StartServer(quint16 port); + void StopServer(); + QString getRunningHostName() const; + quint16 getRunningPort() const; private: - quint16 ds_port; - QProcess process; + quint16 ds_port; + QProcess process; }; #endif // _NETSERVER_INCLUDED diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/netserverslist.cpp --- a/QTfrontend/netserverslist.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/netserverslist.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -35,34 +35,34 @@ QVariant HWNetServersModel::headerData(int section, Qt::Orientation orientation, int role) const { - if (role != Qt::DisplayRole) - return QVariant(); + if (role != Qt::DisplayRole) + return QVariant(); - if (orientation == Qt::Horizontal) - { - switch (section) - { - case 0: return tr("Title"); - case 1: return tr("IP"); - case 2: return tr("Port"); - default: return QVariant(); - } - } else - return QString("%1").arg(section + 1); + if (orientation == Qt::Horizontal) + { + switch (section) + { + case 0: return tr("Title"); + case 1: return tr("IP"); + case 2: return tr("Port"); + default: return QVariant(); + } + } else + return QString("%1").arg(section + 1); } int HWNetServersModel::rowCount(const QModelIndex &parent) const { - if (parent.isValid()) - return 0; - else - return games.size(); + if (parent.isValid()) + return 0; + else + return games.size(); } int HWNetServersModel::columnCount(const QModelIndex & parent) const { - if (parent.isValid()) - return 0; - else - return 3; + if (parent.isValid()) + return 0; + else + return 3; } diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/netserverslist.h --- a/QTfrontend/netserverslist.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/netserverslist.h Sat Mar 06 10:59:20 2010 +0000 @@ -24,20 +24,20 @@ class HWNetServersModel : public QAbstractTableModel { - Q_OBJECT + Q_OBJECT public: - HWNetServersModel(QObject *parent = 0); + HWNetServersModel(QObject *parent = 0); - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - int rowCount(const QModelIndex & parent) const; - int columnCount(const QModelIndex & parent) const; + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + int rowCount(const QModelIndex & parent) const; + int columnCount(const QModelIndex & parent) const; public slots: - virtual void updateList(); + virtual void updateList(); protected: - QList games; + QList games; }; #endif // _NET_SERVERSLIST_INCLUDED diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/netudpwidget.cpp --- a/QTfrontend/netudpwidget.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/netudpwidget.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -24,48 +24,48 @@ HWNetUdpModel::HWNetUdpModel(QObject* parent) : HWNetServersModel(parent) { - pUdpSocket = new QUdpSocket(this); + pUdpSocket = new QUdpSocket(this); - pUdpSocket->bind(); - connect(pUdpSocket, SIGNAL(readyRead()), this, SLOT(onClientRead())); + pUdpSocket->bind(); + connect(pUdpSocket, SIGNAL(readyRead()), this, SLOT(onClientRead())); } void HWNetUdpModel::updateList() { - games.clear(); + games.clear(); - reset(); + reset(); - pUdpSocket->writeDatagram("hedgewars client", QHostAddress::Broadcast, 46631); + pUdpSocket->writeDatagram("hedgewars client", QHostAddress::Broadcast, 46631); } void HWNetUdpModel::onClientRead() { - while (pUdpSocket->hasPendingDatagrams()) { - QByteArray datagram; - datagram.resize(pUdpSocket->pendingDatagramSize()); - QHostAddress clientAddr; - quint16 clientPort; + while (pUdpSocket->hasPendingDatagrams()) { + QByteArray datagram; + datagram.resize(pUdpSocket->pendingDatagramSize()); + QHostAddress clientAddr; + quint16 clientPort; - pUdpSocket->readDatagram(datagram.data(), datagram.size(), &clientAddr, &clientPort); + pUdpSocket->readDatagram(datagram.data(), datagram.size(), &clientAddr, &clientPort); - if(QString("%1").arg(datagram.data())==QString("hedgewars server")) { - QStringList sl; - sl << "-" << clientAddr.toString() << "46631"; - games.append(sl); - } - } + if(QString("%1").arg(datagram.data())==QString("hedgewars server")) { + QStringList sl; + sl << "-" << clientAddr.toString() << "46631"; + games.append(sl); + } + } - reset(); + reset(); } QVariant HWNetUdpModel::data(const QModelIndex &index, int role) const { - if (!index.isValid() || index.row() < 0 - || index.row() >= games.size() - || role != Qt::DisplayRole) - return QVariant(); + if (!index.isValid() || index.row() < 0 + || index.row() >= games.size() + || role != Qt::DisplayRole) + return QVariant(); - return games[index.row()][index.column()]; + return games[index.row()][index.column()]; } diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/netudpwidget.h --- a/QTfrontend/netudpwidget.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/netudpwidget.h Sat Mar 06 10:59:20 2010 +0000 @@ -29,18 +29,18 @@ Q_OBJECT public: - HWNetUdpModel(QObject *parent = 0); + HWNetUdpModel(QObject *parent = 0); - QVariant data(const QModelIndex &index, int role) const; + QVariant data(const QModelIndex &index, int role) const; public slots: - void updateList(); + void updateList(); private slots: - void onClientRead(); + void onClientRead(); private: - QUdpSocket* pUdpSocket; + QUdpSocket* pUdpSocket; }; #endif // _NET_UDPWIDGET_INCLUDED diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/newnetclient.cpp --- a/QTfrontend/newnetclient.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/newnetclient.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -42,96 +42,96 @@ netClientState(0) { // socket stuff - connect(&NetSocket, SIGNAL(readyRead()), this, SLOT(ClientRead())); - connect(&NetSocket, SIGNAL(connected()), this, SLOT(OnConnect())); - connect(&NetSocket, SIGNAL(disconnected()), this, SLOT(OnDisconnect())); - connect(&NetSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, - SLOT(displayError(QAbstractSocket::SocketError))); + connect(&NetSocket, SIGNAL(readyRead()), this, SLOT(ClientRead())); + connect(&NetSocket, SIGNAL(connected()), this, SLOT(OnConnect())); + connect(&NetSocket, SIGNAL(disconnected()), this, SLOT(OnDisconnect())); + connect(&NetSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, + SLOT(displayError(QAbstractSocket::SocketError))); // config stuff - connect(this, SIGNAL(paramChanged(const QString &, const QStringList &)), pGameCFGWidget, SLOT(setParam(const QString &, const QStringList &))); - connect(pGameCFGWidget, SIGNAL(paramChanged(const QString &, const QStringList &)), this, SLOT(onParamChanged(const QString &, const QStringList &))); - connect(this, SIGNAL(configAsked()), pGameCFGWidget, SLOT(fullNetConfig())); + connect(this, SIGNAL(paramChanged(const QString &, const QStringList &)), pGameCFGWidget, SLOT(setParam(const QString &, const QStringList &))); + connect(pGameCFGWidget, SIGNAL(paramChanged(const QString &, const QStringList &)), this, SLOT(onParamChanged(const QString &, const QStringList &))); + connect(this, SIGNAL(configAsked()), pGameCFGWidget, SLOT(fullNetConfig())); } HWNewNet::~HWNewNet() { - if (m_game_connected) - { - RawSendNet(QString("QUIT%1%2").arg(delimeter).arg("User quit")); - emit Disconnected(); - } - NetSocket.flush(); + if (m_game_connected) + { + RawSendNet(QString("QUIT%1%2").arg(delimeter).arg("User quit")); + emit Disconnected(); + } + NetSocket.flush(); } void HWNewNet::Connect(const QString & hostName, quint16 port, const QString & nick) { - mynick = nick.isEmpty() ? QLineEdit::tr("unnamed") : nick; - myhost = hostName + QString(":%1").arg(port); - NetSocket.connectToHost(hostName, port); + mynick = nick.isEmpty() ? QLineEdit::tr("unnamed") : nick; + myhost = hostName + QString(":%1").arg(port); + NetSocket.connectToHost(hostName, port); } void HWNewNet::Disconnect() { - if (m_game_connected) - RawSendNet(QString("QUIT%1%2").arg(delimeter).arg("User quit")); - m_game_connected = false; + if (m_game_connected) + RawSendNet(QString("QUIT%1%2").arg(delimeter).arg("User quit")); + m_game_connected = false; - NetSocket.disconnectFromHost(); + NetSocket.disconnectFromHost(); } void HWNewNet::CreateRoom(const QString & room) { - if(netClientState != 2) - { - qWarning("Illegal try to create room!"); - return; - } + if(netClientState != 2) + { + qWarning("Illegal try to create room!"); + return; + } - myroom = room; + myroom = room; - RawSendNet(QString("CREATE_ROOM%1%2").arg(delimeter).arg(room)); - isChief = true; + RawSendNet(QString("CREATE_ROOM%1%2").arg(delimeter).arg(room)); + isChief = true; } void HWNewNet::JoinRoom(const QString & room) { - if(netClientState != 2) - { - qWarning("Illegal try to join room!"); - return; - } + if(netClientState != 2) + { + qWarning("Illegal try to join room!"); + return; + } - myroom = room; + myroom = room; - RawSendNet(QString("JOIN_ROOM%1%2").arg(delimeter).arg(room)); - isChief = false; + RawSendNet(QString("JOIN_ROOM%1%2").arg(delimeter).arg(room)); + isChief = false; } void HWNewNet::AddTeam(const HWTeam & team) { - QString cmd = QString("ADD_TEAM") + delimeter + - team.TeamName + delimeter + - team.teamColor.name() + delimeter + - team.Grave + delimeter + - team.Fort + delimeter + - team.Voicepack + delimeter + - team.Flag + delimeter + - QString::number(team.difficulty); + QString cmd = QString("ADD_TEAM") + delimeter + + team.TeamName + delimeter + + team.teamColor.name() + delimeter + + team.Grave + delimeter + + team.Fort + delimeter + + team.Voicepack + delimeter + + team.Flag + delimeter + + QString::number(team.difficulty); - for(int i = 0; i < 8; ++i) - { - cmd.append(delimeter); - cmd.append(team.HHName[i]); - cmd.append(delimeter); - cmd.append(team.HHHat[i]); - } - RawSendNet(cmd); + for(int i = 0; i < 8; ++i) + { + cmd.append(delimeter); + cmd.append(team.HHName[i]); + cmd.append(delimeter); + cmd.append(team.HHHat[i]); + } + RawSendNet(cmd); } void HWNewNet::RemoveTeam(const HWTeam & team) { - RawSendNet(QString("REMOVE_TEAM") + delimeter + team.TeamName); + RawSendNet(QString("REMOVE_TEAM") + delimeter + team.TeamName); } void HWNewNet::ToggleReady() @@ -153,23 +153,23 @@ void HWNewNet::RawSendNet(const QByteArray & buf) { -// qDebug() << "Client: " << QString(buf).split("\n"); - NetSocket.write(buf); - NetSocket.write("\n\n", 2); +// qDebug() << "Client: " << QString(buf).split("\n"); + NetSocket.write(buf); + NetSocket.write("\n\n", 2); } void HWNewNet::ClientRead() { - while (NetSocket.canReadLine()) { - QString s = QString::fromUtf8(NetSocket.readLine()); - if (s.endsWith('\n')) s.chop(1); + while (NetSocket.canReadLine()) { + QString s = QString::fromUtf8(NetSocket.readLine()); + if (s.endsWith('\n')) s.chop(1); - if (s.size() == 0) { - ParseCmd(cmdbuf); - cmdbuf.clear(); - } else - cmdbuf << s; - } + if (s.size() == 0) { + ParseCmd(cmdbuf); + cmdbuf.clear(); + } else + cmdbuf << s; + } } void HWNewNet::OnConnect() @@ -178,284 +178,284 @@ void HWNewNet::OnDisconnect() { - if(m_game_connected) emit Disconnected(); - m_game_connected = false; + if(m_game_connected) emit Disconnected(); + m_game_connected = false; } void HWNewNet::displayError(QAbstractSocket::SocketError socketError) { - emit Disconnected(); + emit Disconnected(); - switch (socketError) { - case QAbstractSocket::RemoteHostClosedError: - break; - case QAbstractSocket::HostNotFoundError: - emit showMessage(tr("The host was not found. Please check the host name and port settings.")); - break; - case QAbstractSocket::ConnectionRefusedError: - emit showMessage(tr("Connection refused")); - break; - default: - emit showMessage(NetSocket.errorString()); - } + switch (socketError) { + case QAbstractSocket::RemoteHostClosedError: + break; + case QAbstractSocket::HostNotFoundError: + emit showMessage(tr("The host was not found. Please check the host name and port settings.")); + break; + case QAbstractSocket::ConnectionRefusedError: + emit showMessage(tr("Connection refused")); + break; + default: + emit showMessage(NetSocket.errorString()); + } } void HWNewNet::ParseCmd(const QStringList & lst) { -// qDebug() << "Server: " << lst; +// qDebug() << "Server: " << lst; - if(!lst.size()) - { - qWarning("Net client: Bad message"); - return; - } + if(!lst.size()) + { + qWarning("Net client: Bad message"); + return; + } - if (lst[0] == "NICK") - { - mynick = lst[1]; - return ; - } + if (lst[0] == "NICK") + { + mynick = lst[1]; + return ; + } - if (lst[0] == "PROTO") - return ; + if (lst[0] == "PROTO") + return ; - if (lst[0] == "ERROR") { - if (lst.size() == 2) - emit showMessage("Error: " + lst[1]); - else - emit showMessage("Unknown error"); - return; - } + if (lst[0] == "ERROR") { + if (lst.size() == 2) + emit showMessage("Error: " + lst[1]); + else + emit showMessage("Unknown error"); + return; + } - if (lst[0] == "WARNING") { - if (lst.size() == 2) - emit showMessage("Warning: " + lst[1]); - else - emit showMessage("Unknown warning"); - return; - } + if (lst[0] == "WARNING") { + if (lst.size() == 2) + emit showMessage("Warning: " + lst[1]); + else + emit showMessage("Unknown warning"); + return; + } - if (lst[0] == "CONNECTED") { - RawSendNet(QString("NICK%1%2").arg(delimeter).arg(mynick)); - RawSendNet(QString("PROTO%1%2").arg(delimeter).arg(*cProtoVer)); - netClientState = 1; - m_game_connected = true; - emit adminAccess(false); - return; - } + if (lst[0] == "CONNECTED") { + RawSendNet(QString("NICK%1%2").arg(delimeter).arg(mynick)); + RawSendNet(QString("PROTO%1%2").arg(delimeter).arg(*cProtoVer)); + netClientState = 1; + m_game_connected = true; + emit adminAccess(false); + return; + } - if (lst[0] == "PING") { - if (lst.size() > 1) - RawSendNet(QString("PONG%1%2").arg(delimeter).arg(lst[1])); - else - RawSendNet(QString("PONG")); - return; - } + if (lst[0] == "PING") { + if (lst.size() > 1) + RawSendNet(QString("PONG%1%2").arg(delimeter).arg(lst[1])); + else + RawSendNet(QString("PONG")); + return; + } - if (lst[0] == "ROOMS") { - QStringList tmp = lst; - tmp.removeFirst(); - emit roomsList(tmp); - return; - } + if (lst[0] == "ROOMS") { + QStringList tmp = lst; + tmp.removeFirst(); + emit roomsList(tmp); + return; + } - if (lst[0] == "SERVER_MESSAGE") { - if(lst.size() < 2) - { - qWarning("Net: Empty SERVERMESSAGE message"); - return; - } - emit serverMessage(lst[1]); - return; - } + if (lst[0] == "SERVER_MESSAGE") { + if(lst.size() < 2) + { + qWarning("Net: Empty SERVERMESSAGE message"); + return; + } + emit serverMessage(lst[1]); + return; + } - if (lst[0] == "CHAT") { - if(lst.size() < 3) - { - qWarning("Net: Empty CHAT message"); - return; - } - if (netClientState == 2) - emit chatStringLobby(HWProto::formatChatMsg(lst[1], lst[2])); - else - emit chatStringFromNet(HWProto::formatChatMsg(lst[1], lst[2])); - return; - } + if (lst[0] == "CHAT") { + if(lst.size() < 3) + { + qWarning("Net: Empty CHAT message"); + return; + } + if (netClientState == 2) + emit chatStringLobby(HWProto::formatChatMsg(lst[1], lst[2])); + else + emit chatStringFromNet(HWProto::formatChatMsg(lst[1], lst[2])); + return; + } - if (lst[0] == "INFO") { - if(lst.size() < 5) - { - qWarning("Net: Malformed INFO message"); - return; - } - QStringList tmp = lst; - tmp.removeFirst(); - if (netClientState == 2) - emit chatStringLobby(tmp.join("\n").prepend('\x01')); - else - emit chatStringFromNet(tmp.join("\n").prepend('\x01')); - return; - } + if (lst[0] == "INFO") { + if(lst.size() < 5) + { + qWarning("Net: Malformed INFO message"); + return; + } + QStringList tmp = lst; + tmp.removeFirst(); + if (netClientState == 2) + emit chatStringLobby(tmp.join("\n").prepend('\x01')); + else + emit chatStringFromNet(tmp.join("\n").prepend('\x01')); + return; + } - if (lst[0] == "READY") { - if(lst.size() < 2) - { - qWarning("Net: Malformed READY message"); - return; - } - for(int i = 1; i < lst.size(); ++i) - { - if (lst[i] == mynick) - emit setMyReadyStatus(true); - emit setReadyStatus(lst[i], true); - } - return; - } + if (lst[0] == "READY") { + if(lst.size() < 2) + { + qWarning("Net: Malformed READY message"); + return; + } + for(int i = 1; i < lst.size(); ++i) + { + if (lst[i] == mynick) + emit setMyReadyStatus(true); + emit setReadyStatus(lst[i], true); + } + return; + } - if (lst[0] == "NOT_READY") { - if(lst.size() < 2) - { - qWarning("Net: Malformed NOT_READY message"); - return; - } - for(int i = 1; i < lst.size(); ++i) - { - if (lst[i] == mynick) - emit setMyReadyStatus(false); - emit setReadyStatus(lst[i], false); - } - return; - } + if (lst[0] == "NOT_READY") { + if(lst.size() < 2) + { + qWarning("Net: Malformed NOT_READY message"); + return; + } + for(int i = 1; i < lst.size(); ++i) + { + if (lst[i] == mynick) + emit setMyReadyStatus(false); + emit setReadyStatus(lst[i], false); + } + return; + } - if (lst[0] == "ADD_TEAM") { - if(lst.size() != 24) - { - qWarning("Net: Bad ADDTEAM message"); - return; - } - QStringList tmp = lst; - tmp.removeFirst(); - emit AddNetTeam(tmp); - return; - } + if (lst[0] == "ADD_TEAM") { + if(lst.size() != 24) + { + qWarning("Net: Bad ADDTEAM message"); + return; + } + QStringList tmp = lst; + tmp.removeFirst(); + emit AddNetTeam(tmp); + return; + } - if (lst[0] == "REMOVE_TEAM") { - if(lst.size() != 2) - { - qWarning("Net: Bad REMOVETEAM message"); - return; - } - m_pTeamSelWidget->removeNetTeam(HWTeam(lst[1])); - return; - } + if (lst[0] == "REMOVE_TEAM") { + if(lst.size() != 2) + { + qWarning("Net: Bad REMOVETEAM message"); + return; + } + m_pTeamSelWidget->removeNetTeam(HWTeam(lst[1])); + return; + } - if(lst[0] == "ROOMABANDONED") { - netClientState = 2; - emit showMessage(HWNewNet::tr("Room destroyed")); - emit LeftRoom(); - return; - } + if(lst[0] == "ROOMABANDONED") { + netClientState = 2; + emit showMessage(HWNewNet::tr("Room destroyed")); + emit LeftRoom(); + return; + } - if(lst[0] == "KICKED") { - netClientState = 2; - emit showMessage(HWNewNet::tr("You got kicked")); - emit LeftRoom(); - return; - } + if(lst[0] == "KICKED") { + netClientState = 2; + emit showMessage(HWNewNet::tr("You got kicked")); + emit LeftRoom(); + return; + } - if(lst[0] == "JOINED") { - if(lst.size() < 2) - { - qWarning("Net: Bad JOINED message"); - return; - } + if(lst[0] == "JOINED") { + if(lst.size() < 2) + { + qWarning("Net: Bad JOINED message"); + return; + } - for(int i = 1; i < lst.size(); ++i) - { - if (lst[i] == mynick) - { - netClientState = 3; - emit EnteredGame(); - emit roomMaster(isChief); - if (isChief) - emit configAsked(); - } - emit nickAdded(lst[i], isChief && (lst[i] != mynick)); + for(int i = 1; i < lst.size(); ++i) + { + if (lst[i] == mynick) + { + netClientState = 3; + emit EnteredGame(); + emit roomMaster(isChief); + if (isChief) + emit configAsked(); + } + emit nickAdded(lst[i], isChief && (lst[i] != mynick)); emit chatStringFromNet(tr("%1 *** %2 has joined the room").arg('\x03').arg(lst[i])); - } - return; - } + } + return; + } - if(lst[0] == "LOBBY:JOINED") { - if(lst.size() < 2) - { - qWarning("Net: Bad JOINED message"); - return; - } + if(lst[0] == "LOBBY:JOINED") { + if(lst.size() < 2) + { + qWarning("Net: Bad JOINED message"); + return; + } - for(int i = 1; i < lst.size(); ++i) - { - if (lst[i] == mynick) - { - netClientState = 2; - RawSendNet(QString("LIST")); - emit Connected(); - } + for(int i = 1; i < lst.size(); ++i) + { + if (lst[i] == mynick) + { + netClientState = 2; + RawSendNet(QString("LIST")); + emit Connected(); + } - emit nickAddedLobby(lst[i], false); - emit chatStringLobby(tr("%1 *** %2 has joined").arg('\x03').arg(lst[i])); - } - return; - } + emit nickAddedLobby(lst[i], false); + emit chatStringLobby(tr("%1 *** %2 has joined").arg('\x03').arg(lst[i])); + } + return; + } - if(lst[0] == "LEFT") { - if(lst.size() < 2) - { - qWarning("Net: Bad LEFT message"); - return; - } - emit nickRemoved(lst[1]); - if (lst.size() < 3) - emit chatStringFromNet(tr("%1 *** %2 has left").arg('\x03').arg(lst[1])); - else - emit chatStringFromNet(tr("%1 *** %2 has left (%3)").arg('\x03').arg(lst[1], lst[2])); - return; - } + if(lst[0] == "LEFT") { + if(lst.size() < 2) + { + qWarning("Net: Bad LEFT message"); + return; + } + emit nickRemoved(lst[1]); + if (lst.size() < 3) + emit chatStringFromNet(tr("%1 *** %2 has left").arg('\x03').arg(lst[1])); + else + emit chatStringFromNet(tr("%1 *** %2 has left (%3)").arg('\x03').arg(lst[1], lst[2])); + return; + } - if(lst[0] == "ROOM") { - if(lst.size() < 2) - { - qWarning("Net: Bad ROOM message"); - return; - } - RawSendNet(QString("LIST")); - return; - } + if(lst[0] == "ROOM") { + if(lst.size() < 2) + { + qWarning("Net: Bad ROOM message"); + return; + } + RawSendNet(QString("LIST")); + return; + } - if(lst[0] == "LOBBY:LEFT") { - if(lst.size() < 2) - { - qWarning("Net: Bad LOBBY:LEFT message"); - return; - } - emit nickRemovedLobby(lst[1]); - if (lst.size() < 3) - emit chatStringLobby(tr("%1 *** %2 has left").arg('\x03').arg(lst[1])); - else - emit chatStringLobby(tr("%1 *** %2 has left (%3)").arg('\x03').arg(lst[1], lst[2])); - return; - } + if(lst[0] == "LOBBY:LEFT") { + if(lst.size() < 2) + { + qWarning("Net: Bad LOBBY:LEFT message"); + return; + } + emit nickRemovedLobby(lst[1]); + if (lst.size() < 3) + emit chatStringLobby(tr("%1 *** %2 has left").arg('\x03').arg(lst[1])); + else + emit chatStringLobby(tr("%1 *** %2 has left (%3)").arg('\x03').arg(lst[1], lst[2])); + return; + } - if (lst[0] == "RUN_GAME") { - netClientState = 5; - emit AskForRunGame(); - return; - } + if (lst[0] == "RUN_GAME") { + netClientState = 5; + emit AskForRunGame(); + return; + } - if (lst[0] == "ASKPASSWORD") { + if (lst[0] == "ASKPASSWORD") { int passLength = config->value("net/passwordlength", 0).toInt(); QString hash = config->value("net/passwordhash", "").toString(); - QString password = QInputDialog::getText(0, tr("Password"), tr("Your nickname %1 is\nregistered on Hedgewars.org\nPlease provide your password\nor pick another nickname:").arg(mynick), QLineEdit::Password, passLength==0?NULL:QString(passLength,'\0')); + QString password = QInputDialog::getText(0, tr("Password"), tr("Your nickname %1 is\nregistered on Hedgewars.org\nPlease provide your password\nor pick another nickname:").arg(mynick), QLineEdit::Password, passLength==0?NULL:QString(passLength,'\0')); if (!passLength || password!=QString(passLength, '\0')) { hash = QCryptographicHash::hash(password.toLatin1(), QCryptographicHash::Md5).toHex(); @@ -463,255 +463,255 @@ config->setValue("net/passwordlength", password.size()); } - RawSendNet(QString("PASSWORD%1%2").arg(delimeter).arg(hash)); - return; - } + RawSendNet(QString("PASSWORD%1%2").arg(delimeter).arg(hash)); + return; + } - if (lst[0] == "TEAM_ACCEPTED") { - if (lst.size() != 2) - { - qWarning("Net: Bad TEAM_ACCEPTED message"); - return; - } - m_pTeamSelWidget->changeTeamStatus(lst[1]); - return; - } + if (lst[0] == "TEAM_ACCEPTED") { + if (lst.size() != 2) + { + qWarning("Net: Bad TEAM_ACCEPTED message"); + return; + } + m_pTeamSelWidget->changeTeamStatus(lst[1]); + return; + } - if (lst[0] == "CFG") { - if(lst.size() < 3) - { - qWarning("Net: Bad CFG message"); - return; - } - QStringList tmp = lst; - tmp.removeFirst(); - tmp.removeFirst(); - if (lst[1] == "SCHEME") - emit netSchemeConfig(tmp); - else - emit paramChanged(lst[1], tmp); - return; - } + if (lst[0] == "CFG") { + if(lst.size() < 3) + { + qWarning("Net: Bad CFG message"); + return; + } + QStringList tmp = lst; + tmp.removeFirst(); + tmp.removeFirst(); + if (lst[1] == "SCHEME") + emit netSchemeConfig(tmp); + else + emit paramChanged(lst[1], tmp); + return; + } - if (lst[0] == "HH_NUM") { - if (lst.size() != 3) - { - qWarning("Net: Bad TEAM_ACCEPTED message"); - return; - } - HWTeam tmptm(lst[1]); - tmptm.numHedgehogs = lst[2].toUInt(); - emit hhnumChanged(tmptm); - return; - } + if (lst[0] == "HH_NUM") { + if (lst.size() != 3) + { + qWarning("Net: Bad TEAM_ACCEPTED message"); + return; + } + HWTeam tmptm(lst[1]); + tmptm.numHedgehogs = lst[2].toUInt(); + emit hhnumChanged(tmptm); + return; + } - if (lst[0] == "TEAM_COLOR") { - if (lst.size() != 3) - { - qWarning("Net: Bad TEAM_COLOR message"); - return; - } - HWTeam tmptm(lst[1]); - tmptm.teamColor = QColor(lst[2]); - emit teamColorChanged(tmptm); - return; - } + if (lst[0] == "TEAM_COLOR") { + if (lst.size() != 3) + { + qWarning("Net: Bad TEAM_COLOR message"); + return; + } + HWTeam tmptm(lst[1]); + tmptm.teamColor = QColor(lst[2]); + emit teamColorChanged(tmptm); + return; + } - if (lst[0] == "EM") { - if(lst.size() < 2) - { - qWarning("Net: Bad EM message"); - return; - } - for(int i = 1; i < lst.size(); ++i) - { - QByteArray em = QByteArray::fromBase64(lst[i].toAscii()); - emit FromNet(em); - } - return; - } + if (lst[0] == "EM") { + if(lst.size() < 2) + { + qWarning("Net: Bad EM message"); + return; + } + for(int i = 1; i < lst.size(); ++i) + { + QByteArray em = QByteArray::fromBase64(lst[i].toAscii()); + emit FromNet(em); + } + return; + } - if (lst[0] == "BYE") { - if (lst.size() < 2) - { - qWarning("Net: Bad BYE message"); - return; - } - emit showMessage(HWNewNet::tr("Quit reason: ") + lst[1]); - return; - } + if (lst[0] == "BYE") { + if (lst.size() < 2) + { + qWarning("Net: Bad BYE message"); + return; + } + emit showMessage(HWNewNet::tr("Quit reason: ") + lst[1]); + return; + } - if (lst[0] == "ADMIN_ACCESS") { - emit adminAccess(true); - return; - } + if (lst[0] == "ADMIN_ACCESS") { + emit adminAccess(true); + return; + } - if (lst[0] == "ROOM_CONTROL_ACCESS") { - if (lst.size() < 2) - { - qWarning("Net: Bad BYE message"); - return; - } - bool b = lst[1] != "0"; - m_pGameCFGWidget->setEnabled(b); - m_pTeamSelWidget->setInteractivity(b); - isChief = b; - emit roomMaster(isChief); + if (lst[0] == "ROOM_CONTROL_ACCESS") { + if (lst.size() < 2) + { + qWarning("Net: Bad BYE message"); + return; + } + bool b = lst[1] != "0"; + m_pGameCFGWidget->setEnabled(b); + m_pTeamSelWidget->setInteractivity(b); + isChief = b; + emit roomMaster(isChief); - return; - } + return; + } - qWarning() << "Net: Unknown message:" << lst; + qWarning() << "Net: Unknown message:" << lst; } void HWNewNet::onHedgehogsNumChanged(const HWTeam& team) { - if (isChief) - RawSendNet(QString("HH_NUM%1%2%1%3") - .arg(delimeter) - .arg(team.TeamName) - .arg(team.numHedgehogs)); + if (isChief) + RawSendNet(QString("HH_NUM%1%2%1%3") + .arg(delimeter) + .arg(team.TeamName) + .arg(team.numHedgehogs)); } void HWNewNet::onTeamColorChanged(const HWTeam& team) { - if (isChief) - RawSendNet(QString("TEAM_COLOR%1%2%1%3") - .arg(delimeter) - .arg(team.TeamName) - .arg(team.teamColor.name())); + if (isChief) + RawSendNet(QString("TEAM_COLOR%1%2%1%3") + .arg(delimeter) + .arg(team.TeamName) + .arg(team.teamColor.name())); } void HWNewNet::onParamChanged(const QString & param, const QStringList & value) { - if (isChief) - RawSendNet( - QString("CFG%1%2%1%3") - .arg(delimeter) - .arg(param) - .arg(value.join(QString(delimeter))) - ); + if (isChief) + RawSendNet( + QString("CFG%1%2%1%3") + .arg(delimeter) + .arg(param) + .arg(value.join(QString(delimeter))) + ); } void HWNewNet::chatLineToNet(const QString& str) { - if(str != "") { - RawSendNet(QString("CHAT") + delimeter + str); - emit(chatStringFromMe(HWProto::formatChatMsg(mynick, str))); - } + if(str != "") { + RawSendNet(QString("CHAT") + delimeter + str); + emit(chatStringFromMe(HWProto::formatChatMsg(mynick, str))); + } } void HWNewNet::chatLineToLobby(const QString& str) { - if(str != "") { - RawSendNet(QString("CHAT") + delimeter + str); - emit(chatStringFromMeLobby(HWProto::formatChatMsg(mynick, str))); - } + if(str != "") { + RawSendNet(QString("CHAT") + delimeter + str); + emit(chatStringFromMeLobby(HWProto::formatChatMsg(mynick, str))); + } } void HWNewNet::SendTeamMessage(const QString& str) { - RawSendNet(QString("TEAMCHAT") + delimeter + str); + RawSendNet(QString("TEAMCHAT") + delimeter + str); } void HWNewNet::askRoomsList() { - if(netClientState != 2) - { - qWarning("Illegal try to get rooms list!"); - return; - } - RawSendNet(QString("LIST")); + if(netClientState != 2) + { + qWarning("Illegal try to get rooms list!"); + return; + } + RawSendNet(QString("LIST")); } int HWNewNet::getClientState() { - return netClientState; + return netClientState; } QString HWNewNet::getNick() { - return mynick; + return mynick; } QString HWNewNet::getRoom() { - return myroom; + return myroom; } QString HWNewNet::getHost() { - return myhost; + return myhost; } bool HWNewNet::isRoomChief() { - return isChief; + return isChief; } void HWNewNet::gameFinished() { - if (netClientState == 5) netClientState = 3; - RawSendNet(QString("ROUNDFINISHED")); + if (netClientState == 5) netClientState = 3; + RawSendNet(QString("ROUNDFINISHED")); } void HWNewNet::banPlayer(const QString & nick) { - RawSendNet(QString("BAN%1%2").arg(delimeter).arg(nick)); + RawSendNet(QString("BAN%1%2").arg(delimeter).arg(nick)); } void HWNewNet::kickPlayer(const QString & nick) { - RawSendNet(QString("KICK%1%2").arg(delimeter).arg(nick)); + RawSendNet(QString("KICK%1%2").arg(delimeter).arg(nick)); } void HWNewNet::infoPlayer(const QString & nick) { - RawSendNet(QString("INFO%1%2").arg(delimeter).arg(nick)); + RawSendNet(QString("INFO%1%2").arg(delimeter).arg(nick)); } void HWNewNet::followPlayer(const QString & nick) { - if (!isInRoom()) { - RawSendNet(QString("FOLLOW%1%2").arg(delimeter).arg(nick)); - isChief = false; - } + if (!isInRoom()) { + RawSendNet(QString("FOLLOW%1%2").arg(delimeter).arg(nick)); + isChief = false; + } } void HWNewNet::startGame() { - RawSendNet(QString("START_GAME")); + RawSendNet(QString("START_GAME")); } void HWNewNet::toggleRestrictJoins() { - RawSendNet(QString("TOGGLE_RESTRICT_JOINS")); + RawSendNet(QString("TOGGLE_RESTRICT_JOINS")); } void HWNewNet::toggleRestrictTeamAdds() { - RawSendNet(QString("TOGGLE_RESTRICT_TEAMS")); + RawSendNet(QString("TOGGLE_RESTRICT_TEAMS")); } void HWNewNet::clearAccountsCache() { - RawSendNet(QString("CLEAR_ACCOUNTS_CACHE")); + RawSendNet(QString("CLEAR_ACCOUNTS_CACHE")); } void HWNewNet::partRoom() { - netClientState = 2; - RawSendNet(QString("PART")); + netClientState = 2; + RawSendNet(QString("PART")); } bool HWNewNet::isInRoom() { - return netClientState > 2; + return netClientState > 2; } void HWNewNet::newServerMessage(const QString & msg) { - RawSendNet(QString("SET_SERVER_MESSAGE%1%2").arg(delimeter).arg(msg)); + RawSendNet(QString("SET_SERVER_MESSAGE%1%2").arg(delimeter).arg(msg)); } diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/pages.cpp --- a/QTfrontend/pages.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/pages.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -66,313 +66,313 @@ AbstractPage(parent) { if(frontendEffects) setAttribute(Qt::WA_NoSystemBackground, true); - QGridLayout * pageLayout = new QGridLayout(this); - //pageLayout->setColumnStretch(0, 1); - //pageLayout->setColumnStretch(1, 2); - //pageLayout->setColumnStretch(2, 1); + QGridLayout * pageLayout = new QGridLayout(this); + //pageLayout->setColumnStretch(0, 1); + //pageLayout->setColumnStretch(1, 2); + //pageLayout->setColumnStretch(2, 1); - //QPushButton* btnLogo = addButton(":/res/HedgewarsTitle.png", pageLayout, 0, 0, 1, 4, true); - //pageLayout->setAlignment(btnLogo, Qt::AlignHCenter); - pageLayout->setRowStretch(0, 1); - pageLayout->setRowStretch(1, 1); - pageLayout->setRowStretch(2, 0); - pageLayout->setRowStretch(3, 1); - pageLayout->setRowStretch(4, 1); + //QPushButton* btnLogo = addButton(":/res/HedgewarsTitle.png", pageLayout, 0, 0, 1, 4, true); + //pageLayout->setAlignment(btnLogo, Qt::AlignHCenter); + pageLayout->setRowStretch(0, 1); + pageLayout->setRowStretch(1, 1); + pageLayout->setRowStretch(2, 0); + pageLayout->setRowStretch(3, 1); + pageLayout->setRowStretch(4, 1); - BtnSinglePlayer = addButton(":/res/LocalPlay.png", pageLayout, 2, 0, 1, 2, true); - BtnSinglePlayer->setToolTip(tr("Local Game (Play a game on a single computer)")); - pageLayout->setAlignment(BtnSinglePlayer, Qt::AlignHCenter); + BtnSinglePlayer = addButton(":/res/LocalPlay.png", pageLayout, 2, 0, 1, 2, true); + BtnSinglePlayer->setToolTip(tr("Local Game (Play a game on a single computer)")); + pageLayout->setAlignment(BtnSinglePlayer, Qt::AlignHCenter); - BtnNet = addButton(":/res/NetworkPlay.png", pageLayout, 2, 2, 1, 2, true); - BtnNet->setToolTip(tr("Network Game (Play a game across a network)")); - pageLayout->setAlignment(BtnNet, Qt::AlignHCenter); + BtnNet = addButton(":/res/NetworkPlay.png", pageLayout, 2, 2, 1, 2, true); + BtnNet->setToolTip(tr("Network Game (Play a game across a network)")); + pageLayout->setAlignment(BtnNet, Qt::AlignHCenter); - BtnSetup = addButton(":/res/Settings.png", pageLayout, 4, 3, true); + BtnSetup = addButton(":/res/Settings.png", pageLayout, 4, 3, true); - //BtnInfo = addButton(":/res/About.png", pageLayout, 3, 1, 1, 2, true); - BtnInfo = addButton(":/res/HedgewarsTitle.png", pageLayout, 0, 0, 1, 4, true); - BtnInfo->setStyleSheet("border: transparent;background: transparent;"); - pageLayout->setAlignment(BtnInfo, Qt::AlignHCenter); - //pageLayout->setAlignment(BtnInfo, Qt::AlignHCenter); + //BtnInfo = addButton(":/res/About.png", pageLayout, 3, 1, 1, 2, true); + BtnInfo = addButton(":/res/HedgewarsTitle.png", pageLayout, 0, 0, 1, 4, true); + BtnInfo->setStyleSheet("border: transparent;background: transparent;"); + pageLayout->setAlignment(BtnInfo, Qt::AlignHCenter); + //pageLayout->setAlignment(BtnInfo, Qt::AlignHCenter); - BtnExit = addButton(":/res/Exit.png", pageLayout, 4, 0, 1, 1, true); + BtnExit = addButton(":/res/Exit.png", pageLayout, 4, 0, 1, 1, true); } PageEditTeam::PageEditTeam(QWidget* parent, SDLInteraction * sdli) : AbstractPage(parent) { mySdli = sdli; - QGridLayout * pageLayout = new QGridLayout(this); - QTabWidget * tbw = new QTabWidget(this); - QWidget * page1 = new QWidget(this); - QWidget * page2 = new QWidget(this); - tbw->addTab(page1, tr("General")); - tbw->addTab(page2, tr("Advanced")); - pageLayout->addWidget(tbw, 0, 0, 1, 3); - BtnTeamDiscard = addButton(":/res/Exit.png", pageLayout, 1, 0, true); - BtnTeamSave = addButton(":/res/Save.png", pageLayout, 1, 2, true);; - BtnTeamSave->setStyleSheet("QPushButton{margin: 12px 0px 12px 0px;}"); + QGridLayout * pageLayout = new QGridLayout(this); + QTabWidget * tbw = new QTabWidget(this); + QWidget * page1 = new QWidget(this); + QWidget * page2 = new QWidget(this); + tbw->addTab(page1, tr("General")); + tbw->addTab(page2, tr("Advanced")); + pageLayout->addWidget(tbw, 0, 0, 1, 3); + BtnTeamDiscard = addButton(":/res/Exit.png", pageLayout, 1, 0, true); + BtnTeamSave = addButton(":/res/Save.png", pageLayout, 1, 2, true);; + BtnTeamSave->setStyleSheet("QPushButton{margin: 12px 0px 12px 0px;}"); - QHBoxLayout * page1Layout = new QHBoxLayout(page1); - page1Layout->setAlignment(Qt::AlignTop); - QGridLayout * page2Layout = new QGridLayout(page2); + QHBoxLayout * page1Layout = new QHBoxLayout(page1); + page1Layout->setAlignment(Qt::AlignTop); + QGridLayout * page2Layout = new QGridLayout(page2); // ====== Page 1 ====== - QVBoxLayout * vbox1 = new QVBoxLayout(); - QVBoxLayout * vbox2 = new QVBoxLayout(); - page1Layout->addLayout(vbox1); - page1Layout->addLayout(vbox2); + QVBoxLayout * vbox1 = new QVBoxLayout(); + QVBoxLayout * vbox2 = new QVBoxLayout(); + page1Layout->addLayout(vbox1); + page1Layout->addLayout(vbox2); - GBoxHedgehogs = new QGroupBox(this); - GBoxHedgehogs->setTitle(QGroupBox::tr("Team Members")); - GBoxHedgehogs->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - QGridLayout * GBHLayout = new QGridLayout(GBoxHedgehogs); + GBoxHedgehogs = new QGroupBox(this); + GBoxHedgehogs->setTitle(QGroupBox::tr("Team Members")); + GBoxHedgehogs->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + QGridLayout * GBHLayout = new QGridLayout(GBoxHedgehogs); - signalMapper = new QSignalMapper(this); + signalMapper = new QSignalMapper(this); - HatsModel * hatsModel = new HatsModel(GBoxHedgehogs); - for(int i = 0; i < 8; i++) - { - HHHats[i] = new QComboBox(GBoxHedgehogs); - HHHats[i]->setModel(hatsModel); - HHHats[i]->setIconSize(QSize(32, 37)); - //HHHats[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents); - //HHHats[i]->setModelColumn(1); - //HHHats[i]->setMinimumWidth(132); - GBHLayout->addWidget(HHHats[i], i, 0); + HatsModel * hatsModel = new HatsModel(GBoxHedgehogs); + for(int i = 0; i < 8; i++) + { + HHHats[i] = new QComboBox(GBoxHedgehogs); + HHHats[i]->setModel(hatsModel); + HHHats[i]->setIconSize(QSize(32, 37)); + //HHHats[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents); + //HHHats[i]->setModelColumn(1); + //HHHats[i]->setMinimumWidth(132); + GBHLayout->addWidget(HHHats[i], i, 0); - HHNameEdit[i] = new QLineEdit(GBoxHedgehogs); - HHNameEdit[i]->setMaxLength(64); - HHNameEdit[i]->setMinimumWidth(120); - GBHLayout->addWidget(HHNameEdit[i], i, 1); + HHNameEdit[i] = new QLineEdit(GBoxHedgehogs); + HHNameEdit[i]->setMaxLength(64); + HHNameEdit[i]->setMinimumWidth(120); + GBHLayout->addWidget(HHNameEdit[i], i, 1); - randButton[i] = addButton(":/res/dice.png", GBHLayout, i, 3, true); + randButton[i] = addButton(":/res/dice.png", GBHLayout, i, 3, true); - connect(randButton[i], SIGNAL(clicked()), signalMapper, SLOT(map())); - signalMapper->setMapping(randButton[i], i); + connect(randButton[i], SIGNAL(clicked()), signalMapper, SLOT(map())); + signalMapper->setMapping(randButton[i], i); - } + } - randTeamButton = addButton(QPushButton::tr("Random Team"), GBHLayout, 9, false); + randTeamButton = addButton(QPushButton::tr("Random Team"), GBHLayout, 9, false); - vbox1->addWidget(GBoxHedgehogs); + vbox1->addWidget(GBoxHedgehogs); - GBoxTeam = new QGroupBox(this); - GBoxTeam->setTitle(QGroupBox::tr("Team Settings")); - GBoxTeam->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - QGridLayout * GBTLayout = new QGridLayout(GBoxTeam); - QLabel * tmpLabel = new QLabel(GBoxTeam); - tmpLabel->setText(QLabel::tr("Name")); - GBTLayout->addWidget(tmpLabel, 0, 0); - tmpLabel = new QLabel(GBoxTeam); - tmpLabel->setText(QLabel::tr("Type")); - GBTLayout->addWidget(tmpLabel, 1, 0); - tmpLabel = new QLabel(GBoxTeam); - tmpLabel->setText(QLabel::tr("Grave")); - GBTLayout->addWidget(tmpLabel, 2, 0); - tmpLabel = new QLabel(GBoxTeam); - tmpLabel->setText(QLabel::tr("Flag")); - GBTLayout->addWidget(tmpLabel, 3, 0); - tmpLabel = new QLabel(GBoxTeam); - tmpLabel->setText(QLabel::tr("Voice")); - GBTLayout->addWidget(tmpLabel, 4, 0); + GBoxTeam = new QGroupBox(this); + GBoxTeam->setTitle(QGroupBox::tr("Team Settings")); + GBoxTeam->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + QGridLayout * GBTLayout = new QGridLayout(GBoxTeam); + QLabel * tmpLabel = new QLabel(GBoxTeam); + tmpLabel->setText(QLabel::tr("Name")); + GBTLayout->addWidget(tmpLabel, 0, 0); + tmpLabel = new QLabel(GBoxTeam); + tmpLabel->setText(QLabel::tr("Type")); + GBTLayout->addWidget(tmpLabel, 1, 0); + tmpLabel = new QLabel(GBoxTeam); + tmpLabel->setText(QLabel::tr("Grave")); + GBTLayout->addWidget(tmpLabel, 2, 0); + tmpLabel = new QLabel(GBoxTeam); + tmpLabel->setText(QLabel::tr("Flag")); + GBTLayout->addWidget(tmpLabel, 3, 0); + tmpLabel = new QLabel(GBoxTeam); + tmpLabel->setText(QLabel::tr("Voice")); + GBTLayout->addWidget(tmpLabel, 4, 0); - TeamNameEdit = new QLineEdit(GBoxTeam); - TeamNameEdit->setMaxLength(64); - GBTLayout->addWidget(TeamNameEdit, 0, 1); - vbox2->addWidget(GBoxTeam); + TeamNameEdit = new QLineEdit(GBoxTeam); + TeamNameEdit->setMaxLength(64); + GBTLayout->addWidget(TeamNameEdit, 0, 1); + vbox2->addWidget(GBoxTeam); - CBTeamLvl = new QComboBox(GBoxTeam); - CBTeamLvl->setIconSize(QSize(48, 48)); - CBTeamLvl->addItem(QIcon(":/res/botlevels/0.png"), QComboBox::tr("Human")); - for(int i = 5; i > 0; i--) - CBTeamLvl->addItem( - QIcon(QString(":/res/botlevels/%1.png").arg(6 - i)), - QString("%1 %2").arg(QComboBox::tr("Level")).arg(i) - ); - GBTLayout->addWidget(CBTeamLvl, 1, 1); + CBTeamLvl = new QComboBox(GBoxTeam); + CBTeamLvl->setIconSize(QSize(48, 48)); + CBTeamLvl->addItem(QIcon(":/res/botlevels/0.png"), QComboBox::tr("Human")); + for(int i = 5; i > 0; i--) + CBTeamLvl->addItem( + QIcon(QString(":/res/botlevels/%1.png").arg(6 - i)), + QString("%1 %2").arg(QComboBox::tr("Level")).arg(i) + ); + GBTLayout->addWidget(CBTeamLvl, 1, 1); - CBGrave = new QComboBox(GBoxTeam); - CBGrave->setMaxCount(65535); - CBGrave->setIconSize(QSize(32, 32)); - GBTLayout->addWidget(CBGrave, 2, 1); + CBGrave = new QComboBox(GBoxTeam); + CBGrave->setMaxCount(65535); + CBGrave->setIconSize(QSize(32, 32)); + GBTLayout->addWidget(CBGrave, 2, 1); - CBFlag = new QComboBox(GBoxTeam); - CBFlag->setMaxCount(65535); - CBFlag->setIconSize(QSize(22, 15)); - GBTLayout->addWidget(CBFlag, 3, 1); + CBFlag = new QComboBox(GBoxTeam); + CBFlag->setMaxCount(65535); + CBFlag->setIconSize(QSize(22, 15)); + GBTLayout->addWidget(CBFlag, 3, 1); - { - QHBoxLayout * hbox = new QHBoxLayout(); - CBVoicepack = new QComboBox(GBoxTeam); - { - QDir tmpdir; - tmpdir.cd(datadir->absolutePath()); - tmpdir.cd("Sounds/voices"); - QStringList list = tmpdir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name); - CBVoicepack->addItems(list); - } - hbox->addWidget(CBVoicepack, 100); - BtnTestSound = addButton(":/res/PlaySound.png", hbox, 1, true); - hbox->setStretchFactor(BtnTestSound, 1); - connect(BtnTestSound, SIGNAL(clicked()), this, SLOT(testSound())); - GBTLayout->addLayout(hbox, 4, 1); - } + { + QHBoxLayout * hbox = new QHBoxLayout(); + CBVoicepack = new QComboBox(GBoxTeam); + { + QDir tmpdir; + tmpdir.cd(datadir->absolutePath()); + tmpdir.cd("Sounds/voices"); + QStringList list = tmpdir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name); + CBVoicepack->addItems(list); + } + hbox->addWidget(CBVoicepack, 100); + BtnTestSound = addButton(":/res/PlaySound.png", hbox, 1, true); + hbox->setStretchFactor(BtnTestSound, 1); + connect(BtnTestSound, SIGNAL(clicked()), this, SLOT(testSound())); + GBTLayout->addLayout(hbox, 4, 1); + } - GBoxFort = new QGroupBox(this); - GBoxFort->setTitle(QGroupBox::tr("Fort")); - QGridLayout * GBFLayout = new QGridLayout(GBoxFort); - CBFort = new QComboBox(GBoxFort); - CBFort->setMaxCount(65535); - GBFLayout->addWidget(CBFort, 0, 0); - FortPreview = new SquareLabel(GBoxFort); - FortPreview->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - FortPreview->setMinimumSize(128, 128); - FortPreview->setPixmap(QPixmap()); + GBoxFort = new QGroupBox(this); + GBoxFort->setTitle(QGroupBox::tr("Fort")); + QGridLayout * GBFLayout = new QGridLayout(GBoxFort); + CBFort = new QComboBox(GBoxFort); + CBFort->setMaxCount(65535); + GBFLayout->addWidget(CBFort, 0, 0); + FortPreview = new SquareLabel(GBoxFort); + FortPreview->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + FortPreview->setMinimumSize(128, 128); + FortPreview->setPixmap(QPixmap()); // perhaps due to handling its own paintevents, SquareLabel doesn't play nice with the stars //FortPreview->setAttribute(Qt::WA_PaintOnScreen, true); - GBFLayout->addWidget(FortPreview, 1, 0); - vbox2->addWidget(GBoxFort); + GBFLayout->addWidget(FortPreview, 1, 0); + vbox2->addWidget(GBoxFort); - QDir tmpdir; - tmpdir.cd(datadir->absolutePath()); - tmpdir.cd("Forts"); - tmpdir.setFilter(QDir::Files); + QDir tmpdir; + tmpdir.cd(datadir->absolutePath()); + tmpdir.cd("Forts"); + tmpdir.setFilter(QDir::Files); - connect(CBFort, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(CBFort_activated(const QString &))); - CBFort->addItems(tmpdir.entryList(QStringList("*L.png")).replaceInStrings(QRegExp("^(.*)L\\.png"), "\\1")); + connect(CBFort, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(CBFort_activated(const QString &))); + CBFort->addItems(tmpdir.entryList(QStringList("*L.png")).replaceInStrings(QRegExp("^(.*)L\\.png"), "\\1")); - tmpdir.cd("../Graphics/Graves"); - QStringList list = tmpdir.entryList(QStringList("*.png")); - for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) - { - QPixmap pix(datadir->absolutePath() + "/Graphics/Graves/" + *it); - QIcon icon(pix.copy(0, 0, 32, 32)); - CBGrave->addItem(icon, (*it).replace(QRegExp("^(.*)\\.png"), "\\1")); - } + tmpdir.cd("../Graphics/Graves"); + QStringList list = tmpdir.entryList(QStringList("*.png")); + for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) + { + QPixmap pix(datadir->absolutePath() + "/Graphics/Graves/" + *it); + QIcon icon(pix.copy(0, 0, 32, 32)); + CBGrave->addItem(icon, (*it).replace(QRegExp("^(.*)\\.png"), "\\1")); + } - tmpdir.cd(datadir->absolutePath()); - tmpdir.cd("Graphics/Flags"); - list = tmpdir.entryList(QStringList("*.png")); - for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) - { - QPixmap pix(datadir->absolutePath() + "/Graphics/Flags/" + *it); - QIcon icon(pix.copy(0, 0, 22, 15)); - if(it->compare("cpu.png")) // skip cpu flag - CBFlag->addItem(icon, (*it).replace(QRegExp("^(.*)\\.png"), "\\1")); - } + tmpdir.cd(datadir->absolutePath()); + tmpdir.cd("Graphics/Flags"); + list = tmpdir.entryList(QStringList("*.png")); + for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) + { + QPixmap pix(datadir->absolutePath() + "/Graphics/Flags/" + *it); + QIcon icon(pix.copy(0, 0, 22, 15)); + if(it->compare("cpu.png")) // skip cpu flag + CBFlag->addItem(icon, (*it).replace(QRegExp("^(.*)\\.png"), "\\1")); + } - vbox1->addStretch(); - vbox2->addStretch(); + vbox1->addStretch(); + vbox2->addStretch(); // ====== Page 2 ====== - GBoxBinds = new QGroupBox(this); - GBoxBinds->setTitle(QGroupBox::tr("Key binds")); - QGridLayout * GBBLayout = new QGridLayout(GBoxBinds); - BindsBox = new QToolBox(GBoxBinds); - BindsBox->setLineWidth(0); - GBBLayout->addWidget(BindsBox); - page2Layout->addWidget(GBoxBinds, 0, 0); + GBoxBinds = new QGroupBox(this); + GBoxBinds->setTitle(QGroupBox::tr("Key binds")); + QGridLayout * GBBLayout = new QGridLayout(GBoxBinds); + BindsBox = new QToolBox(GBoxBinds); + BindsBox->setLineWidth(0); + GBBLayout->addWidget(BindsBox); + page2Layout->addWidget(GBoxBinds, 0, 0); - quint16 i = 0; - quint16 num = 0; - QWidget * curW = NULL; - QGridLayout * pagelayout = NULL; - QLabel* l = NULL; - while (i < BINDS_NUMBER) { - if(cbinds[i].category != NULL) - { - if(curW != NULL) - { - l = new QLabel(curW); - l->setText(""); - pagelayout->addWidget(l, num++, 0, 1, 2); - } - curW = new QWidget(this); - BindsBox->addItem(curW, QApplication::translate("binds (categories)", cbinds[i].category)); - pagelayout = new QGridLayout(curW); - num = 0; - } - if(cbinds[i].description != NULL) - { - l = new QLabel(curW); - l->setText((num > 0 ? QString("\n") : QString("")) + QApplication::translate("binds (descriptions)", cbinds[i].description)); - pagelayout->addWidget(l, num++, 0, 1, 2); - } + quint16 i = 0; + quint16 num = 0; + QWidget * curW = NULL; + QGridLayout * pagelayout = NULL; + QLabel* l = NULL; + while (i < BINDS_NUMBER) { + if(cbinds[i].category != NULL) + { + if(curW != NULL) + { + l = new QLabel(curW); + l->setText(""); + pagelayout->addWidget(l, num++, 0, 1, 2); + } + curW = new QWidget(this); + BindsBox->addItem(curW, QApplication::translate("binds (categories)", cbinds[i].category)); + pagelayout = new QGridLayout(curW); + num = 0; + } + if(cbinds[i].description != NULL) + { + l = new QLabel(curW); + l->setText((num > 0 ? QString("\n") : QString("")) + QApplication::translate("binds (descriptions)", cbinds[i].description)); + pagelayout->addWidget(l, num++, 0, 1, 2); + } - l = new QLabel(curW); - l->setText(QApplication::translate("binds", cbinds[i].name)); - l->setAlignment(Qt::AlignRight); - pagelayout->addWidget(l, num, 0); - CBBind[i] = new QComboBox(curW); - for(int j = 0; sdlkeys[j][1][0] != '\0'; j++) - CBBind[i]->addItem(QApplication::translate("binds (keys)", sdlkeys[j][1]).contains(": ") ? QApplication::translate("binds (keys)", sdlkeys[j][1]) : QApplication::translate("binds (keys)", "Keyboard") + QString(": ") + QApplication::translate("binds (keys)", sdlkeys[j][1]), sdlkeys[j][0]); - pagelayout->addWidget(CBBind[i++], num++, 1); - } + l = new QLabel(curW); + l->setText(QApplication::translate("binds", cbinds[i].name)); + l->setAlignment(Qt::AlignRight); + pagelayout->addWidget(l, num, 0); + CBBind[i] = new QComboBox(curW); + for(int j = 0; sdlkeys[j][1][0] != '\0'; j++) + CBBind[i]->addItem(QApplication::translate("binds (keys)", sdlkeys[j][1]).contains(": ") ? QApplication::translate("binds (keys)", sdlkeys[j][1]) : QApplication::translate("binds (keys)", "Keyboard") + QString(": ") + QApplication::translate("binds (keys)", sdlkeys[j][1]), sdlkeys[j][0]); + pagelayout->addWidget(CBBind[i++], num++, 1); + } } void PageEditTeam::CBFort_activated(const QString & fortname) { - QPixmap pix(datadir->absolutePath() + "/Forts/" + fortname + "L.png"); - FortPreview->setPixmap(pix); + QPixmap pix(datadir->absolutePath() + "/Forts/" + fortname + "L.png"); + FortPreview->setPixmap(pix); } void PageEditTeam::testSound() { - Mix_Chunk *sound; - QDir tmpdir; - mySdli->SDLMusicInit(); - - tmpdir.cd(datadir->absolutePath()); - tmpdir.cd("Sounds/voices"); - tmpdir.cd(CBVoicepack->currentText()); - QStringList list = tmpdir.entryList(QStringList() << "Illgetyou.ogg" << "Incoming.ogg" << "Stupid.ogg" << "Coward.ogg" << "Firstblood.ogg", QDir::Files); - if (list.size()) { - sound = Mix_LoadWAV(QString(tmpdir.absolutePath() + "/" + list[rand() % list.size()]).toLocal8Bit().constData()); - Mix_PlayChannel(-1, sound, 0); - } + Mix_Chunk *sound; + QDir tmpdir; + mySdli->SDLMusicInit(); + + tmpdir.cd(datadir->absolutePath()); + tmpdir.cd("Sounds/voices"); + tmpdir.cd(CBVoicepack->currentText()); + QStringList list = tmpdir.entryList(QStringList() << "Illgetyou.ogg" << "Incoming.ogg" << "Stupid.ogg" << "Coward.ogg" << "Firstblood.ogg", QDir::Files); + if (list.size()) { + sound = Mix_LoadWAV(QString(tmpdir.absolutePath() + "/" + list[rand() % list.size()]).toLocal8Bit().constData()); + Mix_PlayChannel(-1, sound, 0); + } } PageMultiplayer::PageMultiplayer(QWidget* parent) : AbstractPage(parent) { - QGridLayout * pageLayout = new QGridLayout(this); + QGridLayout * pageLayout = new QGridLayout(this); - BtnBack = addButton(":/res/Exit.png", pageLayout, 2, 0, true); + BtnBack = addButton(":/res/Exit.png", pageLayout, 2, 0, true); - gameCFG = new GameCFGWidget(this); - pageLayout->addWidget(gameCFG, 0, 0, 1, 2); + gameCFG = new GameCFGWidget(this); + pageLayout->addWidget(gameCFG, 0, 0, 1, 2); - pageLayout->setRowStretch(1, 1); + pageLayout->setRowStretch(1, 1); - teamsSelect = new TeamSelWidget(this); - pageLayout->addWidget(teamsSelect, 0, 2, 2, 2); + teamsSelect = new TeamSelWidget(this); + pageLayout->addWidget(teamsSelect, 0, 2, 2, 2); - BtnStartMPGame = addButton(tr("Start"), pageLayout, 2, 3); + BtnStartMPGame = addButton(tr("Start"), pageLayout, 2, 3); } PageOptions::PageOptions(QWidget* parent) : AbstractPage(parent) { - QGridLayout * pageLayout = new QGridLayout(this); - pageLayout->setColumnStretch(0, 100); - pageLayout->setColumnStretch(1, 100); - pageLayout->setColumnStretch(2, 100); - pageLayout->setRowStretch(0, 0); - pageLayout->setRowStretch(1, 100); - pageLayout->setRowStretch(2, 0); - pageLayout->setContentsMargins(7, 7, 7, 0); - pageLayout->setSpacing(0); + QGridLayout * pageLayout = new QGridLayout(this); + pageLayout->setColumnStretch(0, 100); + pageLayout->setColumnStretch(1, 100); + pageLayout->setColumnStretch(2, 100); + pageLayout->setRowStretch(0, 0); + pageLayout->setRowStretch(1, 100); + pageLayout->setRowStretch(2, 0); + pageLayout->setContentsMargins(7, 7, 7, 0); + pageLayout->setSpacing(0); - QGroupBox * gbTwoBoxes = new QGroupBox(this); - pageLayout->addWidget(gbTwoBoxes, 0, 0, 1, 3); - QGridLayout * gbTBLayout = new QGridLayout(gbTwoBoxes); - gbTBLayout->setMargin(0); - gbTBLayout->setSpacing(0); - gbTBLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft); + QGroupBox * gbTwoBoxes = new QGroupBox(this); + pageLayout->addWidget(gbTwoBoxes, 0, 0, 1, 3); + QGridLayout * gbTBLayout = new QGridLayout(gbTwoBoxes); + gbTBLayout->setMargin(0); + gbTBLayout->setSpacing(0); + gbTBLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft); { teamsBox = new IconedGroupBox(this); //teamsBox->setContentTopPadding(0); @@ -445,7 +445,7 @@ tmpdir.cd("Locale"); tmpdir.setFilter(QDir::Files); QStringList locs = tmpdir.entryList(QStringList("hedgewars_*.qm")); - CBLanguage->addItem(QComboBox::tr("(System default)"), QString("")); + CBLanguage->addItem(QComboBox::tr("(System default)"), QString("")); for(int i = 0; i < locs.count(); i++) { QLocale loc(locs[i].replace(QRegExp("hedgewars_(.*)\\.qm"), "\\1")); @@ -567,458 +567,458 @@ hr->setFixedHeight(12); GBAlayout->addWidget(hr); - QLabel *restartNote = new QLabel(this); + QLabel *restartNote = new QLabel(this); restartNote->setText(QString("* ") + QLabel::tr("Restart game to apply")); GBAlayout->addWidget(restartNote); gbTBLayout->addWidget(AGGroupBox, 0, 1, 3, 1); } - BtnSaveOptions = addButton(":/res/Save.png", pageLayout, 2, 2, true); - BtnSaveOptions->setStyleSheet("QPushButton{margin: 12px 0px 12px 0px;}"); + BtnSaveOptions = addButton(":/res/Save.png", pageLayout, 2, 2, true); + BtnSaveOptions->setStyleSheet("QPushButton{margin: 12px 0px 12px 0px;}"); - BtnBack = addButton(":/res/Exit.png", pageLayout, 2, 0, true); + BtnBack = addButton(":/res/Exit.png", pageLayout, 2, 0, true); } PageNet::PageNet(QWidget* parent) : AbstractPage(parent) { - QFont * font14 = new QFont("MS Shell Dlg", 14); - QGridLayout * pageLayout = new QGridLayout(this); - pageLayout->setColumnStretch(0, 1); - pageLayout->setColumnStretch(1, 1); - pageLayout->setColumnStretch(2, 1); + QFont * font14 = new QFont("MS Shell Dlg", 14); + QGridLayout * pageLayout = new QGridLayout(this); + pageLayout->setColumnStretch(0, 1); + pageLayout->setColumnStretch(1, 1); + pageLayout->setColumnStretch(2, 1); - BtnNetSvrStart = new QPushButton(this); - BtnNetSvrStart->setFont(*font14); - BtnNetSvrStart->setText(QPushButton::tr("Start server")); - BtnNetSvrStart->setVisible(haveServer); - pageLayout->addWidget(BtnNetSvrStart, 4, 2); + BtnNetSvrStart = new QPushButton(this); + BtnNetSvrStart->setFont(*font14); + BtnNetSvrStart->setText(QPushButton::tr("Start server")); + BtnNetSvrStart->setVisible(haveServer); + pageLayout->addWidget(BtnNetSvrStart, 4, 2); - BtnBack = addButton(":/res/Exit.png", pageLayout, 4, 0, true); + BtnBack = addButton(":/res/Exit.png", pageLayout, 4, 0, true); - ConnGroupBox = new QGroupBox(this); - ConnGroupBox->setTitle(QGroupBox::tr("Net game")); - pageLayout->addWidget(ConnGroupBox, 2, 0, 1, 3); - GBClayout = new QGridLayout(ConnGroupBox); - GBClayout->setColumnStretch(0, 1); - GBClayout->setColumnStretch(1, 1); - GBClayout->setColumnStretch(2, 1); + ConnGroupBox = new QGroupBox(this); + ConnGroupBox->setTitle(QGroupBox::tr("Net game")); + pageLayout->addWidget(ConnGroupBox, 2, 0, 1, 3); + GBClayout = new QGridLayout(ConnGroupBox); + GBClayout->setColumnStretch(0, 1); + GBClayout->setColumnStretch(1, 1); + GBClayout->setColumnStretch(2, 1); - BtnNetConnect = new QPushButton(ConnGroupBox); - BtnNetConnect->setFont(*font14); - BtnNetConnect->setText(QPushButton::tr("Connect")); - GBClayout->addWidget(BtnNetConnect, 2, 2); + BtnNetConnect = new QPushButton(ConnGroupBox); + BtnNetConnect->setFont(*font14); + BtnNetConnect->setText(QPushButton::tr("Connect")); + GBClayout->addWidget(BtnNetConnect, 2, 2); - tvServersList = new QTableView(ConnGroupBox); - tvServersList->setSelectionBehavior(QAbstractItemView::SelectRows); - GBClayout->addWidget(tvServersList, 1, 0, 1, 3); + tvServersList = new QTableView(ConnGroupBox); + tvServersList->setSelectionBehavior(QAbstractItemView::SelectRows); + GBClayout->addWidget(tvServersList, 1, 0, 1, 3); - BtnUpdateSList = new QPushButton(ConnGroupBox); - BtnUpdateSList->setFont(*font14); - BtnUpdateSList->setText(QPushButton::tr("Update")); - GBClayout->addWidget(BtnUpdateSList, 2, 0); + BtnUpdateSList = new QPushButton(ConnGroupBox); + BtnUpdateSList->setFont(*font14); + BtnUpdateSList->setText(QPushButton::tr("Update")); + GBClayout->addWidget(BtnUpdateSList, 2, 0); - BtnSpecifyServer = new QPushButton(ConnGroupBox); - BtnSpecifyServer->setFont(*font14); - BtnSpecifyServer->setText(QPushButton::tr("Specify")); - GBClayout->addWidget(BtnSpecifyServer, 2, 1); + BtnSpecifyServer = new QPushButton(ConnGroupBox); + BtnSpecifyServer->setFont(*font14); + BtnSpecifyServer->setText(QPushButton::tr("Specify")); + GBClayout->addWidget(BtnSpecifyServer, 2, 1); - connect(BtnNetConnect, SIGNAL(clicked()), this, SLOT(slotConnect())); + connect(BtnNetConnect, SIGNAL(clicked()), this, SLOT(slotConnect())); } void PageNet::updateServersList() { - tvServersList->setModel(new HWNetUdpModel(tvServersList)); + tvServersList->setModel(new HWNetUdpModel(tvServersList)); - tvServersList->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); + tvServersList->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); - static_cast(tvServersList->model())->updateList(); + static_cast(tvServersList->model())->updateList(); - connect(BtnUpdateSList, SIGNAL(clicked()), static_cast(tvServersList->model()), SLOT(updateList())); - connect(tvServersList, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(slotConnect())); + connect(BtnUpdateSList, SIGNAL(clicked()), static_cast(tvServersList->model()), SLOT(updateList())); + connect(tvServersList, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(slotConnect())); } void PageNet::slotConnect() { - HWNetServersModel * model = static_cast(tvServersList->model()); - QModelIndex mi = tvServersList->currentIndex(); - if(!mi.isValid()) - { - QMessageBox::information(this, tr("Error"), tr("Please select server from the list above")); - return; - } - QString host = model->index(mi.row(), 1).data().toString(); - quint16 port = model->index(mi.row(), 2).data().toUInt(); + HWNetServersModel * model = static_cast(tvServersList->model()); + QModelIndex mi = tvServersList->currentIndex(); + if(!mi.isValid()) + { + QMessageBox::information(this, tr("Error"), tr("Please select server from the list above")); + return; + } + QString host = model->index(mi.row(), 1).data().toString(); + quint16 port = model->index(mi.row(), 2).data().toUInt(); - emit connectClicked(host, port); + emit connectClicked(host, port); } PageNetServer::PageNetServer(QWidget* parent) : AbstractPage(parent) { - QFont * font14 = new QFont("MS Shell Dlg", 14); - QGridLayout * pageLayout = new QGridLayout(this); - pageLayout->setColumnStretch(0, 1); - pageLayout->setColumnStretch(1, 1); - pageLayout->setColumnStretch(2, 1); + QFont * font14 = new QFont("MS Shell Dlg", 14); + QGridLayout * pageLayout = new QGridLayout(this); + pageLayout->setColumnStretch(0, 1); + pageLayout->setColumnStretch(1, 1); + pageLayout->setColumnStretch(2, 1); - pageLayout->setRowStretch(0, 1); - pageLayout->setRowStretch(1, 0); + pageLayout->setRowStretch(0, 1); + pageLayout->setRowStretch(1, 0); - BtnBack =addButton(":/res/Exit.png", pageLayout, 1, 0, true); + BtnBack =addButton(":/res/Exit.png", pageLayout, 1, 0, true); - BtnStart = new QPushButton(this); - BtnStart->setFont(*font14); - BtnStart->setText(QPushButton::tr("Start")); - pageLayout->addWidget(BtnStart, 1, 2); + BtnStart = new QPushButton(this); + BtnStart->setFont(*font14); + BtnStart->setText(QPushButton::tr("Start")); + pageLayout->addWidget(BtnStart, 1, 2); - QWidget * wg = new QWidget(this); - pageLayout->addWidget(wg, 0, 0, 1, 3); + QWidget * wg = new QWidget(this); + pageLayout->addWidget(wg, 0, 0, 1, 3); - QGridLayout * wgLayout = new QGridLayout(wg); - wgLayout->setColumnStretch(0, 1); - wgLayout->setColumnStretch(1, 3); - wgLayout->setColumnStretch(2, 1); + QGridLayout * wgLayout = new QGridLayout(wg); + wgLayout->setColumnStretch(0, 1); + wgLayout->setColumnStretch(1, 3); + wgLayout->setColumnStretch(2, 1); - wgLayout->setRowStretch(0, 0); - wgLayout->setRowStretch(1, 1); + wgLayout->setRowStretch(0, 0); + wgLayout->setRowStretch(1, 1); - QGroupBox * gb = new QGroupBox(wg); - wgLayout->addWidget(gb, 0, 1); + QGroupBox * gb = new QGroupBox(wg); + wgLayout->addWidget(gb, 0, 1); - QGridLayout * gbLayout = new QGridLayout(gb); + QGridLayout * gbLayout = new QGridLayout(gb); - labelSD = new QLabel(gb); - labelSD->setText(QLabel::tr("Server name:")); - gbLayout->addWidget(labelSD, 0, 0); + labelSD = new QLabel(gb); + labelSD->setText(QLabel::tr("Server name:")); + gbLayout->addWidget(labelSD, 0, 0); - leServerDescr = new QLineEdit(gb); - gbLayout->addWidget(leServerDescr, 0, 1); + leServerDescr = new QLineEdit(gb); + gbLayout->addWidget(leServerDescr, 0, 1); - labelPort = new QLabel(gb); - labelPort->setText(QLabel::tr("Server port:")); - gbLayout->addWidget(labelPort, 1, 0); + labelPort = new QLabel(gb); + labelPort->setText(QLabel::tr("Server port:")); + gbLayout->addWidget(labelPort, 1, 0); - sbPort = new QSpinBox(gb); - sbPort->setMinimum(0); - sbPort->setMaximum(65535); - gbLayout->addWidget(sbPort, 1, 1); + sbPort = new QSpinBox(gb); + sbPort->setMinimum(0); + sbPort->setMaximum(65535); + gbLayout->addWidget(sbPort, 1, 1); - BtnDefault = new QPushButton(gb); - BtnDefault->setText(QPushButton::tr("default")); - gbLayout->addWidget(BtnDefault, 1, 2); + BtnDefault = new QPushButton(gb); + BtnDefault->setText(QPushButton::tr("default")); + gbLayout->addWidget(BtnDefault, 1, 2); - connect(BtnDefault, SIGNAL(clicked()), this, SLOT(setDefaultPort())); + connect(BtnDefault, SIGNAL(clicked()), this, SLOT(setDefaultPort())); } void PageNetServer::setDefaultPort() { - sbPort->setValue(46631); + sbPort->setValue(46631); } PageNetGame::PageNetGame(QWidget* parent, QSettings * gameSettings, SDLInteraction * sdli) : AbstractPage(parent) { - QGridLayout * pageLayout = new QGridLayout(this); - pageLayout->setSizeConstraint(QLayout::SetMinimumSize); - //pageLayout->setSpacing(1); - pageLayout->setColumnStretch(0, 50); - pageLayout->setColumnStretch(1, 50); + QGridLayout * pageLayout = new QGridLayout(this); + pageLayout->setSizeConstraint(QLayout::SetMinimumSize); + //pageLayout->setSpacing(1); + pageLayout->setColumnStretch(0, 50); + pageLayout->setColumnStretch(1, 50); - // chatwidget - pChatWidget = new HWChatWidget(this, gameSettings, sdli, true); - pChatWidget->setShowReady(true); // show status bulbs by default - pageLayout->addWidget(pChatWidget, 1, 0, 1, 2); - pageLayout->setRowStretch(1, 100); + // chatwidget + pChatWidget = new HWChatWidget(this, gameSettings, sdli, true); + pChatWidget->setShowReady(true); // show status bulbs by default + pageLayout->addWidget(pChatWidget, 1, 0, 1, 2); + pageLayout->setRowStretch(1, 100); - pGameCFG = new GameCFGWidget(this); - pageLayout->addWidget(pGameCFG, 0, 0); + pGameCFG = new GameCFGWidget(this); + pageLayout->addWidget(pGameCFG, 0, 0); - pNetTeamsWidget = new TeamSelWidget(this); - pNetTeamsWidget->setAcceptOuter(true); - pageLayout->addWidget(pNetTeamsWidget, 0, 1); + pNetTeamsWidget = new TeamSelWidget(this); + pNetTeamsWidget->setAcceptOuter(true); + pageLayout->addWidget(pNetTeamsWidget, 0, 1); - QHBoxLayout * bottomLayout = new QHBoxLayout; - pageLayout->addLayout(bottomLayout, 3, 0, 1, 2); + QHBoxLayout * bottomLayout = new QHBoxLayout; + pageLayout->addLayout(bottomLayout, 3, 0, 1, 2); - BtnBack = addButton(":/res/Exit.png", bottomLayout, 0, true); + BtnBack = addButton(":/res/Exit.png", bottomLayout, 0, true); - BtnGo = new QPushButton(this); - BtnGo->setToolTip(QPushButton::tr("Ready")); - BtnGo->setIcon(QIcon(":/res/lightbulb_off.png")); - BtnGo->setIconSize(QSize(25, 34)); - BtnGo->setMinimumWidth(50); - BtnGo->setMinimumHeight(50); - bottomLayout->addWidget(BtnGo, 4); + BtnGo = new QPushButton(this); + BtnGo->setToolTip(QPushButton::tr("Ready")); + BtnGo->setIcon(QIcon(":/res/lightbulb_off.png")); + BtnGo->setIconSize(QSize(25, 34)); + BtnGo->setMinimumWidth(50); + BtnGo->setMinimumHeight(50); + bottomLayout->addWidget(BtnGo, 4); - BtnMaster = addButton(tr("Control"), bottomLayout, 2); - QMenu * menu = new QMenu(BtnMaster); - restrictJoins = new QAction(QAction::tr("Restrict Joins"), menu); - restrictJoins->setCheckable(true); - restrictTeamAdds = new QAction(QAction::tr("Restrict Team Additions"), menu); - restrictTeamAdds->setCheckable(true); - //menu->addAction(startGame); - menu->addAction(restrictJoins); - menu->addAction(restrictTeamAdds); + BtnMaster = addButton(tr("Control"), bottomLayout, 2); + QMenu * menu = new QMenu(BtnMaster); + restrictJoins = new QAction(QAction::tr("Restrict Joins"), menu); + restrictJoins->setCheckable(true); + restrictTeamAdds = new QAction(QAction::tr("Restrict Team Additions"), menu); + restrictTeamAdds->setCheckable(true); + //menu->addAction(startGame); + menu->addAction(restrictJoins); + menu->addAction(restrictTeamAdds); - BtnMaster->setMenu(menu); + BtnMaster->setMenu(menu); - BtnStart = addButton(QAction::tr("Start"), bottomLayout, 3); + BtnStart = addButton(QAction::tr("Start"), bottomLayout, 3); - bottomLayout->insertStretch(1, 100); + bottomLayout->insertStretch(1, 100); } void PageNetGame::setReadyStatus(bool isReady) { - if(isReady) - BtnGo->setIcon(QIcon(":/res/lightbulb_on.png")); - else - BtnGo->setIcon(QIcon(":/res/lightbulb_off.png")); + if(isReady) + BtnGo->setIcon(QIcon(":/res/lightbulb_on.png")); + else + BtnGo->setIcon(QIcon(":/res/lightbulb_off.png")); } void PageNetGame::setMasterMode(bool isMaster) { - BtnMaster->setVisible(isMaster); - BtnStart->setVisible(isMaster); + BtnMaster->setVisible(isMaster); + BtnStart->setVisible(isMaster); } PageInfo::PageInfo(QWidget* parent) : AbstractPage(parent) { - QGridLayout * pageLayout = new QGridLayout(this); - pageLayout->setColumnStretch(0, 1); - pageLayout->setColumnStretch(1, 1); - pageLayout->setColumnStretch(2, 1); + QGridLayout * pageLayout = new QGridLayout(this); + pageLayout->setColumnStretch(0, 1); + pageLayout->setColumnStretch(1, 1); + pageLayout->setColumnStretch(2, 1); - BtnBack = addButton(":/res/Exit.png", pageLayout, 1, 0, true); + BtnBack = addButton(":/res/Exit.png", pageLayout, 1, 0, true); - about = new About(this); - pageLayout->addWidget(about, 0, 0, 1, 3); + about = new About(this); + pageLayout->addWidget(about, 0, 0, 1, 3); } PageSinglePlayer::PageSinglePlayer(QWidget* parent) : AbstractPage(parent) { - QVBoxLayout * vLayout = new QVBoxLayout(this); - QHBoxLayout * topLine = new QHBoxLayout(); - QHBoxLayout * middleLine = new QHBoxLayout(); - QHBoxLayout * bottomLine = new QHBoxLayout(); - vLayout->addStretch(); - vLayout->addLayout(topLine); - vLayout->addSpacing(30); - vLayout->addLayout(middleLine); - vLayout->addStretch(); - vLayout->addLayout(bottomLine); + QVBoxLayout * vLayout = new QVBoxLayout(this); + QHBoxLayout * topLine = new QHBoxLayout(); + QHBoxLayout * middleLine = new QHBoxLayout(); + QHBoxLayout * bottomLine = new QHBoxLayout(); + vLayout->addStretch(); + vLayout->addLayout(topLine); + vLayout->addSpacing(30); + vLayout->addLayout(middleLine); + vLayout->addStretch(); + vLayout->addLayout(bottomLine); - topLine->addStretch(); - BtnSimpleGamePage = addButton(":/res/SimpleGame.png", topLine, 0, true); - BtnSimpleGamePage->setToolTip(tr("Simple Game (a quick game against the computer, settings are chosen for you)")); - topLine->addSpacing(60); - BtnMultiplayer = addButton(":/res/Multiplayer.png", topLine, 1, true); - BtnMultiplayer->setToolTip(tr("Multiplayer (play a hotseat game against your friends, or AI teams)")); - topLine->addStretch(); + topLine->addStretch(); + BtnSimpleGamePage = addButton(":/res/SimpleGame.png", topLine, 0, true); + BtnSimpleGamePage->setToolTip(tr("Simple Game (a quick game against the computer, settings are chosen for you)")); + topLine->addSpacing(60); + BtnMultiplayer = addButton(":/res/Multiplayer.png", topLine, 1, true); + BtnMultiplayer->setToolTip(tr("Multiplayer (play a hotseat game against your friends, or AI teams)")); + topLine->addStretch(); - BtnTrainPage = addButton(":/res/Trainings.png", middleLine, 0, true); - BtnTrainPage->setToolTip(tr("Training Mode (Practice your skills in a range of training missions). IN DEVELOPMENT")); + BtnTrainPage = addButton(":/res/Trainings.png", middleLine, 0, true); + BtnTrainPage->setToolTip(tr("Training Mode (Practice your skills in a range of training missions). IN DEVELOPMENT")); - BtnBack = addButton(":/res/Exit.png", bottomLine, 0, true); - bottomLine->addStretch(); + BtnBack = addButton(":/res/Exit.png", bottomLine, 0, true); + bottomLine->addStretch(); - BtnDemos = addButton(":/res/Record.png", bottomLine, 1, true); - BtnDemos->setToolTip(tr("Demos (Watch recorded demos)")); - BtnLoad = addButton(":/res/Save.png", bottomLine, 2, true); - BtnLoad->setStyleSheet("QPushButton{margin: 12px 0px 12px 0px;}"); - BtnLoad->setToolTip(tr("Load (Load a previously saved game)")); + BtnDemos = addButton(":/res/Record.png", bottomLine, 1, true); + BtnDemos->setToolTip(tr("Demos (Watch recorded demos)")); + BtnLoad = addButton(":/res/Save.png", bottomLine, 2, true); + BtnLoad->setStyleSheet("QPushButton{margin: 12px 0px 12px 0px;}"); + BtnLoad->setToolTip(tr("Load (Load a previously saved game)")); } PageTraining::PageTraining(QWidget* parent) : AbstractPage(parent) { - QGridLayout * pageLayout = new QGridLayout(this); - pageLayout->setColumnStretch(0, 1); - pageLayout->setColumnStretch(1, 2); - pageLayout->setColumnStretch(2, 1); + QGridLayout * pageLayout = new QGridLayout(this); + pageLayout->setColumnStretch(0, 1); + pageLayout->setColumnStretch(1, 2); + pageLayout->setColumnStretch(2, 1); - CBSelect = new QComboBox(this); + CBSelect = new QComboBox(this); - QDir tmpdir; - tmpdir.cd(datadir->absolutePath()); - tmpdir.cd("Missions"); - tmpdir.setFilter(QDir::Files); - CBSelect->addItems(tmpdir.entryList(QStringList("*.hwt")).replaceInStrings(QRegExp("^(.*)\\.hwt"), "\\1")); + QDir tmpdir; + tmpdir.cd(datadir->absolutePath()); + tmpdir.cd("Missions"); + tmpdir.setFilter(QDir::Files); + CBSelect->addItems(tmpdir.entryList(QStringList("*.hwt")).replaceInStrings(QRegExp("^(.*)\\.hwt"), "\\1")); - pageLayout->addWidget(CBSelect, 1, 1); - - BtnStartTrain = new QPushButton(this); - BtnStartTrain->setFont(*font14); - BtnStartTrain->setText(QPushButton::tr("Go!")); - pageLayout->addWidget(BtnStartTrain, 1, 2); + pageLayout->addWidget(CBSelect, 1, 1); + + BtnStartTrain = new QPushButton(this); + BtnStartTrain->setFont(*font14); + BtnStartTrain->setText(QPushButton::tr("Go!")); + pageLayout->addWidget(BtnStartTrain, 1, 2); - BtnBack = addButton(":/res/Exit.png", pageLayout, 1, 0, true); + BtnBack = addButton(":/res/Exit.png", pageLayout, 1, 0, true); } PageSelectWeapon::PageSelectWeapon(QWidget* parent) : AbstractPage(parent) { - QGridLayout * pageLayout = new QGridLayout(this); + QGridLayout * pageLayout = new QGridLayout(this); - pWeapons = new SelWeaponWidget(cAmmoNumber, this); - pageLayout->addWidget(pWeapons, 0, 0, 1, 4); + pWeapons = new SelWeaponWidget(cAmmoNumber, this); + pageLayout->addWidget(pWeapons, 0, 0, 1, 4); - BtnBack = addButton(":/res/Exit.png", pageLayout, 1, 0, true); - BtnDefault = addButton(tr("Default"), pageLayout, 1, 1); - BtnDelete = addButton(tr("Delete"), pageLayout, 1, 2); - BtnSave = addButton(":/res/Save.png", pageLayout, 1, 3, true); - BtnSave->setStyleSheet("QPushButton{margin: 12px 0px 12px 0px;}"); + BtnBack = addButton(":/res/Exit.png", pageLayout, 1, 0, true); + BtnDefault = addButton(tr("Default"), pageLayout, 1, 1); + BtnDelete = addButton(tr("Delete"), pageLayout, 1, 2); + BtnSave = addButton(":/res/Save.png", pageLayout, 1, 3, true); + BtnSave->setStyleSheet("QPushButton{margin: 12px 0px 12px 0px;}"); - connect(BtnDefault, SIGNAL(clicked()), pWeapons, SLOT(setDefault())); - connect(BtnSave, SIGNAL(clicked()), pWeapons, SLOT(save())); + connect(BtnDefault, SIGNAL(clicked()), pWeapons, SLOT(setDefault())); + connect(BtnSave, SIGNAL(clicked()), pWeapons, SLOT(save())); } PageInGame::PageInGame(QWidget* parent) : AbstractPage(parent) { - QLabel * label = new QLabel(this); - label->setText("In game..."); + QLabel * label = new QLabel(this); + label->setText("In game..."); } PageRoomsList::PageRoomsList(QWidget* parent, QSettings * gameSettings, SDLInteraction * sdli) : AbstractPage(parent) { - QGridLayout * pageLayout = new QGridLayout(this); + QGridLayout * pageLayout = new QGridLayout(this); - QHBoxLayout * newRoomLayout = new QHBoxLayout(); - QLabel * roomNameLabel = new QLabel(this); - roomNameLabel->setText(tr("Room Name:")); - roomName = new QLineEdit(this); - roomName->setMaxLength(60); - newRoomLayout->addWidget(roomNameLabel); - newRoomLayout->addWidget(roomName); - pageLayout->addLayout(newRoomLayout, 0, 0); + QHBoxLayout * newRoomLayout = new QHBoxLayout(); + QLabel * roomNameLabel = new QLabel(this); + roomNameLabel->setText(tr("Room Name:")); + roomName = new QLineEdit(this); + roomName->setMaxLength(60); + newRoomLayout->addWidget(roomNameLabel); + newRoomLayout->addWidget(roomName); + pageLayout->addLayout(newRoomLayout, 0, 0); - roomsList = new QTableWidget(this); - roomsList->setSelectionBehavior(QAbstractItemView::SelectRows); - roomsList->verticalHeader()->setVisible(false); - roomsList->horizontalHeader()->setResizeMode(QHeaderView::Interactive); - roomsList->setAlternatingRowColors(true); - pageLayout->addWidget(roomsList, 1, 0, 3, 1); - pageLayout->setRowStretch(2, 100); + roomsList = new QTableWidget(this); + roomsList->setSelectionBehavior(QAbstractItemView::SelectRows); + roomsList->verticalHeader()->setVisible(false); + roomsList->horizontalHeader()->setResizeMode(QHeaderView::Interactive); + roomsList->setAlternatingRowColors(true); + pageLayout->addWidget(roomsList, 1, 0, 3, 1); + pageLayout->setRowStretch(2, 100); - chatWidget = new HWChatWidget(this, gameSettings, sdli, false); - pageLayout->addWidget(chatWidget, 4, 0, 1, 2); - pageLayout->setRowStretch(4, 350); + chatWidget = new HWChatWidget(this, gameSettings, sdli, false); + pageLayout->addWidget(chatWidget, 4, 0, 1, 2); + pageLayout->setRowStretch(4, 350); - BtnCreate = addButton(tr("Create"), pageLayout, 0, 1); - BtnJoin = addButton(tr("Join"), pageLayout, 1, 1); - BtnRefresh = addButton(tr("Refresh"), pageLayout, 3, 1); + BtnCreate = addButton(tr("Create"), pageLayout, 0, 1); + BtnJoin = addButton(tr("Join"), pageLayout, 1, 1); + BtnRefresh = addButton(tr("Refresh"), pageLayout, 3, 1); - BtnBack = addButton(":/res/Exit.png", pageLayout, 5, 0, true); - BtnAdmin = addButton(tr("Admin features"), pageLayout, 5, 1); + BtnBack = addButton(":/res/Exit.png", pageLayout, 5, 0, true); + BtnAdmin = addButton(tr("Admin features"), pageLayout, 5, 1); - connect(BtnCreate, SIGNAL(clicked()), this, SLOT(onCreateClick())); - connect(BtnJoin, SIGNAL(clicked()), this, SLOT(onJoinClick())); - connect(BtnRefresh, SIGNAL(clicked()), this, SLOT(onRefreshClick())); - connect(roomsList, SIGNAL(doubleClicked (const QModelIndex &)), this, SLOT(onJoinClick())); + connect(BtnCreate, SIGNAL(clicked()), this, SLOT(onCreateClick())); + connect(BtnJoin, SIGNAL(clicked()), this, SLOT(onJoinClick())); + connect(BtnRefresh, SIGNAL(clicked()), this, SLOT(onRefreshClick())); + connect(roomsList, SIGNAL(doubleClicked (const QModelIndex &)), this, SLOT(onJoinClick())); } void PageRoomsList::setAdmin(bool flag) { - BtnAdmin->setVisible(flag); + BtnAdmin->setVisible(flag); } void PageRoomsList::setRoomsList(const QStringList & list) { - roomsList->clear(); - roomsList->setColumnCount(7); - roomsList->setHorizontalHeaderLabels( - QStringList() << - QTableWidget::tr("Room Name") << - QTableWidget::tr("C") << - QTableWidget::tr("T") << - QTableWidget::tr("Owner") << - QTableWidget::tr("Map") << - QTableWidget::tr("Rules") << - QTableWidget::tr("Weapons") - ); + roomsList->clear(); + roomsList->setColumnCount(7); + roomsList->setHorizontalHeaderLabels( + QStringList() << + QTableWidget::tr("Room Name") << + QTableWidget::tr("C") << + QTableWidget::tr("T") << + QTableWidget::tr("Owner") << + QTableWidget::tr("Map") << + QTableWidget::tr("Rules") << + QTableWidget::tr("Weapons") + ); - // set minimum sizes -// roomsList->horizontalHeader()->resizeSection(0, 200); -// roomsList->horizontalHeader()->resizeSection(1, 50); -// roomsList->horizontalHeader()->resizeSection(2, 50); -// roomsList->horizontalHeader()->resizeSection(3, 100); -// roomsList->horizontalHeader()->resizeSection(4, 100); -// roomsList->horizontalHeader()->resizeSection(5, 100); -// roomsList->horizontalHeader()->resizeSection(6, 100); + // set minimum sizes +// roomsList->horizontalHeader()->resizeSection(0, 200); +// roomsList->horizontalHeader()->resizeSection(1, 50); +// roomsList->horizontalHeader()->resizeSection(2, 50); +// roomsList->horizontalHeader()->resizeSection(3, 100); +// roomsList->horizontalHeader()->resizeSection(4, 100); +// roomsList->horizontalHeader()->resizeSection(5, 100); +// roomsList->horizontalHeader()->resizeSection(6, 100); - // set resize modes -// roomsList->horizontalHeader()->setResizeMode(QHeaderView::Interactive); + // set resize modes +// roomsList->horizontalHeader()->setResizeMode(QHeaderView::Interactive); - if (list.size() % 8) - return; + if (list.size() % 8) + return; - roomsList->setRowCount(list.size() / 8); - for(int i = 0, r = 0; i < list.size(); i += 8, r++) - { - QTableWidgetItem * item; - item = new QTableWidgetItem(list[i + 1]); // room name - item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); - - // pick appropriate room icon and tooltip (game in progress yes/no; later maybe locked rooms etc.) - if(list[i].compare("True")) - { - item->setIcon(QIcon(":/res/iconTime.png"));// game is in lobby - item->setToolTip(tr("This game is in lobby.\nYou may join and start playing once the game starts.")); - } - else - { - item->setIcon(QIcon(":/res/iconDamage.png"));// game has started - item->setToolTip(tr("This game is in progress.\nYou may join and spectate now but you'll have to wait for the game to end to start playing.")); - } + roomsList->setRowCount(list.size() / 8); + for(int i = 0, r = 0; i < list.size(); i += 8, r++) + { + QTableWidgetItem * item; + item = new QTableWidgetItem(list[i + 1]); // room name + item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); + + // pick appropriate room icon and tooltip (game in progress yes/no; later maybe locked rooms etc.) + if(list[i].compare("True")) + { + item->setIcon(QIcon(":/res/iconTime.png"));// game is in lobby + item->setToolTip(tr("This game is in lobby.\nYou may join and start playing once the game starts.")); + } + else + { + item->setIcon(QIcon(":/res/iconDamage.png"));// game has started + item->setToolTip(tr("This game is in progress.\nYou may join and spectate now but you'll have to wait for the game to end to start playing.")); + } - roomsList->setItem(r, 0, item); + roomsList->setItem(r, 0, item); - item = new QTableWidgetItem(list[i + 2]); // number of clients - item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); - item->setTextAlignment(Qt::AlignCenter); - item->setToolTip(tr("There are %1 clients connected to this room.", "", list[i + 2].toInt()).arg(list[i + 2])); - roomsList->setItem(r, 1, item); + item = new QTableWidgetItem(list[i + 2]); // number of clients + item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); + item->setTextAlignment(Qt::AlignCenter); + item->setToolTip(tr("There are %1 clients connected to this room.", "", list[i + 2].toInt()).arg(list[i + 2])); + roomsList->setItem(r, 1, item); - item = new QTableWidgetItem(list[i + 3]); // number of teams - item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); - item->setTextAlignment(Qt::AlignCenter); - item->setToolTip(tr("There are %1 teams participating in this room.", "", list[i + 3].toInt()).arg(list[i + 3])); - roomsList->setItem(r, 2, item); + item = new QTableWidgetItem(list[i + 3]); // number of teams + item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); + item->setTextAlignment(Qt::AlignCenter); + item->setToolTip(tr("There are %1 teams participating in this room.", "", list[i + 3].toInt()).arg(list[i + 3])); + roomsList->setItem(r, 2, item); - item = new QTableWidgetItem(list[i + 4].left(15)); // name of host - item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); - item->setToolTip(tr("%1 is the host. He may adjust settings and start the game.").arg(list[i + 4])); - roomsList->setItem(r, 3, item); + item = new QTableWidgetItem(list[i + 4].left(15)); // name of host + item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); + item->setToolTip(tr("%1 is the host. He may adjust settings and start the game.").arg(list[i + 4])); + roomsList->setItem(r, 3, item); - if(list[i + 5].compare("+rnd+")) - { - item = new QTableWidgetItem(list[i + 5]); // selected map - - // check to see if we've got this map - // not perfect but a start - if(!mapList->contains(list[i + 5])) - item->setForeground(QBrush(QColor(255, 0, 0))); - } - else - item = new QTableWidgetItem(tr("Random Map")); // selected map (is randomized) - - item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); - item->setToolTip(tr("Games may be played on precreated or randomized maps.")); - roomsList->setItem(r, 4, item); + if(list[i + 5].compare("+rnd+")) + { + item = new QTableWidgetItem(list[i + 5]); // selected map + + // check to see if we've got this map + // not perfect but a start + if(!mapList->contains(list[i + 5])) + item->setForeground(QBrush(QColor(255, 0, 0))); + } + else + item = new QTableWidgetItem(tr("Random Map")); // selected map (is randomized) + + item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); + item->setToolTip(tr("Games may be played on precreated or randomized maps.")); + roomsList->setItem(r, 4, item); - item = new QTableWidgetItem(list[i + 6].left(20)); // selected game scheme - item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); - item->setToolTip(tr("The Game Scheme defines general options and preferences like Round Time, Sudden Death or Vampirism.")); - roomsList->setItem(r, 5, item); + item = new QTableWidgetItem(list[i + 6].left(20)); // selected game scheme + item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); + item->setToolTip(tr("The Game Scheme defines general options and preferences like Round Time, Sudden Death or Vampirism.")); + roomsList->setItem(r, 5, item); - item = new QTableWidgetItem(list[i + 7].left(20)); // selected weapon scheme - item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); - item->setToolTip(tr("The Weapon Scheme defines available weapons and their ammunition count.")); - roomsList->setItem(r, 6, item); + item = new QTableWidgetItem(list[i + 7].left(20)); // selected weapon scheme + item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); + item->setToolTip(tr("The Weapon Scheme defines available weapons and their ammunition count.")); + roomsList->setItem(r, 6, item); - } + } roomsList->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); roomsList->horizontalHeader()->setResizeMode(1, QHeaderView::ResizeToContents); roomsList->horizontalHeader()->setResizeMode(2, QHeaderView::ResizeToContents); @@ -1027,429 +1027,429 @@ roomsList->horizontalHeader()->setResizeMode(5, QHeaderView::ResizeToContents); roomsList->horizontalHeader()->setResizeMode(6, QHeaderView::ResizeToContents); -// roomsList->resizeColumnsToContents(); +// roomsList->resizeColumnsToContents(); } void PageRoomsList::onCreateClick() { - if (roomName->text().size()) - emit askForCreateRoom(roomName->text()); - else - QMessageBox::critical(this, - tr("Error"), - tr("Please enter room name"), - tr("OK")); + if (roomName->text().size()) + emit askForCreateRoom(roomName->text()); + else + QMessageBox::critical(this, + tr("Error"), + tr("Please enter room name"), + tr("OK")); } void PageRoomsList::onJoinClick() { - QTableWidgetItem * curritem = roomsList->item(roomsList->currentRow(), 0); - if (!curritem) - { - QMessageBox::critical(this, - tr("Error"), - tr("Please select room from the list"), - tr("OK")); - return ; - } - emit askForJoinRoom(curritem->data(Qt::DisplayRole).toString()); + QTableWidgetItem * curritem = roomsList->item(roomsList->currentRow(), 0); + if (!curritem) + { + QMessageBox::critical(this, + tr("Error"), + tr("Please select room from the list"), + tr("OK")); + return ; + } + emit askForJoinRoom(curritem->data(Qt::DisplayRole).toString()); } void PageRoomsList::onRefreshClick() { - emit askForRoomList(); + emit askForRoomList(); } PageConnecting::PageConnecting(QWidget* parent) : - AbstractPage(parent) + AbstractPage(parent) { - QGridLayout * pageLayout = new QGridLayout(this); + QGridLayout * pageLayout = new QGridLayout(this); - QLabel * lblConnecting = new QLabel(this); - lblConnecting->setText(tr("Connecting...")); - pageLayout->addWidget(lblConnecting); + QLabel * lblConnecting = new QLabel(this); + lblConnecting->setText(tr("Connecting...")); + pageLayout->addWidget(lblConnecting); } PageScheme::PageScheme(QWidget* parent) : - AbstractPage(parent) + AbstractPage(parent) { - QGridLayout * pageLayout = new QGridLayout(this); - QGroupBox * gb = new QGroupBox(this); + QGridLayout * pageLayout = new QGridLayout(this); + QGroupBox * gb = new QGroupBox(this); - QGridLayout * gl = new QGridLayout(); - gb->setLayout(gl); - QSizePolicy sp; - sp.setVerticalPolicy(QSizePolicy::MinimumExpanding); - sp.setHorizontalPolicy(QSizePolicy::Expanding); + QGridLayout * gl = new QGridLayout(); + gb->setLayout(gl); + QSizePolicy sp; + sp.setVerticalPolicy(QSizePolicy::MinimumExpanding); + sp.setHorizontalPolicy(QSizePolicy::Expanding); - pageLayout->addWidget(gb, 1,0,13,4); + pageLayout->addWidget(gb, 1,0,13,4); - gbGameModes = new QGroupBox(QGroupBox::tr("Game Modifiers"), gb); - gbBasicSettings = new QGroupBox(QGroupBox::tr("Basic Settings"), gb); + gbGameModes = new QGroupBox(QGroupBox::tr("Game Modifiers"), gb); + gbBasicSettings = new QGroupBox(QGroupBox::tr("Basic Settings"), gb); - gbGameModes->setStyleSheet(".QGroupBox {" - "background-color: #130f2c; background-image:url();" - "}"); - gbBasicSettings->setStyleSheet(".QGroupBox {" - "background-color: #130f2c; background-image:url();" - "}"); + gbGameModes->setStyleSheet(".QGroupBox {" + "background-color: #130f2c; background-image:url();" + "}"); + gbBasicSettings->setStyleSheet(".QGroupBox {" + "background-color: #130f2c; background-image:url();" + "}"); - gbGameModes->setSizePolicy(sp); - gbBasicSettings->setSizePolicy(sp); - gl->addWidget(gbGameModes,0,0,1,3,Qt::AlignTop); - gl->addWidget(gbBasicSettings,0,3,1,3,Qt::AlignTop); + gbGameModes->setSizePolicy(sp); + gbBasicSettings->setSizePolicy(sp); + gl->addWidget(gbGameModes,0,0,1,3,Qt::AlignTop); + gl->addWidget(gbBasicSettings,0,3,1,3,Qt::AlignTop); - QGridLayout * glGMLayout = new QGridLayout(gbGameModes); - QGridLayout * glBSLayout = new QGridLayout(gbBasicSettings); - gbGameModes->setLayout(glGMLayout); - gbBasicSettings->setLayout(glBSLayout); - // Left + QGridLayout * glGMLayout = new QGridLayout(gbGameModes); + QGridLayout * glBSLayout = new QGridLayout(gbBasicSettings); + gbGameModes->setLayout(glGMLayout); + gbBasicSettings->setLayout(glBSLayout); + // Left - TBW_mode_Forts = new ToggleButtonWidget(gbGameModes, ":/res/btnForts.png"); - TBW_mode_Forts->setText(ToggleButtonWidget::tr("Fort Mode")); + TBW_mode_Forts = new ToggleButtonWidget(gbGameModes, ":/res/btnForts.png"); + TBW_mode_Forts->setText(ToggleButtonWidget::tr("Fort Mode")); TBW_mode_Forts->setToolTip(tr("Defend your fort and destroy the opponents, two team colours max!")); - glGMLayout->addWidget(TBW_mode_Forts,0,0,1,1); + glGMLayout->addWidget(TBW_mode_Forts,0,0,1,1); - TBW_teamsDivide = new ToggleButtonWidget(gbGameModes, ":/res/btnTeamsDivide.png"); - TBW_teamsDivide->setText(ToggleButtonWidget::tr("Divide Teams")); + TBW_teamsDivide = new ToggleButtonWidget(gbGameModes, ":/res/btnTeamsDivide.png"); + TBW_teamsDivide->setText(ToggleButtonWidget::tr("Divide Teams")); TBW_teamsDivide->setToolTip(tr("Teams will start on opposite sides of the terrain, two team colours max!")); - glGMLayout->addWidget(TBW_teamsDivide,0,1,1,1); + glGMLayout->addWidget(TBW_teamsDivide,0,1,1,1); - TBW_solid = new ToggleButtonWidget(gbGameModes, ":/res/btnSolid.png"); - TBW_solid->setText(ToggleButtonWidget::tr("Solid Land")); + TBW_solid = new ToggleButtonWidget(gbGameModes, ":/res/btnSolid.png"); + TBW_solid->setText(ToggleButtonWidget::tr("Solid Land")); TBW_solid->setToolTip(tr("Land can not be destroyed!")); - glGMLayout->addWidget(TBW_solid,0,2,1,1); + glGMLayout->addWidget(TBW_solid,0,2,1,1); - TBW_border = new ToggleButtonWidget(gbGameModes, ":/res/btnBorder.png"); - TBW_border->setText(ToggleButtonWidget::tr("Add Border")); + TBW_border = new ToggleButtonWidget(gbGameModes, ":/res/btnBorder.png"); + TBW_border->setText(ToggleButtonWidget::tr("Add Border")); TBW_border->setToolTip(tr("Add an indestructable border around the terrain")); - glGMLayout->addWidget(TBW_border,0,3,1,1); + glGMLayout->addWidget(TBW_border,0,3,1,1); - TBW_lowGravity = new ToggleButtonWidget(gbGameModes, ":/res/btnLowGravity.png"); - TBW_lowGravity->setText(ToggleButtonWidget::tr("Low Gravity")); + TBW_lowGravity = new ToggleButtonWidget(gbGameModes, ":/res/btnLowGravity.png"); + TBW_lowGravity->setText(ToggleButtonWidget::tr("Low Gravity")); TBW_lowGravity->setToolTip(tr("Lower gravity")); - glGMLayout->addWidget(TBW_lowGravity,1,0,1,1); + glGMLayout->addWidget(TBW_lowGravity,1,0,1,1); - TBW_laserSight = new ToggleButtonWidget(gbGameModes, ":/res/btnLaserSight.png"); - TBW_laserSight->setText(ToggleButtonWidget::tr("Laser Sight")); + TBW_laserSight = new ToggleButtonWidget(gbGameModes, ":/res/btnLaserSight.png"); + TBW_laserSight->setText(ToggleButtonWidget::tr("Laser Sight")); TBW_laserSight->setToolTip(tr("Assisted aiming with laser sight")); - glGMLayout->addWidget(TBW_laserSight,1,1,1,1); + glGMLayout->addWidget(TBW_laserSight,1,1,1,1); - TBW_invulnerable = new ToggleButtonWidget(gbGameModes, ":/res/btnInvulnerable.png"); - TBW_invulnerable->setText(ToggleButtonWidget::tr("Invulnerable")); + TBW_invulnerable = new ToggleButtonWidget(gbGameModes, ":/res/btnInvulnerable.png"); + TBW_invulnerable->setText(ToggleButtonWidget::tr("Invulnerable")); TBW_invulnerable->setToolTip(tr("All hogs have a personal forcefield")); - glGMLayout->addWidget(TBW_invulnerable,1,2,1,1); + glGMLayout->addWidget(TBW_invulnerable,1,2,1,1); - TBW_mines = new ToggleButtonWidget(gbGameModes, ":/res/btnMines.png"); - TBW_mines->setText(ToggleButtonWidget::tr("Add Mines")); + TBW_mines = new ToggleButtonWidget(gbGameModes, ":/res/btnMines.png"); + TBW_mines->setText(ToggleButtonWidget::tr("Add Mines")); TBW_mines->setToolTip(tr("Enable random mines")); - glGMLayout->addWidget(TBW_mines,1,3,1,1); + glGMLayout->addWidget(TBW_mines,1,3,1,1); - TBW_vampiric = new ToggleButtonWidget(gbGameModes, ":/res/btnVampiric.png"); - TBW_vampiric->setText(ToggleButtonWidget::tr("Vampirism")); + TBW_vampiric = new ToggleButtonWidget(gbGameModes, ":/res/btnVampiric.png"); + TBW_vampiric->setText(ToggleButtonWidget::tr("Vampirism")); TBW_vampiric->setToolTip(tr("Gain 80% of the damage you do back in health")); - glGMLayout->addWidget(TBW_vampiric,2,0,1,1); + glGMLayout->addWidget(TBW_vampiric,2,0,1,1); - TBW_karma = new ToggleButtonWidget(gbGameModes, ":/res/btnKarma.png"); - TBW_karma->setText(ToggleButtonWidget::tr("Karma")); + TBW_karma = new ToggleButtonWidget(gbGameModes, ":/res/btnKarma.png"); + TBW_karma->setText(ToggleButtonWidget::tr("Karma")); TBW_karma->setToolTip(tr("Share your opponents pain, share their damage")); - glGMLayout->addWidget(TBW_karma,2,1,1,1); + glGMLayout->addWidget(TBW_karma,2,1,1,1); - TBW_artillery = new ToggleButtonWidget(gbGameModes, ":/res/btnArtillery.png"); - TBW_artillery->setText(ToggleButtonWidget::tr("Artillery")); + TBW_artillery = new ToggleButtonWidget(gbGameModes, ":/res/btnArtillery.png"); + TBW_artillery->setText(ToggleButtonWidget::tr("Artillery")); TBW_artillery->setToolTip(tr("Your hogs are unable to move, put your artillery skills to the test")); - glGMLayout->addWidget(TBW_artillery,2,2,1,1); + glGMLayout->addWidget(TBW_artillery,2,2,1,1); - TBW_randomorder = new ToggleButtonWidget(gbGameModes, ":/res/btnRandomOrder.png"); - TBW_randomorder->setText(ToggleButtonWidget::tr("Random Order")); + TBW_randomorder = new ToggleButtonWidget(gbGameModes, ":/res/btnRandomOrder.png"); + TBW_randomorder->setText(ToggleButtonWidget::tr("Random Order")); TBW_randomorder->setToolTip(tr("Order of play is random instead of in room order.")); - glGMLayout->addWidget(TBW_randomorder,2,3,1,1); + glGMLayout->addWidget(TBW_randomorder,2,3,1,1); - TBW_king = new ToggleButtonWidget(gbGameModes, ":/res/btnKing.png"); - TBW_king->setText(ToggleButtonWidget::tr("King")); + TBW_king = new ToggleButtonWidget(gbGameModes, ":/res/btnKing.png"); + TBW_king->setText(ToggleButtonWidget::tr("King")); TBW_king->setToolTip(tr("Play with a King. If he dies, your side dies.")); - glGMLayout->addWidget(TBW_king,3,0,1,1); + glGMLayout->addWidget(TBW_king,3,0,1,1); - TBW_placehog = new ToggleButtonWidget(gbGameModes, ":/res/btnPlaceHog.png"); - TBW_placehog->setText(ToggleButtonWidget::tr("Place Hedgehogs")); + TBW_placehog = new ToggleButtonWidget(gbGameModes, ":/res/btnPlaceHog.png"); + TBW_placehog->setText(ToggleButtonWidget::tr("Place Hedgehogs")); TBW_placehog->setToolTip(tr("Take turns placing your hedgehogs before the start of play.")); - glGMLayout->addWidget(TBW_placehog,3,1,1,1); + glGMLayout->addWidget(TBW_placehog,3,1,1,1); - TBW_sharedammo = new ToggleButtonWidget(gbGameModes, ":/res/btnSharedAmmo.png"); - TBW_sharedammo->setText(ToggleButtonWidget::tr("Clan Shares Ammo")); + TBW_sharedammo = new ToggleButtonWidget(gbGameModes, ":/res/btnSharedAmmo.png"); + TBW_sharedammo->setText(ToggleButtonWidget::tr("Clan Shares Ammo")); TBW_sharedammo->setToolTip(tr("Ammo is shared between all teams that share a colour.")); - glGMLayout->addWidget(TBW_sharedammo,3,2,1,1); + glGMLayout->addWidget(TBW_sharedammo,3,2,1,1); - TBW_disablegirders = new ToggleButtonWidget(gbGameModes, ":/res/btnDisableGirders.png"); - TBW_disablegirders->setText(ToggleButtonWidget::tr("Disable Girders")); + TBW_disablegirders = new ToggleButtonWidget(gbGameModes, ":/res/btnDisableGirders.png"); + TBW_disablegirders->setText(ToggleButtonWidget::tr("Disable Girders")); TBW_disablegirders->setToolTip(tr("Disable girders when generating random maps.")); - glGMLayout->addWidget(TBW_disablegirders,3,3,1,1); - - // Right - QLabel * l; + glGMLayout->addWidget(TBW_disablegirders,3,3,1,1); + + // Right + QLabel * l; - l = new QLabel(gbBasicSettings); - l->setText(QLabel::tr("Damage Modifier")); - l->setWordWrap(true); - glBSLayout->addWidget(l,0,0,1,1); - l = new QLabel(gbBasicSettings); - l->setFixedSize(32,32); - l->setPixmap(QPixmap(":/res/iconDamage.png")); - glBSLayout->addWidget(l,0,1,1,1); + l = new QLabel(gbBasicSettings); + l->setText(QLabel::tr("Damage Modifier")); + l->setWordWrap(true); + glBSLayout->addWidget(l,0,0,1,1); + l = new QLabel(gbBasicSettings); + l->setFixedSize(32,32); + l->setPixmap(QPixmap(":/res/iconDamage.png")); + glBSLayout->addWidget(l,0,1,1,1); - SB_DamageModifier = new QSpinBox(gbBasicSettings); - SB_DamageModifier->setRange(10, 300); - SB_DamageModifier->setValue(100); - SB_DamageModifier->setSingleStep(25); - glBSLayout->addWidget(SB_DamageModifier,0,2,1,1); + SB_DamageModifier = new QSpinBox(gbBasicSettings); + SB_DamageModifier->setRange(10, 300); + SB_DamageModifier->setValue(100); + SB_DamageModifier->setSingleStep(25); + glBSLayout->addWidget(SB_DamageModifier,0,2,1,1); - l = new QLabel(gbBasicSettings); - l->setText(QLabel::tr("Turn Time")); - l->setWordWrap(true); - glBSLayout->addWidget(l,1,0,1,1); - l = new QLabel(gbBasicSettings); - l->setFixedSize(32,32); - l->setPixmap(QPixmap(":/res/iconTime.png")); - glBSLayout->addWidget(l,1,1,1,1); + l = new QLabel(gbBasicSettings); + l->setText(QLabel::tr("Turn Time")); + l->setWordWrap(true); + glBSLayout->addWidget(l,1,0,1,1); + l = new QLabel(gbBasicSettings); + l->setFixedSize(32,32); + l->setPixmap(QPixmap(":/res/iconTime.png")); + glBSLayout->addWidget(l,1,1,1,1); - SB_TurnTime = new QSpinBox(gbBasicSettings); - SB_TurnTime->setRange(1, 99); - SB_TurnTime->setValue(45); - SB_TurnTime->setSingleStep(15); - glBSLayout->addWidget(SB_TurnTime,1,2,1,1); + SB_TurnTime = new QSpinBox(gbBasicSettings); + SB_TurnTime->setRange(1, 99); + SB_TurnTime->setValue(45); + SB_TurnTime->setSingleStep(15); + glBSLayout->addWidget(SB_TurnTime,1,2,1,1); - l = new QLabel(gbBasicSettings); - l->setText(QLabel::tr("Initial Health")); - l->setWordWrap(true); - glBSLayout->addWidget(l,2,0,1,1); - l = new QLabel(gbBasicSettings); - l->setFixedSize(32,32); - l->setPixmap(QPixmap(":/res/iconHealth.png")); - glBSLayout->addWidget(l,2,1,1,1); + l = new QLabel(gbBasicSettings); + l->setText(QLabel::tr("Initial Health")); + l->setWordWrap(true); + glBSLayout->addWidget(l,2,0,1,1); + l = new QLabel(gbBasicSettings); + l->setFixedSize(32,32); + l->setPixmap(QPixmap(":/res/iconHealth.png")); + glBSLayout->addWidget(l,2,1,1,1); - SB_InitHealth = new QSpinBox(gbBasicSettings); - SB_InitHealth->setRange(50, 200); - SB_InitHealth->setValue(100); - SB_InitHealth->setSingleStep(25); - glBSLayout->addWidget(SB_InitHealth,2,2,1,1); + SB_InitHealth = new QSpinBox(gbBasicSettings); + SB_InitHealth->setRange(50, 200); + SB_InitHealth->setValue(100); + SB_InitHealth->setSingleStep(25); + glBSLayout->addWidget(SB_InitHealth,2,2,1,1); - l = new QLabel(gbBasicSettings); - l->setText(QLabel::tr("Sudden Death Timeout")); - l->setWordWrap(true); - glBSLayout->addWidget(l,3,0,1,1); - l = new QLabel(gbBasicSettings); - l->setFixedSize(32,32); - l->setPixmap(QPixmap(":/res/iconSuddenDeath.png")); - glBSLayout->addWidget(l,3,1,1,1); + l = new QLabel(gbBasicSettings); + l->setText(QLabel::tr("Sudden Death Timeout")); + l->setWordWrap(true); + glBSLayout->addWidget(l,3,0,1,1); + l = new QLabel(gbBasicSettings); + l->setFixedSize(32,32); + l->setPixmap(QPixmap(":/res/iconSuddenDeath.png")); + glBSLayout->addWidget(l,3,1,1,1); - SB_SuddenDeath = new QSpinBox(gbBasicSettings); - SB_SuddenDeath->setRange(0, 50); - SB_SuddenDeath->setValue(15); - SB_SuddenDeath->setSingleStep(3); - glBSLayout->addWidget(SB_SuddenDeath,3,2,1,1); + SB_SuddenDeath = new QSpinBox(gbBasicSettings); + SB_SuddenDeath->setRange(0, 50); + SB_SuddenDeath->setValue(15); + SB_SuddenDeath->setSingleStep(3); + glBSLayout->addWidget(SB_SuddenDeath,3,2,1,1); - l = new QLabel(gbBasicSettings); - l->setText(QLabel::tr("Crate Drops")); - l->setWordWrap(true); - glBSLayout->addWidget(l,4,0,1,1); - l = new QLabel(gbBasicSettings); - l->setFixedSize(32,32); - l->setPixmap(QPixmap(":/res/iconBox.png")); - glBSLayout->addWidget(l,4,1,1,1); + l = new QLabel(gbBasicSettings); + l->setText(QLabel::tr("Crate Drops")); + l->setWordWrap(true); + glBSLayout->addWidget(l,4,0,1,1); + l = new QLabel(gbBasicSettings); + l->setFixedSize(32,32); + l->setPixmap(QPixmap(":/res/iconBox.png")); + glBSLayout->addWidget(l,4,1,1,1); - SB_CaseProb = new FreqSpinBox(gbBasicSettings); - SB_CaseProb->setRange(0, 9); - SB_CaseProb->setValue(5); - glBSLayout->addWidget(SB_CaseProb,4,2,1,1); + SB_CaseProb = new FreqSpinBox(gbBasicSettings); + SB_CaseProb->setRange(0, 9); + SB_CaseProb->setValue(5); + glBSLayout->addWidget(SB_CaseProb,4,2,1,1); - l = new QLabel(gbBasicSettings); - l->setText(QLabel::tr("Mines Time")); - l->setWordWrap(true); - glBSLayout->addWidget(l,5,0,1,1); - l = new QLabel(gbBasicSettings); - l->setFixedSize(32,32); - l->setPixmap(QPixmap(":/res/iconTime.png")); // TODO: icon - glBSLayout->addWidget(l,5,1,1,1); - SB_MinesTime = new QSpinBox(gbBasicSettings); - SB_MinesTime->setRange(-1, 3); - SB_MinesTime->setValue(3); - SB_MinesTime->setSingleStep(1); - SB_MinesTime->setSpecialValueText(tr("Random")); - SB_MinesTime->setSuffix(" "+ tr("Seconds")); - glBSLayout->addWidget(SB_MinesTime,5,2,1,1); + l = new QLabel(gbBasicSettings); + l->setText(QLabel::tr("Mines Time")); + l->setWordWrap(true); + glBSLayout->addWidget(l,5,0,1,1); + l = new QLabel(gbBasicSettings); + l->setFixedSize(32,32); + l->setPixmap(QPixmap(":/res/iconTime.png")); // TODO: icon + glBSLayout->addWidget(l,5,1,1,1); + SB_MinesTime = new QSpinBox(gbBasicSettings); + SB_MinesTime->setRange(-1, 3); + SB_MinesTime->setValue(3); + SB_MinesTime->setSingleStep(1); + SB_MinesTime->setSpecialValueText(tr("Random")); + SB_MinesTime->setSuffix(" "+ tr("Seconds")); + glBSLayout->addWidget(SB_MinesTime,5,2,1,1); - l = new QLabel(gbBasicSettings); - l->setText(QLabel::tr("Mines")); - l->setWordWrap(true); - glBSLayout->addWidget(l,6,0,1,1); - l = new QLabel(gbBasicSettings); - l->setFixedSize(32,32); - l->setPixmap(QPixmap(":/res/iconMine.png")); // TODO: icon - glBSLayout->addWidget(l,6,1,1,1); - SB_Mines = new QSpinBox(gbBasicSettings); - SB_Mines->setRange(1, 80); - SB_Mines->setValue(1); - SB_Mines->setSingleStep(5); - glBSLayout->addWidget(SB_Mines,6,2,1,1); + l = new QLabel(gbBasicSettings); + l->setText(QLabel::tr("Mines")); + l->setWordWrap(true); + glBSLayout->addWidget(l,6,0,1,1); + l = new QLabel(gbBasicSettings); + l->setFixedSize(32,32); + l->setPixmap(QPixmap(":/res/iconMine.png")); // TODO: icon + glBSLayout->addWidget(l,6,1,1,1); + SB_Mines = new QSpinBox(gbBasicSettings); + SB_Mines->setRange(1, 80); + SB_Mines->setValue(1); + SB_Mines->setSingleStep(5); + glBSLayout->addWidget(SB_Mines,6,2,1,1); - l = new QLabel(gbBasicSettings); - l->setText(QLabel::tr("% Dud Mines")); - l->setWordWrap(true); - glBSLayout->addWidget(l,7,0,1,1); - l = new QLabel(gbBasicSettings); - l->setFixedSize(32,32); - l->setPixmap(QPixmap(":/res/iconMine.png")); - glBSLayout->addWidget(l,7,1,1,1); - SB_MineDuds = new QSpinBox(gbBasicSettings); - SB_MineDuds->setRange(0, 100); - SB_MineDuds->setValue(0); - SB_MineDuds->setSingleStep(5); - glBSLayout->addWidget(SB_MineDuds,7,2,1,1); + l = new QLabel(gbBasicSettings); + l->setText(QLabel::tr("% Dud Mines")); + l->setWordWrap(true); + glBSLayout->addWidget(l,7,0,1,1); + l = new QLabel(gbBasicSettings); + l->setFixedSize(32,32); + l->setPixmap(QPixmap(":/res/iconMine.png")); + glBSLayout->addWidget(l,7,1,1,1); + SB_MineDuds = new QSpinBox(gbBasicSettings); + SB_MineDuds->setRange(0, 100); + SB_MineDuds->setValue(0); + SB_MineDuds->setSingleStep(5); + glBSLayout->addWidget(SB_MineDuds,7,2,1,1); - l = new QLabel(gbBasicSettings); - l->setText(QLabel::tr("Explosives")); - l->setWordWrap(true); - glBSLayout->addWidget(l,8,0,1,1); - l = new QLabel(gbBasicSettings); - l->setFixedSize(32,32); - l->setPixmap(QPixmap(":/res/iconDamage.png")); - glBSLayout->addWidget(l,8,1,1,1); - SB_Explosives = new QSpinBox(gbBasicSettings); - SB_Explosives->setRange(0, 40); - SB_Explosives->setValue(0); - SB_Explosives->setSingleStep(1); - glBSLayout->addWidget(SB_Explosives,8,2,1,1); + l = new QLabel(gbBasicSettings); + l->setText(QLabel::tr("Explosives")); + l->setWordWrap(true); + glBSLayout->addWidget(l,8,0,1,1); + l = new QLabel(gbBasicSettings); + l->setFixedSize(32,32); + l->setPixmap(QPixmap(":/res/iconDamage.png")); + glBSLayout->addWidget(l,8,1,1,1); + SB_Explosives = new QSpinBox(gbBasicSettings); + SB_Explosives->setRange(0, 40); + SB_Explosives->setValue(0); + SB_Explosives->setSingleStep(1); + glBSLayout->addWidget(SB_Explosives,8,2,1,1); - l = new QLabel(gbBasicSettings); - l->setText(QLabel::tr("Scheme Name:")); + l = new QLabel(gbBasicSettings); + l->setText(QLabel::tr("Scheme Name:")); - LE_name = new QLineEdit(this); + LE_name = new QLineEdit(this); - gl->addWidget(LE_name,14,1,1,5); - gl->addWidget(l,14,0,1,1); + gl->addWidget(LE_name,14,1,1,5); + gl->addWidget(l,14,0,1,1); - mapper = new QDataWidgetMapper(this); + mapper = new QDataWidgetMapper(this); - BtnBack = addButton(":/res/Exit.png", pageLayout, 15, 0, true); - BtnNew = addButton(tr("New"), pageLayout, 15, 2); - BtnDelete = addButton(tr("Delete"), pageLayout, 15, 3); + BtnBack = addButton(":/res/Exit.png", pageLayout, 15, 0, true); + BtnNew = addButton(tr("New"), pageLayout, 15, 2); + BtnDelete = addButton(tr("Delete"), pageLayout, 15, 3); - selectScheme = new QComboBox(this); - pageLayout->addWidget(selectScheme, 15, 1); + selectScheme = new QComboBox(this); + pageLayout->addWidget(selectScheme, 15, 1); - connect(BtnNew, SIGNAL(clicked()), this, SLOT(newRow())); - connect(BtnDelete, SIGNAL(clicked()), this, SLOT(deleteRow())); - connect(selectScheme, SIGNAL(currentIndexChanged(int)), mapper, SLOT(setCurrentIndex(int))); - connect(selectScheme, SIGNAL(currentIndexChanged(int)), this, SLOT(schemeSelected(int))); + connect(BtnNew, SIGNAL(clicked()), this, SLOT(newRow())); + connect(BtnDelete, SIGNAL(clicked()), this, SLOT(deleteRow())); + connect(selectScheme, SIGNAL(currentIndexChanged(int)), mapper, SLOT(setCurrentIndex(int))); + connect(selectScheme, SIGNAL(currentIndexChanged(int)), this, SLOT(schemeSelected(int))); } void PageScheme::setModel(QAbstractItemModel * model) { - mapper->setModel(model); - selectScheme->setModel(model); + mapper->setModel(model); + selectScheme->setModel(model); - mapper->addMapping(LE_name, 0); - mapper->addMapping(TBW_mode_Forts->button(), 1); - mapper->addMapping(TBW_teamsDivide->button(), 2); - mapper->addMapping(TBW_solid->button(), 3); - mapper->addMapping(TBW_border->button(), 4); - mapper->addMapping(TBW_lowGravity->button(), 5); - mapper->addMapping(TBW_laserSight->button(), 6); - mapper->addMapping(TBW_invulnerable->button(), 7); - mapper->addMapping(TBW_mines->button(), 8); - mapper->addMapping(TBW_vampiric->button(), 9); - mapper->addMapping(TBW_karma->button(), 10); - mapper->addMapping(TBW_artillery->button(), 11); - mapper->addMapping(TBW_randomorder->button(), 12); - mapper->addMapping(TBW_king->button(), 13); - mapper->addMapping(TBW_placehog->button(), 14); - mapper->addMapping(TBW_sharedammo->button(), 15); - mapper->addMapping(TBW_disablegirders->button(), 16); - mapper->addMapping(SB_DamageModifier, 17); - mapper->addMapping(SB_TurnTime, 18); - mapper->addMapping(SB_InitHealth, 19); - mapper->addMapping(SB_SuddenDeath, 20); - mapper->addMapping(SB_CaseProb, 21); - mapper->addMapping(SB_MinesTime, 22); - mapper->addMapping(SB_Mines, 23); - mapper->addMapping(SB_MineDuds, 24); - mapper->addMapping(SB_Explosives, 25); + mapper->addMapping(LE_name, 0); + mapper->addMapping(TBW_mode_Forts->button(), 1); + mapper->addMapping(TBW_teamsDivide->button(), 2); + mapper->addMapping(TBW_solid->button(), 3); + mapper->addMapping(TBW_border->button(), 4); + mapper->addMapping(TBW_lowGravity->button(), 5); + mapper->addMapping(TBW_laserSight->button(), 6); + mapper->addMapping(TBW_invulnerable->button(), 7); + mapper->addMapping(TBW_mines->button(), 8); + mapper->addMapping(TBW_vampiric->button(), 9); + mapper->addMapping(TBW_karma->button(), 10); + mapper->addMapping(TBW_artillery->button(), 11); + mapper->addMapping(TBW_randomorder->button(), 12); + mapper->addMapping(TBW_king->button(), 13); + mapper->addMapping(TBW_placehog->button(), 14); + mapper->addMapping(TBW_sharedammo->button(), 15); + mapper->addMapping(TBW_disablegirders->button(), 16); + mapper->addMapping(SB_DamageModifier, 17); + mapper->addMapping(SB_TurnTime, 18); + mapper->addMapping(SB_InitHealth, 19); + mapper->addMapping(SB_SuddenDeath, 20); + mapper->addMapping(SB_CaseProb, 21); + mapper->addMapping(SB_MinesTime, 22); + mapper->addMapping(SB_Mines, 23); + mapper->addMapping(SB_MineDuds, 24); + mapper->addMapping(SB_Explosives, 25); - mapper->toFirst(); + mapper->toFirst(); } void PageScheme::newRow() { - QAbstractItemModel * model = mapper->model(); - model->insertRow(model->rowCount()); - selectScheme->setCurrentIndex(model->rowCount() - 1); + QAbstractItemModel * model = mapper->model(); + model->insertRow(model->rowCount()); + selectScheme->setCurrentIndex(model->rowCount() - 1); } void PageScheme::deleteRow() { - QAbstractItemModel * model = mapper->model(); - model->removeRow(selectScheme->currentIndex()); + QAbstractItemModel * model = mapper->model(); + model->removeRow(selectScheme->currentIndex()); } void PageScheme::schemeSelected(int n) { - gbGameModes->setEnabled(n >= 5); // FIXME: derive number from model - gbBasicSettings->setEnabled(n >= 5); - LE_name->setEnabled(n >= 5); + gbGameModes->setEnabled(n >= 5); // FIXME: derive number from model + gbBasicSettings->setEnabled(n >= 5); + LE_name->setEnabled(n >= 5); } ///////////////////////////////////////////////// PageAdmin::PageAdmin(QWidget* parent) : - AbstractPage(parent) + AbstractPage(parent) { - QGridLayout * pageLayout = new QGridLayout(this); + QGridLayout * pageLayout = new QGridLayout(this); - QLabel * lblSM = new QLabel(this); - lblSM->setText(tr("Server message:")); - pageLayout->addWidget(lblSM, 0, 0); + QLabel * lblSM = new QLabel(this); + lblSM->setText(tr("Server message:")); + pageLayout->addWidget(lblSM, 0, 0); - leServerMessage = new QLineEdit(this); - pageLayout->addWidget(leServerMessage, 0, 1); + leServerMessage = new QLineEdit(this); + pageLayout->addWidget(leServerMessage, 0, 1); - pbSetSM = addButton(tr("Set message"), pageLayout, 0, 2); - pbClearAccountsCache = addButton(tr("Clear Accounts Cache"), pageLayout, 1, 0); + pbSetSM = addButton(tr("Set message"), pageLayout, 0, 2); + pbClearAccountsCache = addButton(tr("Clear Accounts Cache"), pageLayout, 1, 0); - BtnBack = addButton(":/res/Exit.png", pageLayout, 2, 0, true); + BtnBack = addButton(":/res/Exit.png", pageLayout, 2, 0, true); - connect(pbSetSM, SIGNAL(clicked()), this, SLOT(smChanged())); + connect(pbSetSM, SIGNAL(clicked()), this, SLOT(smChanged())); } void PageAdmin::smChanged() { - emit setServerMessage(leServerMessage->text()); + emit setServerMessage(leServerMessage->text()); } void PageAdmin::serverMessage(const QString & str) { - leServerMessage->setText(str); + leServerMessage->setText(str); } ///////////////////////////////////////////////// PageNetType::PageNetType(QWidget* parent) : AbstractPage(parent) { - QGridLayout * pageLayout = new QGridLayout(this); - pageLayout->setRowStretch(0, 10); - pageLayout->setRowStretch(3, 10); + QGridLayout * pageLayout = new QGridLayout(this); + pageLayout->setRowStretch(0, 10); + pageLayout->setRowStretch(3, 10); - pageLayout->setColumnStretch(1, 10); - pageLayout->setColumnStretch(2, 20); - pageLayout->setColumnStretch(3, 10); + pageLayout->setColumnStretch(1, 10); + pageLayout->setColumnStretch(2, 20); + pageLayout->setColumnStretch(3, 10); - BtnLAN = addButton(tr("LAN game"), pageLayout, 1, 2); - BtnOfficialServer = addButton(tr("Official server"), pageLayout, 2, 2); + BtnLAN = addButton(tr("LAN game"), pageLayout, 1, 2); + BtnOfficialServer = addButton(tr("Official server"), pageLayout, 2, 2); - // hack: temporary deactivated - requires server modifications that aren't backward compatible (yet) - //BtnOfficialServer->setEnabled(false); + // hack: temporary deactivated - requires server modifications that aren't backward compatible (yet) + //BtnOfficialServer->setEnabled(false); - BtnBack = addButton(":/res/Exit.png", pageLayout, 4, 0, true); + BtnBack = addButton(":/res/Exit.png", pageLayout, 4, 0, true); } diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/pages.h --- a/QTfrontend/pages.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/pages.h Sat Mar 06 10:59:20 2010 +0000 @@ -62,7 +62,7 @@ class AbstractPage : public QWidget { - Q_OBJECT + Q_OBJECT public: @@ -132,375 +132,375 @@ class PageMain : public AbstractPage { - Q_OBJECT + Q_OBJECT public: - PageMain(QWidget* parent = 0); + PageMain(QWidget* parent = 0); - QPushButton *BtnSinglePlayer; - QPushButton *BtnNet; - QPushButton *BtnSetup; - QPushButton *BtnInfo; - QPushButton *BtnExit; + QPushButton *BtnSinglePlayer; + QPushButton *BtnNet; + QPushButton *BtnSetup; + QPushButton *BtnInfo; + QPushButton *BtnExit; }; class PageEditTeam : public AbstractPage { - Q_OBJECT + Q_OBJECT public: - PageEditTeam(QWidget* parent, SDLInteraction * sdli); - QSignalMapper* signalMapper; - QGroupBox *GBoxHedgehogs; - QGroupBox *GBoxTeam; - QGroupBox *GBoxFort; - QComboBox *CBFort; - SquareLabel *FortPreview; - QComboBox *CBGrave; - QComboBox *CBFlag; - QComboBox *CBTeamLvl; - QComboBox *CBVoicepack; - QGroupBox *GBoxBinds; - QToolBox *BindsBox; - QPushButton *BtnTeamDiscard; - QPushButton *BtnTeamSave; - QPushButton * BtnTestSound; - QLineEdit * TeamNameEdit; - QLineEdit * HHNameEdit[8]; - QComboBox * HHHats[8]; - QPushButton * randButton[8]; - QComboBox * CBBind[BINDS_NUMBER]; - QPushButton * randTeamButton; + PageEditTeam(QWidget* parent, SDLInteraction * sdli); + QSignalMapper* signalMapper; + QGroupBox *GBoxHedgehogs; + QGroupBox *GBoxTeam; + QGroupBox *GBoxFort; + QComboBox *CBFort; + SquareLabel *FortPreview; + QComboBox *CBGrave; + QComboBox *CBFlag; + QComboBox *CBTeamLvl; + QComboBox *CBVoicepack; + QGroupBox *GBoxBinds; + QToolBox *BindsBox; + QPushButton *BtnTeamDiscard; + QPushButton *BtnTeamSave; + QPushButton * BtnTestSound; + QLineEdit * TeamNameEdit; + QLineEdit * HHNameEdit[8]; + QComboBox * HHHats[8]; + QPushButton * randButton[8]; + QComboBox * CBBind[BINDS_NUMBER]; + QPushButton * randTeamButton; private: SDLInteraction * mySdli; public slots: - void CBFort_activated(const QString & gravename); + void CBFort_activated(const QString & gravename); private slots: - void testSound(); + void testSound(); }; class PageMultiplayer : public AbstractPage { - Q_OBJECT + Q_OBJECT public: - PageMultiplayer(QWidget* parent = 0); + PageMultiplayer(QWidget* parent = 0); - QPushButton *BtnBack; - GameCFGWidget *gameCFG; - TeamSelWidget *teamsSelect; - QPushButton *BtnStartMPGame; + QPushButton *BtnBack; + GameCFGWidget *gameCFG; + TeamSelWidget *teamsSelect; + QPushButton *BtnStartMPGame; }; class PageOptions : public AbstractPage { - Q_OBJECT + Q_OBJECT public: - PageOptions(QWidget* parent = 0); + PageOptions(QWidget* parent = 0); - QPushButton *WeaponsButt; - QPushButton *WeaponEdit; - QComboBox *WeaponsName; - QCheckBox *WeaponTooltip; - QComboBox *CBLanguage; + QPushButton *WeaponsButt; + QPushButton *WeaponEdit; + QComboBox *WeaponsName; + QCheckBox *WeaponTooltip; + QComboBox *CBLanguage; - QPushButton *BtnBack; - IconedGroupBox *teamsBox; - QPushButton *BtnNewTeam; - QPushButton *BtnEditTeam; - QComboBox *CBTeamName; - IconedGroupBox *AGGroupBox; - QComboBox *CBResolution; - QCheckBox *CBEnableSound; - QCheckBox *CBEnableFrontendSound; + QPushButton *BtnBack; + IconedGroupBox *teamsBox; + QPushButton *BtnNewTeam; + QPushButton *BtnEditTeam; + QComboBox *CBTeamName; + IconedGroupBox *AGGroupBox; + QComboBox *CBResolution; + QCheckBox *CBEnableSound; + QCheckBox *CBEnableFrontendSound; #ifdef _WIN32 - QCheckBox *CBHardwareSound; + QCheckBox *CBHardwareSound; #endif - QCheckBox *CBEnableMusic; - QCheckBox *CBEnableFrontendMusic; - QCheckBox *CBFullscreen; - QCheckBox *CBFrontendFullscreen; - QCheckBox *CBShowFPS; - QCheckBox *CBAltDamage; - QCheckBox *CBNameWithDate; + QCheckBox *CBEnableMusic; + QCheckBox *CBEnableFrontendMusic; + QCheckBox *CBFullscreen; + QCheckBox *CBFrontendFullscreen; + QCheckBox *CBShowFPS; + QCheckBox *CBAltDamage; + QCheckBox *CBNameWithDate; #ifdef __APPLE__ QCheckBox *CBAutoUpdate; #endif - FPSEdit *fpsedit; - QPushButton *BtnSaveOptions; - QLabel *labelNN; - QSpinBox * volumeBox; - QLineEdit *editNetNick; - QCheckBox *CBReduceQuality; - QCheckBox *CBFrontendEffects; + FPSEdit *fpsedit; + QPushButton *BtnSaveOptions; + QLabel *labelNN; + QSpinBox * volumeBox; + QLineEdit *editNetNick; + QCheckBox *CBReduceQuality; + QCheckBox *CBFrontendEffects; }; class PageNet : public AbstractPage { - Q_OBJECT + Q_OBJECT public: - PageNet(QWidget* parent = 0); + PageNet(QWidget* parent = 0); - QPushButton* BtnUpdateSList; - QTableView * tvServersList; - QPushButton * BtnBack; - QPushButton * BtnNetConnect; - QPushButton * BtnNetSvrStart; - QPushButton * BtnSpecifyServer; + QPushButton* BtnUpdateSList; + QTableView * tvServersList; + QPushButton * BtnBack; + QPushButton * BtnNetConnect; + QPushButton * BtnNetSvrStart; + QPushButton * BtnSpecifyServer; private: - QGroupBox * ConnGroupBox; - QGridLayout * GBClayout; + QGroupBox * ConnGroupBox; + QGridLayout * GBClayout; private slots: - void slotConnect(); + void slotConnect(); public slots: - void updateServersList(); + void updateServersList(); signals: - void connectClicked(const QString & host, quint16 port); + void connectClicked(const QString & host, quint16 port); }; class PageNetServer : public AbstractPage { - Q_OBJECT + Q_OBJECT public: - PageNetServer(QWidget* parent = 0); + PageNetServer(QWidget* parent = 0); - QPushButton *BtnBack; - QPushButton *BtnStart; - QPushButton *BtnDefault; - QLabel *labelSD; - QLineEdit *leServerDescr; - QLabel *labelPort; - QSpinBox *sbPort; + QPushButton *BtnBack; + QPushButton *BtnStart; + QPushButton *BtnDefault; + QLabel *labelSD; + QLineEdit *leServerDescr; + QLabel *labelPort; + QSpinBox *sbPort; private slots: - void setDefaultPort(); + void setDefaultPort(); }; class PageNetGame : public AbstractPage { - Q_OBJECT + Q_OBJECT public: - PageNetGame(QWidget* parent, QSettings * config, SDLInteraction * sdli); + PageNetGame(QWidget* parent, QSettings * config, SDLInteraction * sdli); - QPushButton *BtnBack; - QPushButton *BtnGo; - QPushButton *BtnMaster; - QPushButton *BtnStart; + QPushButton *BtnBack; + QPushButton *BtnGo; + QPushButton *BtnMaster; + QPushButton *BtnStart; - QAction * restrictJoins; - QAction * restrictTeamAdds; + QAction * restrictJoins; + QAction * restrictTeamAdds; - HWChatWidget* pChatWidget; + HWChatWidget* pChatWidget; - TeamSelWidget* pNetTeamsWidget; - GameCFGWidget* pGameCFG; + TeamSelWidget* pNetTeamsWidget; + GameCFGWidget* pGameCFG; public slots: - void setReadyStatus(bool isReady); - void setMasterMode(bool isMaster); + void setReadyStatus(bool isReady); + void setMasterMode(bool isMaster); }; class PageInfo : public AbstractPage { - Q_OBJECT + Q_OBJECT public: - PageInfo(QWidget* parent = 0); + PageInfo(QWidget* parent = 0); - QPushButton *BtnBack; - About *about; + QPushButton *BtnBack; + About *about; }; class PageSinglePlayer : public AbstractPage { - Q_OBJECT + Q_OBJECT public: - PageSinglePlayer(QWidget* parent = 0); + PageSinglePlayer(QWidget* parent = 0); - QPushButton *BtnSimpleGamePage; - QPushButton *BtnTrainPage; - QPushButton *BtnMultiplayer; - QPushButton *BtnLoad; - QPushButton *BtnDemos; - QPushButton *BtnBack; - GameCFGWidget *gameCFG; + QPushButton *BtnSimpleGamePage; + QPushButton *BtnTrainPage; + QPushButton *BtnMultiplayer; + QPushButton *BtnLoad; + QPushButton *BtnDemos; + QPushButton *BtnBack; + GameCFGWidget *gameCFG; }; class PageTraining : public AbstractPage { - Q_OBJECT + Q_OBJECT public: - PageTraining(QWidget* parent = 0); + PageTraining(QWidget* parent = 0); - QPushButton *BtnStartTrain; - QPushButton *BtnBack; - QComboBox *CBSelect; + QPushButton *BtnStartTrain; + QPushButton *BtnBack; + QComboBox *CBSelect; }; class PageSelectWeapon : public AbstractPage { - Q_OBJECT + Q_OBJECT public: - PageSelectWeapon(QWidget* parent = 0); + PageSelectWeapon(QWidget* parent = 0); - QPushButton *BtnSave; - QPushButton *BtnDefault; - QPushButton *BtnDelete; - QPushButton *BtnBack; - SelWeaponWidget* pWeapons; + QPushButton *BtnSave; + QPushButton *BtnDefault; + QPushButton *BtnDelete; + QPushButton *BtnBack; + SelWeaponWidget* pWeapons; }; class PageInGame : public AbstractPage { - Q_OBJECT + Q_OBJECT public: - PageInGame(QWidget* parent = 0); + PageInGame(QWidget* parent = 0); }; class PageRoomsList : public AbstractPage { - Q_OBJECT + Q_OBJECT public: PageRoomsList(QWidget* parent, QSettings * config, SDLInteraction * sdli); - QLineEdit * roomName; - QTableWidget * roomsList; - QPushButton * BtnBack; - QPushButton * BtnCreate; - QPushButton * BtnJoin; - QPushButton * BtnRefresh; - QPushButton * BtnAdmin; - HWChatWidget * chatWidget; + QLineEdit * roomName; + QTableWidget * roomsList; + QPushButton * BtnBack; + QPushButton * BtnCreate; + QPushButton * BtnJoin; + QPushButton * BtnRefresh; + QPushButton * BtnAdmin; + HWChatWidget * chatWidget; public slots: - void setRoomsList(const QStringList & list); - void setAdmin(bool); + void setRoomsList(const QStringList & list); + void setAdmin(bool); private slots: - void onCreateClick(); - void onJoinClick(); - void onRefreshClick(); + void onCreateClick(); + void onJoinClick(); + void onRefreshClick(); signals: - void askForCreateRoom(const QString &); - void askForJoinRoom(const QString &); - void askForRoomList(); + void askForCreateRoom(const QString &); + void askForJoinRoom(const QString &); + void askForRoomList(); }; class PageConnecting : public AbstractPage { - Q_OBJECT + Q_OBJECT public: - PageConnecting(QWidget* parent = 0); + PageConnecting(QWidget* parent = 0); }; class PageScheme : public AbstractPage { - Q_OBJECT + Q_OBJECT public: - PageScheme(QWidget* parent = 0); + PageScheme(QWidget* parent = 0); - QPushButton * BtnBack; - QPushButton * BtnNew; - QPushButton * BtnDelete; - QPushButton * BtnSave; + QPushButton * BtnBack; + QPushButton * BtnNew; + QPushButton * BtnDelete; + QPushButton * BtnSave; - void setModel(QAbstractItemModel * model); + void setModel(QAbstractItemModel * model); private: - QDataWidgetMapper * mapper; - ToggleButtonWidget * TBW_mode_Forts; - ToggleButtonWidget * TBW_teamsDivide; - ToggleButtonWidget * TBW_solid; - ToggleButtonWidget * TBW_border; - ToggleButtonWidget * TBW_lowGravity; - ToggleButtonWidget * TBW_laserSight; - ToggleButtonWidget * TBW_invulnerable; - ToggleButtonWidget * TBW_mines; - ToggleButtonWidget * TBW_vampiric; - ToggleButtonWidget * TBW_karma; - ToggleButtonWidget * TBW_artillery; - ToggleButtonWidget * TBW_randomorder; - ToggleButtonWidget * TBW_king; - ToggleButtonWidget * TBW_placehog; - ToggleButtonWidget * TBW_sharedammo; - ToggleButtonWidget * TBW_disablegirders; + QDataWidgetMapper * mapper; + ToggleButtonWidget * TBW_mode_Forts; + ToggleButtonWidget * TBW_teamsDivide; + ToggleButtonWidget * TBW_solid; + ToggleButtonWidget * TBW_border; + ToggleButtonWidget * TBW_lowGravity; + ToggleButtonWidget * TBW_laserSight; + ToggleButtonWidget * TBW_invulnerable; + ToggleButtonWidget * TBW_mines; + ToggleButtonWidget * TBW_vampiric; + ToggleButtonWidget * TBW_karma; + ToggleButtonWidget * TBW_artillery; + ToggleButtonWidget * TBW_randomorder; + ToggleButtonWidget * TBW_king; + ToggleButtonWidget * TBW_placehog; + ToggleButtonWidget * TBW_sharedammo; + ToggleButtonWidget * TBW_disablegirders; - QSpinBox * SB_DamageModifier; - QSpinBox * SB_TurnTime; - QSpinBox * SB_InitHealth; - QSpinBox * SB_SuddenDeath; - FreqSpinBox * SB_CaseProb; - QSpinBox * SB_MinesTime; - QSpinBox * SB_Mines; - QSpinBox * SB_MineDuds; - QSpinBox * SB_Explosives; - QLineEdit * LE_name; - QComboBox * selectScheme; + QSpinBox * SB_DamageModifier; + QSpinBox * SB_TurnTime; + QSpinBox * SB_InitHealth; + QSpinBox * SB_SuddenDeath; + FreqSpinBox * SB_CaseProb; + QSpinBox * SB_MinesTime; + QSpinBox * SB_Mines; + QSpinBox * SB_MineDuds; + QSpinBox * SB_Explosives; + QLineEdit * LE_name; + QComboBox * selectScheme; - QGroupBox * gbGameModes; - QGroupBox * gbBasicSettings; + QGroupBox * gbGameModes; + QGroupBox * gbBasicSettings; private slots: - void newRow(); - void deleteRow(); - void schemeSelected(int); + void newRow(); + void deleteRow(); + void schemeSelected(int); }; class PageAdmin : public AbstractPage { - Q_OBJECT + Q_OBJECT public: - PageAdmin(QWidget* parent = 0); + PageAdmin(QWidget* parent = 0); - QPushButton * BtnBack; - QPushButton * pbClearAccountsCache; + QPushButton * BtnBack; + QPushButton * pbClearAccountsCache; private: - QLineEdit * leServerMessage; - QPushButton * pbSetSM; + QLineEdit * leServerMessage; + QPushButton * pbSetSM; private slots: - void smChanged(); + void smChanged(); public slots: - void serverMessage(const QString & str); + void serverMessage(const QString & str); signals: - void setServerMessage(const QString & str); + void setServerMessage(const QString & str); }; class PageNetType : public AbstractPage { - Q_OBJECT + Q_OBJECT public: - PageNetType(QWidget* parent = 0); + PageNetType(QWidget* parent = 0); - QPushButton * BtnBack; - QPushButton * BtnLAN; - QPushButton * BtnOfficialServer; + QPushButton * BtnBack; + QPushButton * BtnLAN; + QPushButton * BtnOfficialServer; }; #endif // PAGES_H diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/playrecordpage.cpp --- a/QTfrontend/playrecordpage.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/playrecordpage.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -30,123 +30,123 @@ PagePlayDemo::PagePlayDemo(QWidget* parent) : AbstractPage(parent) { - QFont * font14 = new QFont("MS Shell Dlg", 14); - QGridLayout * pageLayout = new QGridLayout(this); - pageLayout->setColumnStretch(0, 1); - pageLayout->setColumnStretch(1, 2); - pageLayout->setColumnStretch(2, 1); - pageLayout->setRowStretch(2, 100); + QFont * font14 = new QFont("MS Shell Dlg", 14); + QGridLayout * pageLayout = new QGridLayout(this); + pageLayout->setColumnStretch(0, 1); + pageLayout->setColumnStretch(1, 2); + pageLayout->setColumnStretch(2, 1); + pageLayout->setRowStretch(2, 100); - BtnBack = addButton(":/res/Exit.png", pageLayout, 3, 0, true); + BtnBack = addButton(":/res/Exit.png", pageLayout, 3, 0, true); - BtnPlayDemo = new QPushButton(this); - BtnPlayDemo->setFont(*font14); - BtnPlayDemo->setText(QPushButton::tr("Play demo")); - pageLayout->addWidget(BtnPlayDemo, 3, 2); + BtnPlayDemo = new QPushButton(this); + BtnPlayDemo->setFont(*font14); + BtnPlayDemo->setText(QPushButton::tr("Play demo")); + pageLayout->addWidget(BtnPlayDemo, 3, 2); - BtnRenameRecord = new QPushButton(this); - BtnRenameRecord->setText(QPushButton::tr("Rename")); - pageLayout->addWidget(BtnRenameRecord, 0, 2); + BtnRenameRecord = new QPushButton(this); + BtnRenameRecord->setText(QPushButton::tr("Rename")); + pageLayout->addWidget(BtnRenameRecord, 0, 2); - BtnRemoveRecord = new QPushButton(this); - BtnRemoveRecord->setText(QPushButton::tr("Delete")); - pageLayout->addWidget(BtnRemoveRecord, 1, 2); + BtnRemoveRecord = new QPushButton(this); + BtnRemoveRecord->setText(QPushButton::tr("Delete")); + pageLayout->addWidget(BtnRemoveRecord, 1, 2); - DemosList = new QListWidget(this); - DemosList->setGeometry(QRect(170, 10, 311, 311)); - pageLayout->addWidget(DemosList, 0, 1, 3, 1); + DemosList = new QListWidget(this); + DemosList->setGeometry(QRect(170, 10, 311, 311)); + pageLayout->addWidget(DemosList, 0, 1, 3, 1); - connect(BtnRenameRecord, SIGNAL(clicked()), this, SLOT(renameRecord())); - connect(BtnRemoveRecord, SIGNAL(clicked()), this, SLOT(removeRecord())); + connect(BtnRenameRecord, SIGNAL(clicked()), this, SLOT(renameRecord())); + connect(BtnRemoveRecord, SIGNAL(clicked()), this, SLOT(removeRecord())); } void PagePlayDemo::FillFromDir(RecordType rectype) { - QDir dir; - QString extension; + QDir dir; + QString extension; - recType = rectype; + recType = rectype; - dir.cd(cfgdir->absolutePath()); - if (rectype == RT_Demo) - { - dir.cd("Demos"); - extension = "hwd"; - BtnPlayDemo->setText(QPushButton::tr("Play demo")); - } else - { - dir.cd("Saves"); - extension = "hws"; - BtnPlayDemo->setText(QPushButton::tr("Load")); - } - dir.setFilter(QDir::Files); + dir.cd(cfgdir->absolutePath()); + if (rectype == RT_Demo) + { + dir.cd("Demos"); + extension = "hwd"; + BtnPlayDemo->setText(QPushButton::tr("Play demo")); + } else + { + dir.cd("Saves"); + extension = "hws"; + BtnPlayDemo->setText(QPushButton::tr("Load")); + } + dir.setFilter(QDir::Files); - QStringList sl = dir.entryList(QStringList(QString("*.%2.%1").arg(extension, *cProtoVer))); - sl.replaceInStrings(QRegExp(QString("^(.*)\\.%2\\.%1$").arg(extension, *cProtoVer)), "\\1"); + QStringList sl = dir.entryList(QStringList(QString("*.%2.%1").arg(extension, *cProtoVer))); + sl.replaceInStrings(QRegExp(QString("^(.*)\\.%2\\.%1$").arg(extension, *cProtoVer)), "\\1"); - DemosList->clear(); - DemosList->addItems(sl); + DemosList->clear(); + DemosList->addItems(sl); - for (int i = 0; i < DemosList->count(); ++i) - { - DemosList->item(i)->setData(Qt::UserRole, dir.absoluteFilePath(QString("%1.%3.%2").arg(sl[i], extension, *cProtoVer))); - DemosList->item(i)->setIcon(recType == RT_Demo ? QIcon(":/res/file_demo.png") : QIcon(":/res/file_save.png")); - } + for (int i = 0; i < DemosList->count(); ++i) + { + DemosList->item(i)->setData(Qt::UserRole, dir.absoluteFilePath(QString("%1.%3.%2").arg(sl[i], extension, *cProtoVer))); + DemosList->item(i)->setIcon(recType == RT_Demo ? QIcon(":/res/file_demo.png") : QIcon(":/res/file_save.png")); + } } void PagePlayDemo::renameRecord() { - QListWidgetItem * curritem = DemosList->currentItem(); - if (!curritem) - { - QMessageBox::critical(this, - tr("Error"), - tr("Please select record from the list"), - tr("OK")); - return ; - } - QFile rfile(curritem->data(Qt::UserRole).toString()); + QListWidgetItem * curritem = DemosList->currentItem(); + if (!curritem) + { + QMessageBox::critical(this, + tr("Error"), + tr("Please select record from the list"), + tr("OK")); + return ; + } + QFile rfile(curritem->data(Qt::UserRole).toString()); - QFileInfo finfo(rfile); + QFileInfo finfo(rfile); - bool ok; + bool ok; - QString newname = QInputDialog::getText(this, tr("Rename dialog"), tr("Enter new file name:"), QLineEdit::Normal, finfo.completeBaseName().replace("." + *cProtoVer, ""), &ok); + QString newname = QInputDialog::getText(this, tr("Rename dialog"), tr("Enter new file name:"), QLineEdit::Normal, finfo.completeBaseName().replace("." + *cProtoVer, ""), &ok); - if(ok && newname.size()) - { - QString newfullname = QString("%1/%2.%3.%4") - .arg(finfo.absolutePath()) - .arg(newname) - .arg(*cProtoVer) - .arg(finfo.suffix()); + if(ok && newname.size()) + { + QString newfullname = QString("%1/%2.%3.%4") + .arg(finfo.absolutePath()) + .arg(newname) + .arg(*cProtoVer) + .arg(finfo.suffix()); - ok = rfile.rename(newfullname); - if(!ok) - QMessageBox::critical(this, tr("Error"), tr("Cannot rename to") + newfullname); - else - FillFromDir(recType); - } + ok = rfile.rename(newfullname); + if(!ok) + QMessageBox::critical(this, tr("Error"), tr("Cannot rename to") + newfullname); + else + FillFromDir(recType); + } } void PagePlayDemo::removeRecord() { - QListWidgetItem * curritem = DemosList->currentItem(); - if (!curritem) - { - QMessageBox::critical(this, - tr("Error"), - tr("Please select record from the list"), - tr("OK")); - return ; - } - QFile rfile(curritem->data(Qt::UserRole).toString()); + QListWidgetItem * curritem = DemosList->currentItem(); + if (!curritem) + { + QMessageBox::critical(this, + tr("Error"), + tr("Please select record from the list"), + tr("OK")); + return ; + } + QFile rfile(curritem->data(Qt::UserRole).toString()); - bool ok; + bool ok; - ok = rfile.remove(); - if(!ok) - QMessageBox::critical(this, tr("Error"), tr("Cannot delete file")); - else - FillFromDir(recType); + ok = rfile.remove(); + if(!ok) + QMessageBox::critical(this, tr("Error"), tr("Cannot delete file")); + else + FillFromDir(recType); } diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/playrecordpage.h --- a/QTfrontend/playrecordpage.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/playrecordpage.h Sat Mar 06 10:59:20 2010 +0000 @@ -28,30 +28,30 @@ class PagePlayDemo : public AbstractPage { - Q_OBJECT + Q_OBJECT public: - enum RecordType { - RT_Demo, - RT_Save - }; + enum RecordType { + RT_Demo, + RT_Save + }; - PagePlayDemo(QWidget* parent = 0); + PagePlayDemo(QWidget* parent = 0); - void FillFromDir(RecordType rectype); + void FillFromDir(RecordType rectype); - QPushButton *BtnBack; - QPushButton *BtnPlayDemo; - QPushButton *BtnRenameRecord; - QPushButton *BtnRemoveRecord; - QListWidget *DemosList; + QPushButton *BtnBack; + QPushButton *BtnPlayDemo; + QPushButton *BtnRenameRecord; + QPushButton *BtnRemoveRecord; + QListWidget *DemosList; private: - RecordType recType; + RecordType recType; private slots: - void renameRecord(); - void removeRecord(); + void renameRecord(); + void removeRecord(); }; diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/predefteams.h --- a/QTfrontend/predefteams.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/predefteams.h Sat Mar 06 10:59:20 2010 +0000 @@ -25,90 +25,90 @@ /* struct PredefinedTeam { - const char * TeamName; - const char * hh0name; - const char * hh1name; - const char * hh2name; - const char * hh3name; - const char * hh4name; - const char * hh5name; - const char * hh6name; - const char * hh7name; - const char * hh0hat; - const char * hh1hat; - const char * hh2hat; - const char * hh3hat; - const char * hh4hat; - const char * hh5hat; - const char * hh6hat; - const char * hh7hat; - QString Grave; - QString Fort; + const char * TeamName; + const char * hh0name; + const char * hh1name; + const char * hh2name; + const char * hh3name; + const char * hh4name; + const char * hh5name; + const char * hh6name; + const char * hh7name; + const char * hh0hat; + const char * hh1hat; + const char * hh2hat; + const char * hh3hat; + const char * hh4hat; + const char * hh5hat; + const char * hh6hat; + const char * hh7hat; + QString Grave; + QString Fort; }; const PredefinedTeam pteams[PREDEFTEAMS_COUNT] = { - { - QT_TRANSLATE_NOOP("teams", "Hedgehogs"), - QT_TRANSLATE_NOOP("teams", "hedgehog 1"), - QT_TRANSLATE_NOOP("teams", "hedgehog 2"), - QT_TRANSLATE_NOOP("teams", "hedgehog 3"), - QT_TRANSLATE_NOOP("teams", "hedgehog 4"), - QT_TRANSLATE_NOOP("teams", "hedgehog 5"), - QT_TRANSLATE_NOOP("teams", "hedgehog 6"), - QT_TRANSLATE_NOOP("teams", "hedgehog 7"), - QT_TRANSLATE_NOOP("teams", "hedgehog 8"), - "NoHat", - "NoHat", - "NoHat", - "NoHat", - "NoHat", - "NoHat", - "NoHat", - "NoHat", - "Simple", "Island" - }, - { - QT_TRANSLATE_NOOP("teams", "Goddess"), - QT_TRANSLATE_NOOP("teams", "Isis"), - QT_TRANSLATE_NOOP("teams", "Astarte"), - QT_TRANSLATE_NOOP("teams", "Diana"), - QT_TRANSLATE_NOOP("teams", "Aphrodite"), - QT_TRANSLATE_NOOP("teams", "Hecate"), - QT_TRANSLATE_NOOP("teams", "Demeter"), - QT_TRANSLATE_NOOP("teams", "Kali"), - QT_TRANSLATE_NOOP("teams", "Inanna"), - "NoHat", - "NoHat", - "NoHat", - "NoHat", - "NoHat", - "NoHat", - "NoHat", - "NoHat", - "Bone", "Island" - }, - { - QT_TRANSLATE_NOOP("teams", "Fruits"), - QT_TRANSLATE_NOOP("teams", "Banana"), - QT_TRANSLATE_NOOP("teams", "Apple"), - QT_TRANSLATE_NOOP("teams", "Orange"), - QT_TRANSLATE_NOOP("teams", "Lemon"), - QT_TRANSLATE_NOOP("teams", "Pineapple"), - QT_TRANSLATE_NOOP("teams", "Mango"), - QT_TRANSLATE_NOOP("teams", "Peach"), - QT_TRANSLATE_NOOP("teams", "Plum"), - "banana", - "apple", - "orange", - "lemon", - "NoHat", - "NoHat", - "NoHat", - "NoHat", - "coffin", "Barrelhouse" - } + { + QT_TRANSLATE_NOOP("teams", "Hedgehogs"), + QT_TRANSLATE_NOOP("teams", "hedgehog 1"), + QT_TRANSLATE_NOOP("teams", "hedgehog 2"), + QT_TRANSLATE_NOOP("teams", "hedgehog 3"), + QT_TRANSLATE_NOOP("teams", "hedgehog 4"), + QT_TRANSLATE_NOOP("teams", "hedgehog 5"), + QT_TRANSLATE_NOOP("teams", "hedgehog 6"), + QT_TRANSLATE_NOOP("teams", "hedgehog 7"), + QT_TRANSLATE_NOOP("teams", "hedgehog 8"), + "NoHat", + "NoHat", + "NoHat", + "NoHat", + "NoHat", + "NoHat", + "NoHat", + "NoHat", + "Simple", "Island" + }, + { + QT_TRANSLATE_NOOP("teams", "Goddess"), + QT_TRANSLATE_NOOP("teams", "Isis"), + QT_TRANSLATE_NOOP("teams", "Astarte"), + QT_TRANSLATE_NOOP("teams", "Diana"), + QT_TRANSLATE_NOOP("teams", "Aphrodite"), + QT_TRANSLATE_NOOP("teams", "Hecate"), + QT_TRANSLATE_NOOP("teams", "Demeter"), + QT_TRANSLATE_NOOP("teams", "Kali"), + QT_TRANSLATE_NOOP("teams", "Inanna"), + "NoHat", + "NoHat", + "NoHat", + "NoHat", + "NoHat", + "NoHat", + "NoHat", + "NoHat", + "Bone", "Island" + }, + { + QT_TRANSLATE_NOOP("teams", "Fruits"), + QT_TRANSLATE_NOOP("teams", "Banana"), + QT_TRANSLATE_NOOP("teams", "Apple"), + QT_TRANSLATE_NOOP("teams", "Orange"), + QT_TRANSLATE_NOOP("teams", "Lemon"), + QT_TRANSLATE_NOOP("teams", "Pineapple"), + QT_TRANSLATE_NOOP("teams", "Mango"), + QT_TRANSLATE_NOOP("teams", "Peach"), + QT_TRANSLATE_NOOP("teams", "Plum"), + "banana", + "apple", + "orange", + "lemon", + "NoHat", + "NoHat", + "NoHat", + "NoHat", + "coffin", "Barrelhouse" + } }; */ #endif // PREDEFTEAMS_H diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/proto.cpp --- a/QTfrontend/proto.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/proto.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -25,25 +25,25 @@ QByteArray & HWProto::addStringToBuffer(QByteArray & buf, const QString & string) { - QByteArray strmsg = string.toUtf8(); - strmsg = strmsg.left(250); - quint8 sz = strmsg.size(); - buf.append(QByteArray((char *)&sz, 1)); - buf.append(strmsg); - return buf; + QByteArray strmsg = string.toUtf8(); + strmsg = strmsg.left(250); + quint8 sz = strmsg.size(); + buf.append(QByteArray((char *)&sz, 1)); + buf.append(strmsg); + return buf; } QByteArray & HWProto::addStringListToBuffer(QByteArray & buf, const QStringList & strList) { - for (int i = 0; i < strList.size(); i++) - addStringToBuffer(buf, strList[i]); - return buf; + for (int i = 0; i < strList.size(); i++) + addStringToBuffer(buf, strList[i]); + return buf; } QString HWProto::formatChatMsg(const QString & nick, const QString & msg) { - if(msg.left(4) == "/me ") - return QString("\x02* %1 %2").arg(nick).arg(msg.mid(4)); - else - return QString("\x01%1: %2").arg(nick).arg(msg); + if(msg.left(4) == "/me ") + return QString("\x02* %1 %2").arg(nick).arg(msg.mid(4)); + else + return QString("\x01%1: %2").arg(nick).arg(msg); } diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/proto.h --- a/QTfrontend/proto.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/proto.h Sat Mar 06 10:59:20 2010 +0000 @@ -26,13 +26,13 @@ class HWProto : public QObject { - Q_OBJECT + Q_OBJECT public: - HWProto(); - static QByteArray & addStringToBuffer(QByteArray & buf, const QString & string); - static QByteArray & addStringListToBuffer(QByteArray & buf, const QStringList & strList); - static QString formatChatMsg(const QString & nick, const QString & msg); + HWProto(); + static QByteArray & addStringToBuffer(QByteArray & buf, const QString & string); + static QByteArray & addStringListToBuffer(QByteArray & buf, const QStringList & strList); + static QString formatChatMsg(const QString & nick, const QString & msg); }; #endif // _PROTO_H diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/sdlkeys.h --- a/QTfrontend/sdlkeys.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/sdlkeys.h Sat Mar 06 10:59:20 2010 +0000 @@ -17,163 +17,163 @@ */ char sdlkeys[1024][2][128] = { - {"mousel", QT_TRANSLATE_NOOP("binds (keys)", "Mouse: Left button")}, - {"mousem", QT_TRANSLATE_NOOP("binds (keys)", "Mouse: Middle button")}, - {"mouser", QT_TRANSLATE_NOOP("binds (keys)", "Mouse: Right button")}, - {"wheelup", QT_TRANSLATE_NOOP("binds (keys)", "Mouse: Wheel up")}, - {"wheeldown", QT_TRANSLATE_NOOP("binds (keys)", "Mouse: Wheel down")}, - {"backspace", QT_TRANSLATE_NOOP("binds (keys)", "Backspace")}, - {"tab", QT_TRANSLATE_NOOP("binds (keys)", "Tab")}, - {"clear", QT_TRANSLATE_NOOP("binds (keys)", "Clear")}, - {"return", QT_TRANSLATE_NOOP("binds (keys)", "Return")}, - {"pause", QT_TRANSLATE_NOOP("binds (keys)", "Pause")}, - {"escape", QT_TRANSLATE_NOOP("binds (keys)", "Escape")}, - {"space", QT_TRANSLATE_NOOP("binds (keys)", "Space")}, - {"!", "!"}, - {"\"", "\""}, - {"#", "#"}, - {"$", "$"}, - {"&", "&"}, - {"'", "'"}, - {"(", "("}, - {")", ")"}, - {"*", "*"}, - {"+", "+"}, - {", ", ", "}, - {"-", "-"}, - {".", "."}, - {"/", "/"}, - {"0", "0"}, - {"1", "1"}, - {"2", "2"}, - {"3", "3"}, - {"4", "4"}, - {"5", "5"}, - {"6", "6"}, - {"7", "7"}, - {"8", "8"}, - {"9", "9"}, - {":", ":"}, - {";", ";"}, - {"<", "<"}, - {"=", "="}, - {">", ">"}, - {"?", "?"}, - {"@", "@"}, - {"[", "["}, - {"\\", "\\"}, - {"]", "]"}, - {"^", "^"}, - {"_", "_"}, - {"`", "`"}, - {"a", "A"}, - {"b", "B"}, - {"c", "C"}, - {"d", "D"}, - {"e", "E"}, - {"f", "F"}, - {"g", "G"}, - {"h", "H"}, - {"i", "I"}, - {"j", "J"}, - {"k", "K"}, - {"l", "L"}, - {"m", "M"}, - {"n", "N"}, - {"o", "O"}, - {"p", "P"}, - {"q", "Q"}, - {"r", "R"}, - {"s", "S"}, - {"t", "T"}, - {"u", "U"}, - {"v", "V"}, - {"w", "W"}, - {"x", "X"}, - {"y", "Y"}, - {"z", "Z"}, - {"delete", QT_TRANSLATE_NOOP("binds (keys)", "Delete")}, - {"[0]", QT_TRANSLATE_NOOP("binds (keys)", "Numpad 0")}, - {"[1]", QT_TRANSLATE_NOOP("binds (keys)", "Numpad 1")}, - {"[2]", QT_TRANSLATE_NOOP("binds (keys)", "Numpad 2")}, - {"[3]", QT_TRANSLATE_NOOP("binds (keys)", "Numpad 3")}, - {"[4]", QT_TRANSLATE_NOOP("binds (keys)", "Numpad 4")}, - {"[5]", QT_TRANSLATE_NOOP("binds (keys)", "Numpad 5")}, - {"[6]", QT_TRANSLATE_NOOP("binds (keys)", "Numpad 6")}, - {"[7]", QT_TRANSLATE_NOOP("binds (keys)", "Numpad 7")}, - {"[8]", QT_TRANSLATE_NOOP("binds (keys)", "Numpad 8")}, - {"[9]", QT_TRANSLATE_NOOP("binds (keys)", "Numpad 9")}, - {"[.]", QT_TRANSLATE_NOOP("binds (keys)", "Numpad .")}, - {"[/]", QT_TRANSLATE_NOOP("binds (keys)", "Numpad /")}, - {"[*]", QT_TRANSLATE_NOOP("binds (keys)", "Numpad *")}, - {"[-]", QT_TRANSLATE_NOOP("binds (keys)", "Numpad -")}, - {"[+]", QT_TRANSLATE_NOOP("binds (keys)", "Numpad +")}, - {"enter", QT_TRANSLATE_NOOP("binds (keys)", "Enter")}, - {"equals", QT_TRANSLATE_NOOP("binds (keys)", "Equals")}, - {"up", QT_TRANSLATE_NOOP("binds (keys)", "Up")}, - {"down", QT_TRANSLATE_NOOP("binds (keys)", "Down")}, - {"right", QT_TRANSLATE_NOOP("binds (keys)", "Right")}, - {"left", QT_TRANSLATE_NOOP("binds (keys)", "Left")}, - {"insert", QT_TRANSLATE_NOOP("binds (keys)", "Insert")}, - {"home", QT_TRANSLATE_NOOP("binds (keys)", "Home")}, - {"end", QT_TRANSLATE_NOOP("binds (keys)", "End")}, - {"page up", QT_TRANSLATE_NOOP("binds (keys)", "Page up")}, - {"page down", QT_TRANSLATE_NOOP("binds (keys)", "Page down")}, - {"f1", "F1"}, - {"f2", "F2"}, - {"f3", "F3"}, - {"f4", "F4"}, - {"f5", "F5"}, - {"f6", "F6"}, - {"f7", "F7"}, - {"f8", "F8"}, - {"f9", "F9"}, - {"f10", "F10"}, - {"f11", "F11"}, - {"f12", "F12"}, - {"f13", "F13"}, - {"f14", "F14"}, - {"f15", "F15"}, - {"numlock", QT_TRANSLATE_NOOP("binds (keys)", "Num lock")}, - {"caps_lock", QT_TRANSLATE_NOOP("binds (keys)", "Caps lock")}, - {"scroll_lock", QT_TRANSLATE_NOOP("binds (keys)", "Scroll lock")}, - {"right_shift", QT_TRANSLATE_NOOP("binds (keys)", "Right shift")}, - {"left_shift", QT_TRANSLATE_NOOP("binds (keys)", "Left shift")}, - {"right_ctrl", QT_TRANSLATE_NOOP("binds (keys)", "Right ctrl")}, - {"left_ctrl", QT_TRANSLATE_NOOP("binds (keys)", "Left ctrl")}, - {"right_alt", QT_TRANSLATE_NOOP("binds (keys)", "Right alt")}, - {"left_alt", QT_TRANSLATE_NOOP("binds (keys)", "Left alt")}, - {"right_meta", QT_TRANSLATE_NOOP("binds (keys)", "Right meta")}, - {"left_meta", QT_TRANSLATE_NOOP("binds (keys)", "Left meta")} - }; + {"mousel", QT_TRANSLATE_NOOP("binds (keys)", "Mouse: Left button")}, + {"mousem", QT_TRANSLATE_NOOP("binds (keys)", "Mouse: Middle button")}, + {"mouser", QT_TRANSLATE_NOOP("binds (keys)", "Mouse: Right button")}, + {"wheelup", QT_TRANSLATE_NOOP("binds (keys)", "Mouse: Wheel up")}, + {"wheeldown", QT_TRANSLATE_NOOP("binds (keys)", "Mouse: Wheel down")}, + {"backspace", QT_TRANSLATE_NOOP("binds (keys)", "Backspace")}, + {"tab", QT_TRANSLATE_NOOP("binds (keys)", "Tab")}, + {"clear", QT_TRANSLATE_NOOP("binds (keys)", "Clear")}, + {"return", QT_TRANSLATE_NOOP("binds (keys)", "Return")}, + {"pause", QT_TRANSLATE_NOOP("binds (keys)", "Pause")}, + {"escape", QT_TRANSLATE_NOOP("binds (keys)", "Escape")}, + {"space", QT_TRANSLATE_NOOP("binds (keys)", "Space")}, + {"!", "!"}, + {"\"", "\""}, + {"#", "#"}, + {"$", "$"}, + {"&", "&"}, + {"'", "'"}, + {"(", "("}, + {")", ")"}, + {"*", "*"}, + {"+", "+"}, + {", ", ", "}, + {"-", "-"}, + {".", "."}, + {"/", "/"}, + {"0", "0"}, + {"1", "1"}, + {"2", "2"}, + {"3", "3"}, + {"4", "4"}, + {"5", "5"}, + {"6", "6"}, + {"7", "7"}, + {"8", "8"}, + {"9", "9"}, + {":", ":"}, + {";", ";"}, + {"<", "<"}, + {"=", "="}, + {">", ">"}, + {"?", "?"}, + {"@", "@"}, + {"[", "["}, + {"\\", "\\"}, + {"]", "]"}, + {"^", "^"}, + {"_", "_"}, + {"`", "`"}, + {"a", "A"}, + {"b", "B"}, + {"c", "C"}, + {"d", "D"}, + {"e", "E"}, + {"f", "F"}, + {"g", "G"}, + {"h", "H"}, + {"i", "I"}, + {"j", "J"}, + {"k", "K"}, + {"l", "L"}, + {"m", "M"}, + {"n", "N"}, + {"o", "O"}, + {"p", "P"}, + {"q", "Q"}, + {"r", "R"}, + {"s", "S"}, + {"t", "T"}, + {"u", "U"}, + {"v", "V"}, + {"w", "W"}, + {"x", "X"}, + {"y", "Y"}, + {"z", "Z"}, + {"delete", QT_TRANSLATE_NOOP("binds (keys)", "Delete")}, + {"[0]", QT_TRANSLATE_NOOP("binds (keys)", "Numpad 0")}, + {"[1]", QT_TRANSLATE_NOOP("binds (keys)", "Numpad 1")}, + {"[2]", QT_TRANSLATE_NOOP("binds (keys)", "Numpad 2")}, + {"[3]", QT_TRANSLATE_NOOP("binds (keys)", "Numpad 3")}, + {"[4]", QT_TRANSLATE_NOOP("binds (keys)", "Numpad 4")}, + {"[5]", QT_TRANSLATE_NOOP("binds (keys)", "Numpad 5")}, + {"[6]", QT_TRANSLATE_NOOP("binds (keys)", "Numpad 6")}, + {"[7]", QT_TRANSLATE_NOOP("binds (keys)", "Numpad 7")}, + {"[8]", QT_TRANSLATE_NOOP("binds (keys)", "Numpad 8")}, + {"[9]", QT_TRANSLATE_NOOP("binds (keys)", "Numpad 9")}, + {"[.]", QT_TRANSLATE_NOOP("binds (keys)", "Numpad .")}, + {"[/]", QT_TRANSLATE_NOOP("binds (keys)", "Numpad /")}, + {"[*]", QT_TRANSLATE_NOOP("binds (keys)", "Numpad *")}, + {"[-]", QT_TRANSLATE_NOOP("binds (keys)", "Numpad -")}, + {"[+]", QT_TRANSLATE_NOOP("binds (keys)", "Numpad +")}, + {"enter", QT_TRANSLATE_NOOP("binds (keys)", "Enter")}, + {"equals", QT_TRANSLATE_NOOP("binds (keys)", "Equals")}, + {"up", QT_TRANSLATE_NOOP("binds (keys)", "Up")}, + {"down", QT_TRANSLATE_NOOP("binds (keys)", "Down")}, + {"right", QT_TRANSLATE_NOOP("binds (keys)", "Right")}, + {"left", QT_TRANSLATE_NOOP("binds (keys)", "Left")}, + {"insert", QT_TRANSLATE_NOOP("binds (keys)", "Insert")}, + {"home", QT_TRANSLATE_NOOP("binds (keys)", "Home")}, + {"end", QT_TRANSLATE_NOOP("binds (keys)", "End")}, + {"page up", QT_TRANSLATE_NOOP("binds (keys)", "Page up")}, + {"page down", QT_TRANSLATE_NOOP("binds (keys)", "Page down")}, + {"f1", "F1"}, + {"f2", "F2"}, + {"f3", "F3"}, + {"f4", "F4"}, + {"f5", "F5"}, + {"f6", "F6"}, + {"f7", "F7"}, + {"f8", "F8"}, + {"f9", "F9"}, + {"f10", "F10"}, + {"f11", "F11"}, + {"f12", "F12"}, + {"f13", "F13"}, + {"f14", "F14"}, + {"f15", "F15"}, + {"numlock", QT_TRANSLATE_NOOP("binds (keys)", "Num lock")}, + {"caps_lock", QT_TRANSLATE_NOOP("binds (keys)", "Caps lock")}, + {"scroll_lock", QT_TRANSLATE_NOOP("binds (keys)", "Scroll lock")}, + {"right_shift", QT_TRANSLATE_NOOP("binds (keys)", "Right shift")}, + {"left_shift", QT_TRANSLATE_NOOP("binds (keys)", "Left shift")}, + {"right_ctrl", QT_TRANSLATE_NOOP("binds (keys)", "Right ctrl")}, + {"left_ctrl", QT_TRANSLATE_NOOP("binds (keys)", "Left ctrl")}, + {"right_alt", QT_TRANSLATE_NOOP("binds (keys)", "Right alt")}, + {"left_alt", QT_TRANSLATE_NOOP("binds (keys)", "Left alt")}, + {"right_meta", QT_TRANSLATE_NOOP("binds (keys)", "Right meta")}, + {"left_meta", QT_TRANSLATE_NOOP("binds (keys)", "Left meta")} + }; // button name definitions for Microsoft's XBox360 controller // don't modify button order! char xb360buttons[][128] = { - QT_TRANSLATE_NOOP("binds (keys)", "A button"), - QT_TRANSLATE_NOOP("binds (keys)", "B button"), - QT_TRANSLATE_NOOP("binds (keys)", "X button"), - QT_TRANSLATE_NOOP("binds (keys)", "Y button"), - QT_TRANSLATE_NOOP("binds (keys)", "LB button"), - QT_TRANSLATE_NOOP("binds (keys)", "RB button"), - QT_TRANSLATE_NOOP("binds (keys)", "Back button"), - QT_TRANSLATE_NOOP("binds (keys)", "Start button"), - QT_TRANSLATE_NOOP("binds (keys)", "Left stick"), - QT_TRANSLATE_NOOP("binds (keys)", "Right stick") + QT_TRANSLATE_NOOP("binds (keys)", "A button"), + QT_TRANSLATE_NOOP("binds (keys)", "B button"), + QT_TRANSLATE_NOOP("binds (keys)", "X button"), + QT_TRANSLATE_NOOP("binds (keys)", "Y button"), + QT_TRANSLATE_NOOP("binds (keys)", "LB button"), + QT_TRANSLATE_NOOP("binds (keys)", "RB button"), + QT_TRANSLATE_NOOP("binds (keys)", "Back button"), + QT_TRANSLATE_NOOP("binds (keys)", "Start button"), + QT_TRANSLATE_NOOP("binds (keys)", "Left stick"), + QT_TRANSLATE_NOOP("binds (keys)", "Right stick") }; // axis name definitions for Microsoft's XBox360 controller // don't modify axis order! char xbox360axes[][128] = { - QT_TRANSLATE_NOOP("binds (keys)", "Left stick (Right)"), - QT_TRANSLATE_NOOP("binds (keys)", "Left stick (Left)"), - QT_TRANSLATE_NOOP("binds (keys)", "Left stick (Down)"), - QT_TRANSLATE_NOOP("binds (keys)", "Left stick (Up)"), - QT_TRANSLATE_NOOP("binds (keys)", "Left trigger"), - QT_TRANSLATE_NOOP("binds (keys)", "Right trigger"), - QT_TRANSLATE_NOOP("binds (keys)", "Right stick (Down)"), - QT_TRANSLATE_NOOP("binds (keys)", "Right stick (Up)"), - QT_TRANSLATE_NOOP("binds (keys)", "Right stick (Right)"), - QT_TRANSLATE_NOOP("binds (keys)", "Right stick (Left)"), + QT_TRANSLATE_NOOP("binds (keys)", "Left stick (Right)"), + QT_TRANSLATE_NOOP("binds (keys)", "Left stick (Left)"), + QT_TRANSLATE_NOOP("binds (keys)", "Left stick (Down)"), + QT_TRANSLATE_NOOP("binds (keys)", "Left stick (Up)"), + QT_TRANSLATE_NOOP("binds (keys)", "Left trigger"), + QT_TRANSLATE_NOOP("binds (keys)", "Right trigger"), + QT_TRANSLATE_NOOP("binds (keys)", "Right stick (Down)"), + QT_TRANSLATE_NOOP("binds (keys)", "Right stick (Up)"), + QT_TRANSLATE_NOOP("binds (keys)", "Right stick (Right)"), + QT_TRANSLATE_NOOP("binds (keys)", "Right stick (Left)"), }; char xb360dpad[128] = QT_TRANSLATE_NOOP("binds (keys)", "DPad"); diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/selectWeapon.cpp --- a/QTfrontend/selectWeapon.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/selectWeapon.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -33,214 +33,214 @@ QImage getAmmoImage(int num) { - static QImage ammo(":Ammos.png"); + static QImage ammo(":Ammos.png"); int x = floor(num/(ammo.height()/32)); int y = (num-((ammo.height()/32)*x))*32; x*=32; - return ammo.copy(x, y, 32, 32); + return ammo.copy(x, y, 32, 32); } SelWeaponItem::SelWeaponItem(bool allowInfinite, int iconNum, int wNum, QImage image, QWidget* parent) : - QWidget(parent) + QWidget(parent) { - QHBoxLayout* hbLayout = new QHBoxLayout(this); - hbLayout->setSpacing(1); - hbLayout->setMargin(1); + QHBoxLayout* hbLayout = new QHBoxLayout(this); + hbLayout->setSpacing(1); + hbLayout->setMargin(1); - QLabel* lbl = new QLabel(this); - lbl->setPixmap(QPixmap::fromImage(getAmmoImage(iconNum))); - lbl->setMaximumWidth(30); - lbl->setGeometry(0, 0, 30, 30); - hbLayout->addWidget(lbl); + QLabel* lbl = new QLabel(this); + lbl->setPixmap(QPixmap::fromImage(getAmmoImage(iconNum))); + lbl->setMaximumWidth(30); + lbl->setGeometry(0, 0, 30, 30); + hbLayout->addWidget(lbl); - item = new WeaponItem(image, this); - item->setItemsNum(wNum); - item->setInfinityState(allowInfinite); - hbLayout->addWidget(item); + item = new WeaponItem(image, this); + item->setItemsNum(wNum); + item->setInfinityState(allowInfinite); + hbLayout->addWidget(item); - hbLayout->setStretchFactor(lbl, 1); - hbLayout->setStretchFactor(item, 99); - hbLayout->setAlignment(lbl, Qt::AlignLeft | Qt::AlignVCenter); - hbLayout->setAlignment(item, Qt::AlignLeft | Qt::AlignVCenter); + hbLayout->setStretchFactor(lbl, 1); + hbLayout->setStretchFactor(item, 99); + hbLayout->setAlignment(lbl, Qt::AlignLeft | Qt::AlignVCenter); + hbLayout->setAlignment(item, Qt::AlignLeft | Qt::AlignVCenter); } void SelWeaponItem::setItemsNum(const unsigned char num) { - item->setItemsNum(num); + item->setItemsNum(num); } unsigned char SelWeaponItem::getItemsNum() const { - return item->getItemsNum(); + return item->getItemsNum(); } SelWeaponWidget::SelWeaponWidget(int numItems, QWidget* parent) : QFrame(parent), m_numItems(numItems) { - wconf = new QSettings(cfgdir->absolutePath() + "/weapons.ini", QSettings::IniFormat, this); + wconf = new QSettings(cfgdir->absolutePath() + "/weapons.ini", QSettings::IniFormat, this); - for(int i = 0; i < cDefaultAmmos.size(); ++i) - wconf->setValue(cDefaultAmmos[i].first, cDefaultAmmos[i].second); + for(int i = 0; i < cDefaultAmmos.size(); ++i) + wconf->setValue(cDefaultAmmos[i].first, cDefaultAmmos[i].second); - QStringList keys = wconf->allKeys(); - for(int i = 0; i < keys.size(); i++) - { - if (wconf->value(keys[i]).toString().size() != cDefaultAmmoStore->size()) - wconf->remove(keys[i]); - } + QStringList keys = wconf->allKeys(); + for(int i = 0; i < keys.size(); i++) + { + if (wconf->value(keys[i]).toString().size() != cDefaultAmmoStore->size()) + wconf->remove(keys[i]); + } - QString currentState = *cDefaultAmmoStore; + QString currentState = *cDefaultAmmoStore; - QTabWidget * tbw = new QTabWidget(this); - QWidget * page1 = new QWidget(this); - p1Layout = new QGridLayout(page1); - p1Layout->setSpacing(1); - p1Layout->setMargin(1); - QWidget * page2 = new QWidget(this); - p2Layout = new QGridLayout(page2); - p2Layout->setSpacing(1); - p2Layout->setMargin(1); - QWidget * page3 = new QWidget(this); - p3Layout = new QGridLayout(page3); - p3Layout->setSpacing(1); - p3Layout->setMargin(1); - QWidget * page4 = new QWidget(this); - p4Layout = new QGridLayout(page4); - p4Layout->setSpacing(1); - p4Layout->setMargin(1); + QTabWidget * tbw = new QTabWidget(this); + QWidget * page1 = new QWidget(this); + p1Layout = new QGridLayout(page1); + p1Layout->setSpacing(1); + p1Layout->setMargin(1); + QWidget * page2 = new QWidget(this); + p2Layout = new QGridLayout(page2); + p2Layout->setSpacing(1); + p2Layout->setMargin(1); + QWidget * page3 = new QWidget(this); + p3Layout = new QGridLayout(page3); + p3Layout->setSpacing(1); + p3Layout->setMargin(1); + QWidget * page4 = new QWidget(this); + p4Layout = new QGridLayout(page4); + p4Layout->setSpacing(1); + p4Layout->setMargin(1); - tbw->addTab(page1, tr("Weapon set")); - tbw->addTab(page2, tr("Probabilities")); - tbw->addTab(page4, tr("Ammo in boxes")); - tbw->addTab(page3, tr("Delays")); + tbw->addTab(page1, tr("Weapon set")); + tbw->addTab(page2, tr("Probabilities")); + tbw->addTab(page4, tr("Ammo in boxes")); + tbw->addTab(page3, tr("Delays")); - QGridLayout * pageLayout = new QGridLayout(this); - pageLayout->addWidget(tbw); + QGridLayout * pageLayout = new QGridLayout(this); + pageLayout->addWidget(tbw); - int j = -1; - int i = 0, k = 0; - for(; i < m_numItems; ++i) { - if (i == 6) continue; - if (k % 4 == 0) ++j; - SelWeaponItem * swi = new SelWeaponItem(true, i, currentState[i].digitValue(), QImage(":/res/ammopic.png"), this); - weaponItems[i].append(swi); - p1Layout->addWidget(swi, j, k % 4); + int j = -1; + int i = 0, k = 0; + for(; i < m_numItems; ++i) { + if (i == 6) continue; + if (k % 4 == 0) ++j; + SelWeaponItem * swi = new SelWeaponItem(true, i, currentState[i].digitValue(), QImage(":/res/ammopic.png"), this); + weaponItems[i].append(swi); + p1Layout->addWidget(swi, j, k % 4); - SelWeaponItem * pwi = new SelWeaponItem(false, i, currentState[numItems + i].digitValue(), QImage(":/res/ammopicbox.png"), this); - weaponItems[i].append(pwi); - p2Layout->addWidget(pwi, j, k % 4); - - SelWeaponItem * dwi = new SelWeaponItem(false, i, currentState[numItems*2 + i].digitValue(), QImage(":/res/ammopicdelay.png"), this); - weaponItems[i].append(dwi); - p3Layout->addWidget(dwi, j, k % 4); - - SelWeaponItem * awi = new SelWeaponItem(false, i, currentState[numItems*3 + i].digitValue(), QImage(":/res/ammopic.png"), this); - weaponItems[i].append(awi); - p4Layout->addWidget(awi, j, k % 4); + SelWeaponItem * pwi = new SelWeaponItem(false, i, currentState[numItems + i].digitValue(), QImage(":/res/ammopicbox.png"), this); + weaponItems[i].append(pwi); + p2Layout->addWidget(pwi, j, k % 4); + + SelWeaponItem * dwi = new SelWeaponItem(false, i, currentState[numItems*2 + i].digitValue(), QImage(":/res/ammopicdelay.png"), this); + weaponItems[i].append(dwi); + p3Layout->addWidget(dwi, j, k % 4); + + SelWeaponItem * awi = new SelWeaponItem(false, i, currentState[numItems*3 + i].digitValue(), QImage(":/res/ammopic.png"), this); + weaponItems[i].append(awi); + p4Layout->addWidget(awi, j, k % 4); - ++k; - } + ++k; + } - //pLayout->setRowStretch(5, 100); - m_name = new QLineEdit(this); - pageLayout->addWidget(m_name, i, 0, 1, 5); + //pLayout->setRowStretch(5, 100); + m_name = new QLineEdit(this); + pageLayout->addWidget(m_name, i, 0, 1, 5); } void SelWeaponWidget::setWeapons(const QString& ammo) { - for(int i = 0; i < m_numItems; ++i) { - twi::iterator it = weaponItems.find(i); - if (it == weaponItems.end()) continue; - it.value()[0]->setItemsNum(ammo[i].digitValue()); - it.value()[1]->setItemsNum(ammo[m_numItems + i].digitValue()); - it.value()[2]->setItemsNum(ammo[m_numItems*2 + i].digitValue()); - it.value()[3]->setItemsNum(ammo[m_numItems*3 + i].digitValue()); - } - update(); + for(int i = 0; i < m_numItems; ++i) { + twi::iterator it = weaponItems.find(i); + if (it == weaponItems.end()) continue; + it.value()[0]->setItemsNum(ammo[i].digitValue()); + it.value()[1]->setItemsNum(ammo[m_numItems + i].digitValue()); + it.value()[2]->setItemsNum(ammo[m_numItems*2 + i].digitValue()); + it.value()[3]->setItemsNum(ammo[m_numItems*3 + i].digitValue()); + } + update(); } void SelWeaponWidget::setDefault() { - setWeapons(*cDefaultAmmoStore); + setWeapons(*cDefaultAmmoStore); } void SelWeaponWidget::save() { - if (m_name->text() == "Default") { - QMessageBox impossible(QMessageBox::Warning, QMessageBox::tr("Weapons"), QMessageBox::tr("Can not edit default weapon set")); - impossible.exec(); - return; - } + if (m_name->text() == "Default") { + QMessageBox impossible(QMessageBox::Warning, QMessageBox::tr("Weapons"), QMessageBox::tr("Can not edit default weapon set")); + impossible.exec(); + return; + } - if (m_name->text() == "") return; + if (m_name->text() == "") return; - QString state1; - QString state2; - QString state3; - QString state4; + QString state1; + QString state2; + QString state3; + QString state4; - for(int i = 0; i < m_numItems; ++i) { - twi::const_iterator it = weaponItems.find(i); - int num = it == weaponItems.end() ? 9 : it.value()[0]->getItemsNum(); // 9 is for 'skip turn' - state1.append(QString::number(num)); - int prob = it == weaponItems.end() ? 0 : it.value()[1]->getItemsNum(); - state2.append(QString::number(prob)); - int del = it == weaponItems.end() ? 0 : it.value()[2]->getItemsNum(); - state3.append(QString::number(del)); - int am = it == weaponItems.end() ? 0 : it.value()[3]->getItemsNum(); - state4.append(QString::number(am)); - } - if (curWeaponsName != "") { - // remove old entry - wconf->remove(curWeaponsName); - } - wconf->setValue(m_name->text(), state1 + state2 + state3 + state4); - emit weaponsChanged(); + for(int i = 0; i < m_numItems; ++i) { + twi::const_iterator it = weaponItems.find(i); + int num = it == weaponItems.end() ? 9 : it.value()[0]->getItemsNum(); // 9 is for 'skip turn' + state1.append(QString::number(num)); + int prob = it == weaponItems.end() ? 0 : it.value()[1]->getItemsNum(); + state2.append(QString::number(prob)); + int del = it == weaponItems.end() ? 0 : it.value()[2]->getItemsNum(); + state3.append(QString::number(del)); + int am = it == weaponItems.end() ? 0 : it.value()[3]->getItemsNum(); + state4.append(QString::number(am)); + } + if (curWeaponsName != "") { + // remove old entry + wconf->remove(curWeaponsName); + } + wconf->setValue(m_name->text(), state1 + state2 + state3 + state4); + emit weaponsChanged(); } int SelWeaponWidget::operator [] (unsigned int weaponIndex) const { - twi::const_iterator it = weaponItems.find(weaponIndex); - return it == weaponItems.end() ? 9 : it.value()[0]->getItemsNum(); + twi::const_iterator it = weaponItems.find(weaponIndex); + return it == weaponItems.end() ? 9 : it.value()[0]->getItemsNum(); } QString SelWeaponWidget::getWeaponsString(const QString& name) const { - return wconf->value(name).toString(); + return wconf->value(name).toString(); } void SelWeaponWidget::deleteWeaponsName() { - if (curWeaponsName == "") return; + if (curWeaponsName == "") return; - if (curWeaponsName == "Default") { - QMessageBox impossible(QMessageBox::Warning, QMessageBox::tr("Weapons"), QMessageBox::tr("Can not delete default weapon set")); - impossible.exec(); - return; - } + if (curWeaponsName == "Default") { + QMessageBox impossible(QMessageBox::Warning, QMessageBox::tr("Weapons"), QMessageBox::tr("Can not delete default weapon set")); + impossible.exec(); + return; + } - QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Weapons"), QMessageBox::tr("Really delete this weapon set?"), QMessageBox::Ok | QMessageBox::Cancel); + QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Weapons"), QMessageBox::tr("Really delete this weapon set?"), QMessageBox::Ok | QMessageBox::Cancel); - if (reallyDelete.exec() == QMessageBox::Ok) { - wconf->remove(curWeaponsName); - emit weaponsDeleted(); - } + if (reallyDelete.exec() == QMessageBox::Ok) { + wconf->remove(curWeaponsName); + emit weaponsDeleted(); + } } void SelWeaponWidget::setWeaponsName(const QString& name) { - if(name != "" && wconf->contains(name)) { - setWeapons(wconf->value(name).toString()); - } + if(name != "" && wconf->contains(name)) { + setWeapons(wconf->value(name).toString()); + } - curWeaponsName = name; + curWeaponsName = name; - m_name->setText(name); + m_name->setText(name); } QStringList SelWeaponWidget::getWeaponNames() const { - return wconf->allKeys(); + return wconf->allKeys(); } diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/statsPage.cpp --- a/QTfrontend/statsPage.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/statsPage.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -29,99 +29,99 @@ void FitGraphicsView::resizeEvent(QResizeEvent * event) { - fitInView(sceneRect()); + fitInView(sceneRect()); } PageGameStats::PageGameStats(QWidget* parent) : AbstractPage(parent) { - QGridLayout * pageLayout = new QGridLayout(this); - pageLayout->setColumnStretch(0, 1); - pageLayout->setColumnStretch(1, 1); - pageLayout->setColumnStretch(2, 1); + QGridLayout * pageLayout = new QGridLayout(this); + pageLayout->setColumnStretch(0, 1); + pageLayout->setColumnStretch(1, 1); + pageLayout->setColumnStretch(2, 1); - BtnBack = addButton(":/res/Exit.png", pageLayout, 2, 0, true); + BtnBack = addButton(":/res/Exit.png", pageLayout, 2, 0, true); - labelGameStats = new QLabel(this); - labelGameStats->setTextFormat(Qt::RichText); - pageLayout->addWidget(labelGameStats, 0, 0, 1, 3); + labelGameStats = new QLabel(this); + labelGameStats->setTextFormat(Qt::RichText); + pageLayout->addWidget(labelGameStats, 0, 0, 1, 3); - graphic = new FitGraphicsView(this); - graphic->scale(1.0, -1.0); - graphic->setBackgroundBrush(QBrush(Qt::black)); - pageLayout->addWidget(graphic, 1, 0, 1, 3); + graphic = new FitGraphicsView(this); + graphic->scale(1.0, -1.0); + graphic->setBackgroundBrush(QBrush(Qt::black)); + pageLayout->addWidget(graphic, 1, 0, 1, 3); } void PageGameStats::AddStatText(const QString & msg) { - labelGameStats->setText(labelGameStats->text() + msg); + labelGameStats->setText(labelGameStats->text() + msg); } void PageGameStats::clear() { - labelGameStats->setText(""); - healthPoints.clear(); + labelGameStats->setText(""); + healthPoints.clear(); } void PageGameStats::renderStats() { - QGraphicsScene * scene = new QGraphicsScene(); + QGraphicsScene * scene = new QGraphicsScene(); - QMap >::const_iterator i = healthPoints.constBegin(); - while (i != healthPoints.constEnd()) - { - quint32 c = i.key(); - QColor clanColor = QColor(qRgb((c >> 16) & 255, (c >> 8) & 255, c & 255)); - QVector hps = i.value(); + QMap >::const_iterator i = healthPoints.constBegin(); + while (i != healthPoints.constEnd()) + { + quint32 c = i.key(); + QColor clanColor = QColor(qRgb((c >> 16) & 255, (c >> 8) & 255, c & 255)); + QVector hps = i.value(); - QPainterPath path; - if (hps.size()) - path.moveTo(0, hps[0]); + QPainterPath path; + if (hps.size()) + path.moveTo(0, hps[0]); - for(int t = 1; t < hps.size(); ++t) - path.lineTo(t, hps[t]); + for(int t = 1; t < hps.size(); ++t) + path.lineTo(t, hps[t]); - scene->addPath(path, QPen(c)); - ++i; - } + scene->addPath(path, QPen(c)); + ++i; + } - graphic->setScene(scene); - graphic->fitInView(graphic->sceneRect()); + graphic->setScene(scene); + graphic->fitInView(graphic->sceneRect()); } void PageGameStats::GameStats(char type, const QString & info) { - switch(type) { - case 'r' : { - AddStatText(QString("

%1

").arg(info)); - break; - } - case 'D' : { - int i = info.indexOf(' '); - QString message = PageGameStats::tr("

The best shot award was won by %1 with %2 pts.

") - .arg(info.mid(i + 1), info.left(i)); - AddStatText(message); - break; - } - case 'k' : { - int i = info.indexOf(' '); - int num = info.left(i).toInt(); - QString message = PageGameStats::tr("

The best killer is %1 with %2 kills in a turn.

", "", num) - .arg(info.mid(i + 1), info.left(i)); - AddStatText(message); - break; - } - case 'K' : { - int num = info.toInt(); - QString message = PageGameStats::tr("

A total of %1 hedgehog(s) were killed during this round.

", "", num).arg(num); - AddStatText(message); - break; - } - case 'H' : { - int i = info.indexOf(' '); - quint32 clan = info.left(i).toInt(); - quint32 hp = info.mid(i + 1).toUInt(); - healthPoints[clan].append(hp); - break; - } - } + switch(type) { + case 'r' : { + AddStatText(QString("

%1

").arg(info)); + break; + } + case 'D' : { + int i = info.indexOf(' '); + QString message = PageGameStats::tr("

The best shot award was won by %1 with %2 pts.

") + .arg(info.mid(i + 1), info.left(i)); + AddStatText(message); + break; + } + case 'k' : { + int i = info.indexOf(' '); + int num = info.left(i).toInt(); + QString message = PageGameStats::tr("

The best killer is %1 with %2 kills in a turn.

", "", num) + .arg(info.mid(i + 1), info.left(i)); + AddStatText(message); + break; + } + case 'K' : { + int num = info.toInt(); + QString message = PageGameStats::tr("

A total of %1 hedgehog(s) were killed during this round.

", "", num).arg(num); + AddStatText(message); + break; + } + case 'H' : { + int i = info.indexOf(' '); + quint32 clan = info.left(i).toInt(); + quint32 hp = info.mid(i + 1).toUInt(); + healthPoints[clan].append(hp); + break; + } + } } diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/statsPage.h --- a/QTfrontend/statsPage.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/statsPage.h Sat Mar 06 10:59:20 2010 +0000 @@ -26,35 +26,35 @@ class FitGraphicsView : public QGraphicsView { - Q_OBJECT + Q_OBJECT public: - FitGraphicsView(QWidget* parent = 0); + FitGraphicsView(QWidget* parent = 0); protected: - void resizeEvent(QResizeEvent * event); + void resizeEvent(QResizeEvent * event); }; class PageGameStats : public AbstractPage { - Q_OBJECT + Q_OBJECT public: - PageGameStats(QWidget* parent = 0); + PageGameStats(QWidget* parent = 0); - QPushButton *BtnBack; - QLabel *labelGameStats; - FitGraphicsView * graphic; + QPushButton *BtnBack; + QLabel *labelGameStats; + FitGraphicsView * graphic; public slots: - void GameStats(char type, const QString & info); - void clear(); - void renderStats(); + void GameStats(char type, const QString & info); + void clear(); + void renderStats(); private: - void AddStatText(const QString & msg); + void AddStatText(const QString & msg); - QMap > healthPoints; + QMap > healthPoints; }; #endif // STATSPAGE_H diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/tcpBase.cpp --- a/QTfrontend/tcpBase.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/tcpBase.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -41,8 +41,8 @@ IPCServer->setMaxPendingConnections(1); if (!IPCServer->listen(QHostAddress::LocalHost)) { QMessageBox::critical(0, tr("Error"), - tr("Unable to start the server: %1.") - .arg(IPCServer->errorString())); + tr("Unable to start the server: %1.") + .arg(IPCServer->errorString())); exit(0); // FIXME - should be graceful exit here } } @@ -97,8 +97,8 @@ void TCPBase::StartProcessError(QProcess::ProcessError error) { QMessageBox::critical(0, tr("Error"), - tr("Unable to run engine: %1 (") - .arg(error) + bindir->absolutePath() + "/hwengine)"); + tr("Unable to run engine: %1 (") + .arg(error) + bindir->absolutePath() + "/hwengine)"); } void TCPBase::tcpServerReady() @@ -135,27 +135,27 @@ void TCPBase::SendIPC(const QByteArray & buf) { - if (buf.size() > MAXMSGCHARS) return; - quint8 len = buf.size(); - RawSendIPC(QByteArray::fromRawData((char *)&len, 1) + buf); + if (buf.size() > MAXMSGCHARS) return; + quint8 len = buf.size(); + RawSendIPC(QByteArray::fromRawData((char *)&len, 1) + buf); } void TCPBase::RawSendIPC(const QByteArray & buf) { - if (!IPCSocket) - { - toSendBuf += buf; - } else - { - if (toSendBuf.size() > 0) - { - IPCSocket->write(toSendBuf); - if(m_isDemoMode) demo.append(toSendBuf); - toSendBuf.clear(); - } - if(!buf.isEmpty()) { - IPCSocket->write(buf); - if(m_isDemoMode) demo.append(buf); - } - } + if (!IPCSocket) + { + toSendBuf += buf; + } else + { + if (toSendBuf.size() > 0) + { + IPCSocket->write(toSendBuf); + if(m_isDemoMode) demo.append(toSendBuf); + toSendBuf.clear(); + } + if(!buf.isEmpty()) { + IPCSocket->write(buf); + if(m_isDemoMode) demo.append(buf); + } + } } diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/team.cpp --- a/QTfrontend/team.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/team.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -29,49 +29,49 @@ #include "hats.h" HWTeam::HWTeam(const QString & teamname) : - difficulty(0), - numHedgehogs(4), - m_isNetTeam(false) + difficulty(0), + numHedgehogs(4), + m_isNetTeam(false) { - TeamName = teamname; - OldTeamName = TeamName; - for (int i = 0; i < 8; i++) - { - HHName[i].sprintf("hedgehog %d", i); - HHHat[i] = "NoHat"; - } - Grave = "Statue"; - Fort = "Plane"; - Voicepack = "Default"; - Flag = "hedgewars"; - for(int i = 0; i < BINDS_NUMBER; i++) - { - binds[i].action = cbinds[i].action; - binds[i].strbind = cbinds[i].strbind; - } + TeamName = teamname; + OldTeamName = TeamName; + for (int i = 0; i < 8; i++) + { + HHName[i].sprintf("hedgehog %d", i); + HHHat[i] = "NoHat"; + } + Grave = "Statue"; + Fort = "Plane"; + Voicepack = "Default"; + Flag = "hedgewars"; + for(int i = 0; i < BINDS_NUMBER; i++) + { + binds[i].action = cbinds[i].action; + binds[i].strbind = cbinds[i].strbind; + } } HWTeam::HWTeam(const QStringList& strLst) : numHedgehogs(4), m_isNetTeam(true) { - // net teams are configured from QStringList - if(strLst.size() != 23) throw HWTeamConstructException(); - TeamName = strLst[0]; - Grave = strLst[1]; - Fort = strLst[2]; - Voicepack = strLst[3]; - Flag = strLst[4]; - Owner = strLst[5]; - difficulty = strLst[6].toUInt(); - for(int i = 0; i < 8; i++) - { - HHName[i]=strLst[i * 2 + 7]; - HHHat[i]=strLst[i * 2 + 8]; + // net teams are configured from QStringList + if(strLst.size() != 23) throw HWTeamConstructException(); + TeamName = strLst[0]; + Grave = strLst[1]; + Fort = strLst[2]; + Voicepack = strLst[3]; + Flag = strLst[4]; + Owner = strLst[5]; + difficulty = strLst[6].toUInt(); + for(int i = 0; i < 8; i++) + { + HHName[i]=strLst[i * 2 + 7]; + HHHat[i]=strLst[i * 2 + 8]; // Somehow claymore managed an empty hat. Until we figure out how, this should avoid a repeat // Checking net teams is probably pointless, but can't hurt. if (HHHat[i].length() == 0) HHHat[i] = "NoHat"; - } + } } HWTeam::HWTeam() : @@ -79,217 +79,217 @@ numHedgehogs(4), m_isNetTeam(false) { - TeamName = QString("Team"); - for (int i = 0; i < 8; i++) - { - HHName[i].sprintf("hedgehog %d", i); - HHHat[i] = "NoHat"; - } + TeamName = QString("Team"); + for (int i = 0; i < 8; i++) + { + HHName[i].sprintf("hedgehog %d", i); + HHHat[i] = "NoHat"; + } - Grave = QString("Simple"); // default - Fort = QString("Island"); // default - Voicepack = "Default"; - Flag = "hedgewars"; + Grave = QString("Simple"); // default + Fort = QString("Island"); // default + Voicepack = "Default"; + Flag = "hedgewars"; - for(int i = 0; i < BINDS_NUMBER; i++) - { - binds[i].action = cbinds[i].action; - binds[i].strbind = cbinds[i].strbind; - } + for(int i = 0; i < BINDS_NUMBER; i++) + { + binds[i].action = cbinds[i].action; + binds[i].strbind = cbinds[i].strbind; + } } bool HWTeam::LoadFromFile() { - numHedgehogs=4; - QFile cfgfile(cfgdir->absolutePath() + "/" + TeamName + ".cfg"); - if (!cfgfile.open(QIODevice::ReadOnly)) return false; - QTextStream stream(&cfgfile); - stream.setCodec("UTF-8"); - QString str; - QString action; + numHedgehogs=4; + QFile cfgfile(cfgdir->absolutePath() + "/" + TeamName + ".cfg"); + if (!cfgfile.open(QIODevice::ReadOnly)) return false; + QTextStream stream(&cfgfile); + stream.setCodec("UTF-8"); + QString str; + QString action; - while (!stream.atEnd()) - { - str = stream.readLine(); - if (str.startsWith(";")) continue; - /*if (str.startsWith("name team ")) - { - str.remove(0, 10); - TeamName = str; - } else*/ - if (str.startsWith("name hh")) - { - str.remove(0, 7); - long i = str.left(1).toLong(); - if ((i < 0) || (i > 7)) continue; - str.remove(0, 2); - HHName[i] = str; - } else - if (str.startsWith("hat")) - { - str.remove(0, 3); - long i = str.left(1).toLong(); - if ((i < 0) || (i > 7)) continue; - str.remove(0, 2); - HHHat[i] = str; + while (!stream.atEnd()) + { + str = stream.readLine(); + if (str.startsWith(";")) continue; + /*if (str.startsWith("name team ")) + { + str.remove(0, 10); + TeamName = str; + } else*/ + if (str.startsWith("name hh")) + { + str.remove(0, 7); + long i = str.left(1).toLong(); + if ((i < 0) || (i > 7)) continue; + str.remove(0, 2); + HHName[i] = str; + } else + if (str.startsWith("hat")) + { + str.remove(0, 3); + long i = str.left(1).toLong(); + if ((i < 0) || (i > 7)) continue; + str.remove(0, 2); + HHHat[i] = str; // Somehow claymore managed an empty hat. Until we figure out how, this should avoid a repeat if (HHHat[i].length() == 0) HHHat[i] = "NoHat"; - } else - if (str.startsWith("grave ")) - { - str.remove(0, 6); - Grave = str; - } else - if (str.startsWith("fort ")) - { - str.remove(0, 5); - Fort = str; - } else - if (str.startsWith("flag ")) - { - str.remove(0, 5); - Flag = str; - } else - if (str.startsWith("voicepack ")) - { - str.remove(0, 10); - Voicepack = str; - } else - if (str.startsWith("bind ")) - { - str.remove(0, 5); - action = str.section(' ', 1); - str = str.section(' ', 0, 0); - str.truncate(15); - for (int i = 0; i < BINDS_NUMBER; i++) - if (action == binds[i].action) - { - binds[i].strbind = str; - break; - } - } else - if (str.startsWith("difficulty ")) - { - str.remove(0, 11); - difficulty=str.toUInt(); - if (difficulty>5) difficulty=0; // this shouldn't normally happen - } - } - cfgfile.close(); - return true; + } else + if (str.startsWith("grave ")) + { + str.remove(0, 6); + Grave = str; + } else + if (str.startsWith("fort ")) + { + str.remove(0, 5); + Fort = str; + } else + if (str.startsWith("flag ")) + { + str.remove(0, 5); + Flag = str; + } else + if (str.startsWith("voicepack ")) + { + str.remove(0, 10); + Voicepack = str; + } else + if (str.startsWith("bind ")) + { + str.remove(0, 5); + action = str.section(' ', 1); + str = str.section(' ', 0, 0); + str.truncate(15); + for (int i = 0; i < BINDS_NUMBER; i++) + if (action == binds[i].action) + { + binds[i].strbind = str; + break; + } + } else + if (str.startsWith("difficulty ")) + { + str.remove(0, 11); + difficulty=str.toUInt(); + if (difficulty>5) difficulty=0; // this shouldn't normally happen + } + } + cfgfile.close(); + return true; } bool HWTeam::SaveToFile() { - if (OldTeamName != TeamName) - { - QFile cfgfile(cfgdir->absolutePath() + "/" + OldTeamName + ".cfg"); - cfgfile.remove(); - OldTeamName = TeamName; - } - QFile cfgfile(cfgdir->absolutePath() + "/" + TeamName + ".cfg"); - if (!cfgfile.open(QIODevice::WriteOnly)) return false; - QTextStream stream(&cfgfile); - stream.setCodec("UTF-8"); - stream << "; Generated by Hedgewars, do not modify" << endl; - stream << "name team " << TeamName << endl; - for (int i = 0; i < 8; i++) - { - stream << "name hh" << i << " " << HHName[i] << endl; - stream << "hat" << i << " " << HHHat[i] << endl; - } - stream << "grave " << Grave << endl; - stream << "fort " << Fort << endl; - stream << "voicepack " << Voicepack << endl; - stream << "flag " << Flag << endl; - for(int i = 0; i < BINDS_NUMBER; i++) - { - stream << "bind " << binds[i].strbind << " " << binds[i].action << endl; - } - stream << "difficulty " << difficulty << endl; - cfgfile.close(); - return true; + if (OldTeamName != TeamName) + { + QFile cfgfile(cfgdir->absolutePath() + "/" + OldTeamName + ".cfg"); + cfgfile.remove(); + OldTeamName = TeamName; + } + QFile cfgfile(cfgdir->absolutePath() + "/" + TeamName + ".cfg"); + if (!cfgfile.open(QIODevice::WriteOnly)) return false; + QTextStream stream(&cfgfile); + stream.setCodec("UTF-8"); + stream << "; Generated by Hedgewars, do not modify" << endl; + stream << "name team " << TeamName << endl; + for (int i = 0; i < 8; i++) + { + stream << "name hh" << i << " " << HHName[i] << endl; + stream << "hat" << i << " " << HHHat[i] << endl; + } + stream << "grave " << Grave << endl; + stream << "fort " << Fort << endl; + stream << "voicepack " << Voicepack << endl; + stream << "flag " << Flag << endl; + for(int i = 0; i < BINDS_NUMBER; i++) + { + stream << "bind " << binds[i].strbind << " " << binds[i].action << endl; + } + stream << "difficulty " << difficulty << endl; + cfgfile.close(); + return true; } void HWTeam::SetToPage(HWForm * hwform) { - hwform->ui.pageEditTeam->TeamNameEdit->setText(TeamName); - hwform->ui.pageEditTeam->CBTeamLvl->setCurrentIndex(difficulty); - for(int i = 0; i < 8; i++) - { + hwform->ui.pageEditTeam->TeamNameEdit->setText(TeamName); + hwform->ui.pageEditTeam->CBTeamLvl->setCurrentIndex(difficulty); + for(int i = 0; i < 8; i++) + { hwform->ui.pageEditTeam->HHNameEdit[i]->setText(HHName[i]); if (HHHat[i].startsWith("Reserved")) hwform->ui.pageEditTeam->HHHats[i]->setCurrentIndex(hwform->ui.pageEditTeam->HHHats[i]->findData("Reserved "+HHHat[i].remove(0,40), Qt::DisplayRole)); else - hwform->ui.pageEditTeam->HHHats[i]->setCurrentIndex(hwform->ui.pageEditTeam->HHHats[i]->findData(HHHat[i], Qt::DisplayRole)); - } - hwform->ui.pageEditTeam->CBGrave->setCurrentIndex(hwform->ui.pageEditTeam->CBGrave->findText(Grave)); - hwform->ui.pageEditTeam->CBFlag->setCurrentIndex(hwform->ui.pageEditTeam->CBFlag->findText(Flag)); + hwform->ui.pageEditTeam->HHHats[i]->setCurrentIndex(hwform->ui.pageEditTeam->HHHats[i]->findData(HHHat[i], Qt::DisplayRole)); + } + hwform->ui.pageEditTeam->CBGrave->setCurrentIndex(hwform->ui.pageEditTeam->CBGrave->findText(Grave)); + hwform->ui.pageEditTeam->CBFlag->setCurrentIndex(hwform->ui.pageEditTeam->CBFlag->findText(Flag)); - hwform->ui.pageEditTeam->CBFort->setCurrentIndex(hwform->ui.pageEditTeam->CBFort->findText(Fort)); - hwform->ui.pageEditTeam->CBVoicepack->setCurrentIndex(hwform->ui.pageEditTeam->CBVoicepack->findText(Voicepack)); - //hwform->ui.pageEditTeam->CBFort_activated(Fort); + hwform->ui.pageEditTeam->CBFort->setCurrentIndex(hwform->ui.pageEditTeam->CBFort->findText(Fort)); + hwform->ui.pageEditTeam->CBVoicepack->setCurrentIndex(hwform->ui.pageEditTeam->CBVoicepack->findText(Voicepack)); + //hwform->ui.pageEditTeam->CBFort_activated(Fort); - for(int i = 0; i < BINDS_NUMBER; i++) - { - hwform->ui.pageEditTeam->CBBind[i]->setCurrentIndex(hwform->ui.pageEditTeam->CBBind[i]->findData(binds[i].strbind)); - } + for(int i = 0; i < BINDS_NUMBER; i++) + { + hwform->ui.pageEditTeam->CBBind[i]->setCurrentIndex(hwform->ui.pageEditTeam->CBBind[i]->findData(binds[i].strbind)); + } } void HWTeam::GetFromPage(HWForm * hwform) { - TeamName = hwform->ui.pageEditTeam->TeamNameEdit->text(); - difficulty = hwform->ui.pageEditTeam->CBTeamLvl->currentIndex(); - for(int i = 0; i < 8; i++) - { - HHName[i] = hwform->ui.pageEditTeam->HHNameEdit[i]->text(); + TeamName = hwform->ui.pageEditTeam->TeamNameEdit->text(); + difficulty = hwform->ui.pageEditTeam->CBTeamLvl->currentIndex(); + for(int i = 0; i < 8; i++) + { + HHName[i] = hwform->ui.pageEditTeam->HHNameEdit[i]->text(); if (hwform->ui.pageEditTeam->HHHats[i]->currentText().startsWith("Reserved")) - HHHat[i] = "Reserved"+playerHash+hwform->ui.pageEditTeam->HHHats[i]->currentText().remove(0,9); + HHHat[i] = "Reserved"+playerHash+hwform->ui.pageEditTeam->HHHats[i]->currentText().remove(0,9); else - HHHat[i] = hwform->ui.pageEditTeam->HHHats[i]->currentText(); - } + HHHat[i] = hwform->ui.pageEditTeam->HHHats[i]->currentText(); + } - Grave = hwform->ui.pageEditTeam->CBGrave->currentText(); - Fort = hwform->ui.pageEditTeam->CBFort->currentText(); - Voicepack = hwform->ui.pageEditTeam->CBVoicepack->currentText(); - Flag = hwform->ui.pageEditTeam->CBFlag->currentText(); - for(int i = 0; i < BINDS_NUMBER; i++) - { - binds[i].strbind = hwform->ui.pageEditTeam->CBBind[i]->itemData(hwform->ui.pageEditTeam->CBBind[i]->currentIndex()).toString(); - } + Grave = hwform->ui.pageEditTeam->CBGrave->currentText(); + Fort = hwform->ui.pageEditTeam->CBFort->currentText(); + Voicepack = hwform->ui.pageEditTeam->CBVoicepack->currentText(); + Flag = hwform->ui.pageEditTeam->CBFlag->currentText(); + for(int i = 0; i < BINDS_NUMBER; i++) + { + binds[i].strbind = hwform->ui.pageEditTeam->CBBind[i]->itemData(hwform->ui.pageEditTeam->CBBind[i]->currentIndex()).toString(); + } } QStringList HWTeam::TeamGameConfig(quint32 InitHealth) const { - QStringList sl; + QStringList sl; if (m_isNetTeam) { - sl.push_back(QString("eaddteam %3 %1 %2").arg(teamColor.rgb() & 0xffffff).arg(TeamName).arg(QString(QCryptographicHash::hash(Owner.toLatin1(), QCryptographicHash::Md5).toHex()))); - sl.push_back("erdriven"); + sl.push_back(QString("eaddteam %3 %1 %2").arg(teamColor.rgb() & 0xffffff).arg(TeamName).arg(QString(QCryptographicHash::hash(Owner.toLatin1(), QCryptographicHash::Md5).toHex()))); + sl.push_back("erdriven"); } else sl.push_back(QString("eaddteam %3 %1 %2").arg(teamColor.rgb() & 0xffffff).arg(TeamName).arg(playerHash)); - sl.push_back(QString("egrave " + Grave)); - sl.push_back(QString("efort " + Fort)); - sl.push_back(QString("evoicepack " + Voicepack)); - sl.push_back(QString("eflag " + Flag)); + sl.push_back(QString("egrave " + Grave)); + sl.push_back(QString("efort " + Fort)); + sl.push_back(QString("evoicepack " + Voicepack)); + sl.push_back(QString("eflag " + Flag)); - if (!m_isNetTeam) - for(int i = 0; i < BINDS_NUMBER; i++) - if(!binds[i].strbind.isEmpty()) - sl.push_back(QString("ebind " + binds[i].strbind + " " + binds[i].action)); + if (!m_isNetTeam) + for(int i = 0; i < BINDS_NUMBER; i++) + if(!binds[i].strbind.isEmpty()) + sl.push_back(QString("ebind " + binds[i].strbind + " " + binds[i].action)); - for (int t = 0; t < numHedgehogs; t++) - { - sl.push_back(QString("eaddhh %1 %2 %3") - .arg(QString::number(difficulty), - QString::number(InitHealth), - HHName[t])); - sl.push_back(QString("ehat %1") - .arg(HHHat[t])); - } - return sl; + for (int t = 0; t < numHedgehogs; t++) + { + sl.push_back(QString("eaddhh %1 %2 %3") + .arg(QString::number(difficulty), + QString::number(InitHealth), + HHName[t])); + sl.push_back(QString("ehat %1") + .arg(HHHat[t])); + } + return sl; } bool HWTeam::isNetTeam() const diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/team.h --- a/QTfrontend/team.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/team.h Sat Mar 06 10:59:20 2010 +0000 @@ -33,38 +33,38 @@ class HWTeam { - public: - HWTeam(const QString & teamname); - HWTeam(const QStringList& strLst); - HWTeam(); + public: + HWTeam(const QString & teamname); + HWTeam(const QStringList& strLst); + HWTeam(); - bool isNetTeam() const; + bool isNetTeam() const; - QString TeamName; - QString HHName[8]; - QString HHHat[8]; - QString Grave; - QString Fort; - QString Flag; - QString Voicepack; - QString Owner; - unsigned int difficulty; - BindAction binds[BINDS_NUMBER]; + QString TeamName; + QString HHName[8]; + QString HHHat[8]; + QString Grave; + QString Fort; + QString Flag; + QString Voicepack; + QString Owner; + unsigned int difficulty; + BindAction binds[BINDS_NUMBER]; - unsigned char numHedgehogs; - QColor teamColor; + unsigned char numHedgehogs; + QColor teamColor; - bool LoadFromFile(); - bool SaveToFile(); - void SetToPage(HWForm * hwform); - void GetFromPage(HWForm * hwform); - QStringList TeamGameConfig(quint32 InitHealth) const; + bool LoadFromFile(); + bool SaveToFile(); + void SetToPage(HWForm * hwform); + void GetFromPage(HWForm * hwform); + QStringList TeamGameConfig(quint32 InitHealth) const; - bool operator==(const HWTeam& t1) const; - bool operator<(const HWTeam& t1) const; - private: - bool m_isNetTeam; - QString OldTeamName; + bool operator==(const HWTeam& t1) const; + bool operator<(const HWTeam& t1) const; + private: + bool m_isNetTeam; + QString OldTeamName; }; diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/teamselect.cpp --- a/QTfrontend/teamselect.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/teamselect.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -35,21 +35,21 @@ framePlaying->addTeam(team, true); curPlayingTeams.push_back(team); connect(framePlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), - this, SLOT(netTeamStatusChanged(const HWTeam&))); + this, SLOT(netTeamStatusChanged(const HWTeam&))); connect(framePlaying->getTeamWidget(team), SIGNAL(hhNmChanged(const HWTeam&)), - this, SLOT(hhNumChanged(const HWTeam&))); + this, SLOT(hhNumChanged(const HWTeam&))); dynamic_cast(framePlaying->getTeamWidget(team))->hhNumChanged(); connect(framePlaying->getTeamWidget(team), SIGNAL(teamColorChanged(const HWTeam&)), - this, SLOT(proxyTeamColorChanged(const HWTeam&))); + this, SLOT(proxyTeamColorChanged(const HWTeam&))); } else { frameDontPlaying->addTeam(team, false); curDontPlayingTeams.push_back(team); if(m_acceptOuter) { connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), - this, SLOT(pre_changeTeamStatus(HWTeam))); + this, SLOT(pre_changeTeamStatus(HWTeam))); } else { connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), - this, SLOT(changeTeamStatus(HWTeam))); + this, SLOT(changeTeamStatus(HWTeam))); } } emit setEnabledGameStart(curPlayingTeams.size()>1); @@ -57,41 +57,41 @@ void TeamSelWidget::setInteractivity(bool interactive) { - framePlaying->setInteractivity(interactive); + framePlaying->setInteractivity(interactive); } void TeamSelWidget::hhNumChanged(const HWTeam& team) { - QList::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); - if(itPlay==curPlayingTeams.end()) - { - qWarning() << QString("hhNumChanged: team '%1' not found").arg(team.TeamName); - return; - } - itPlay->numHedgehogs=team.numHedgehogs; - emit hhogsNumChanged(team); + QList::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); + if(itPlay==curPlayingTeams.end()) + { + qWarning() << QString("hhNumChanged: team '%1' not found").arg(team.TeamName); + return; + } + itPlay->numHedgehogs=team.numHedgehogs; + emit hhogsNumChanged(team); } void TeamSelWidget::proxyTeamColorChanged(const HWTeam& team) { - QList::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); - if(itPlay==curPlayingTeams.end()) - { - qWarning() << QString("proxyTeamColorChanged: team '%1' not found").arg(team.TeamName); - return; - } - itPlay->teamColor=team.teamColor; - emit teamColorChanged(team); + QList::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); + if(itPlay==curPlayingTeams.end()) + { + qWarning() << QString("proxyTeamColorChanged: team '%1' not found").arg(team.TeamName); + return; + } + itPlay->teamColor=team.teamColor; + emit teamColorChanged(team); } void TeamSelWidget::changeHHNum(const HWTeam& team) { QList::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); - if(itPlay==curPlayingTeams.end()) - { - qWarning() << QString("changeHHNum: team '%1' not found").arg(team.TeamName); - return; - } + if(itPlay==curPlayingTeams.end()) + { + qWarning() << QString("changeHHNum: team '%1' not found").arg(team.TeamName); + return; + } itPlay->numHedgehogs=team.numHedgehogs; framePlaying->setHHNum(team); @@ -99,35 +99,35 @@ void TeamSelWidget::changeTeamColor(const HWTeam& team) { - QList::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); - if(itPlay==curPlayingTeams.end()) - { - qWarning() << QString("changeTeamColor: team '%1' not found").arg(team.TeamName); - return; - } - itPlay->teamColor=team.teamColor; + QList::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); + if(itPlay==curPlayingTeams.end()) + { + qWarning() << QString("changeTeamColor: team '%1' not found").arg(team.TeamName); + return; + } + itPlay->teamColor=team.teamColor; - framePlaying->setTeamColor(team); + framePlaying->setTeamColor(team); } void TeamSelWidget::removeNetTeam(const HWTeam& team) { - //qDebug() << QString("removeNetTeam: removing team '%1'").arg(team.TeamName); - for(;;) { - QList::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); - if(itPlay==curPlayingTeams.end()) - { - qWarning() << QString("removeNetTeam: team '%1' not found").arg(team.TeamName); - break; - } - if(itPlay->isNetTeam()) { - QObject::disconnect(framePlaying->getTeamWidget(*itPlay), SIGNAL(teamStatusChanged(HWTeam))); - framePlaying->removeTeam(team); - curPlayingTeams.erase(itPlay); - break; - } - } - emit setEnabledGameStart(curPlayingTeams.size()>1); + //qDebug() << QString("removeNetTeam: removing team '%1'").arg(team.TeamName); + for(;;) { + QList::iterator itPlay=std::find(curPlayingTeams.begin(), curPlayingTeams.end(), team); + if(itPlay==curPlayingTeams.end()) + { + qWarning() << QString("removeNetTeam: team '%1' not found").arg(team.TeamName); + break; + } + if(itPlay->isNetTeam()) { + QObject::disconnect(framePlaying->getTeamWidget(*itPlay), SIGNAL(teamStatusChanged(HWTeam))); + framePlaying->removeTeam(team); + curPlayingTeams.erase(itPlay); + break; + } + } + emit setEnabledGameStart(curPlayingTeams.size()>1); } void TeamSelWidget::netTeamStatusChanged(const HWTeam& team) @@ -178,17 +178,17 @@ pRemoveTeams->removeTeam(team); if(!team.isNetTeam() && m_acceptOuter && !willBePlaying) { connect(frameDontPlaying->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), - this, SLOT(pre_changeTeamStatus(HWTeam))); + this, SLOT(pre_changeTeamStatus(HWTeam))); } else { connect(pAddTeams->getTeamWidget(team), SIGNAL(teamStatusChanged(HWTeam)), - this, SLOT(changeTeamStatus(HWTeam))); + this, SLOT(changeTeamStatus(HWTeam))); } if(willBePlaying) { connect(framePlaying->getTeamWidget(team), SIGNAL(hhNmChanged(const HWTeam&)), - this, SLOT(hhNumChanged(const HWTeam&))); + this, SLOT(hhNumChanged(const HWTeam&))); dynamic_cast(framePlaying->getTeamWidget(team))->hhNumChanged(); connect(framePlaying->getTeamWidget(team), SIGNAL(teamColorChanged(const HWTeam&)), - this, SLOT(proxyTeamColorChanged(const HWTeam&))); + this, SLOT(proxyTeamColorChanged(const HWTeam&))); emit teamColorChanged(((TeamShowWidget*)framePlaying->getTeamWidget(team))->getTeam()); } @@ -204,39 +204,39 @@ void TeamSelWidget::addScrArea(FrameTeams* pfteams, QColor color, int fixedHeight) { - VertScrArea* area = new VertScrArea(color); - area->setWidget(pfteams); - mainLayout.addWidget(area, 30); - if (fixedHeight > 0) - { - area->setMinimumHeight(fixedHeight); - area->setMaximumHeight(fixedHeight); - area->setStyleSheet( - "FrameTeams{" - "border: solid;" - "border-width: 1px;" - "border-radius: 16px;" - "border-color: #ffcc00;" - "}" - ); - } + VertScrArea* area = new VertScrArea(color); + area->setWidget(pfteams); + mainLayout.addWidget(area, 30); + if (fixedHeight > 0) + { + area->setMinimumHeight(fixedHeight); + area->setMaximumHeight(fixedHeight); + area->setStyleSheet( + "FrameTeams{" + "border: solid;" + "border-width: 1px;" + "border-radius: 16px;" + "border-color: #ffcc00;" + "}" + ); + } } TeamSelWidget::TeamSelWidget(QWidget* parent) : QGroupBox(parent), mainLayout(this), m_acceptOuter(false) { - setTitle(QGroupBox::tr("Playing teams")); - framePlaying = new FrameTeams(); - frameDontPlaying = new FrameTeams(); + setTitle(QGroupBox::tr("Playing teams")); + framePlaying = new FrameTeams(); + frameDontPlaying = new FrameTeams(); - QPalette p; - p.setColor(QPalette::Window, QColor(0x00, 0x00, 0x00)); - addScrArea(framePlaying, p.color(QPalette::Window).light(105), 250); - addScrArea(frameDontPlaying, p.color(QPalette::Window).dark(105), 0); - QPushButton * btnSetup = new QPushButton(this); - btnSetup->setText(QPushButton::tr("Setup")); - connect(btnSetup, SIGNAL(clicked()), this, SIGNAL(SetupClicked())); - mainLayout.addWidget(btnSetup); + QPalette p; + p.setColor(QPalette::Window, QColor(0x00, 0x00, 0x00)); + addScrArea(framePlaying, p.color(QPalette::Window).light(105), 250); + addScrArea(frameDontPlaying, p.color(QPalette::Window).dark(105), 0); + QPushButton * btnSetup = new QPushButton(this); + btnSetup->setText(QPushButton::tr("Setup")); + connect(btnSetup, SIGNAL(clicked()), this, SIGNAL(SetupClicked())); + mainLayout.addWidget(btnSetup); } void TeamSelWidget::setAcceptOuter(bool acceptOuter) diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/teamselhelper.cpp --- a/QTfrontend/teamselhelper.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/teamselhelper.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -35,62 +35,62 @@ QWidget(parent), mainLayout(this), m_team(team), m_isPlaying(isPlaying), phhoger(0), colorButt(0) { - QPalette newPalette = palette(); - newPalette.setColor(QPalette::Window, QColor(0x00, 0x00, 0x00)); - setPalette(newPalette); - setAutoFillBackground(true); + QPalette newPalette = palette(); + newPalette.setColor(QPalette::Window, QColor(0x00, 0x00, 0x00)); + setPalette(newPalette); + setAutoFillBackground(true); - mainLayout.setSpacing(3); - mainLayout.setMargin(0); - this->setMaximumHeight(38); - this->setMinimumHeight(38); - QIcon difficultyIcon=team.isNetTeam() ? - QIcon(QString(":/res/botlevels/net%1.png").arg(m_team.difficulty)) - : QIcon(QString(":/res/botlevels/%1.png").arg(m_team.difficulty)); + mainLayout.setSpacing(3); + mainLayout.setMargin(0); + this->setMaximumHeight(38); + this->setMinimumHeight(38); + QIcon difficultyIcon=team.isNetTeam() ? + QIcon(QString(":/res/botlevels/net%1.png").arg(m_team.difficulty)) + : QIcon(QString(":/res/botlevels/%1.png").arg(m_team.difficulty)); - butt = new QPushButton(difficultyIcon, team.TeamName, this); - butt->setFlat(true); - butt->setToolTip(team.Owner); - mainLayout.addWidget(butt); - butt->setStyleSheet("QPushButton{" - "icon-size: 48px;" - "text-align: left;" - "background-color: #0d0544;" - "color: orange;" - "font: bold;" - "border-width: 2px;" - "margin: 6px 0px 6px 0px;" - "}"); + butt = new QPushButton(difficultyIcon, team.TeamName, this); + butt->setFlat(true); + butt->setToolTip(team.Owner); + mainLayout.addWidget(butt); + butt->setStyleSheet("QPushButton{" + "icon-size: 48px;" + "text-align: left;" + "background-color: #0d0544;" + "color: orange;" + "font: bold;" + "border-width: 2px;" + "margin: 6px 0px 6px 0px;" + "}"); - if(m_isPlaying) { - // team color - colorButt = new QPushButton(this); - colorButt->setMaximumWidth(26); - colorButt->setMinimumHeight(26); - colorButt->setGeometry(0, 0, 26, 26); + if(m_isPlaying) { + // team color + colorButt = new QPushButton(this); + colorButt->setMaximumWidth(26); + colorButt->setMinimumHeight(26); + colorButt->setGeometry(0, 0, 26, 26); - changeTeamColor(); - connect(colorButt, SIGNAL(clicked()), this, SLOT(changeTeamColor())); - mainLayout.addWidget(colorButt); + changeTeamColor(); + connect(colorButt, SIGNAL(clicked()), this, SLOT(changeTeamColor())); + mainLayout.addWidget(colorButt); - phhoger = new CHedgehogerWidget(QImage(":/res/hh25x25.png"), this); - connect(phhoger, SIGNAL(hedgehogsNumChanged()), this, SLOT(hhNumChanged())); - mainLayout.addWidget(phhoger); - } else { - } + phhoger = new CHedgehogerWidget(QImage(":/res/hh25x25.png"), this); + connect(phhoger, SIGNAL(hedgehogsNumChanged()), this, SLOT(hhNumChanged())); + mainLayout.addWidget(phhoger); + } else { + } - QObject::connect(butt, SIGNAL(clicked()), this, SLOT(activateTeam())); - //QObject::connect(bText, SIGNAL(clicked()), this, SLOT(activateTeam())); + QObject::connect(butt, SIGNAL(clicked()), this, SLOT(activateTeam())); + //QObject::connect(bText, SIGNAL(clicked()), this, SLOT(activateTeam())); } void TeamShowWidget::setInteractivity(bool interactive) { - if(m_team.isNetTeam()) { - butt->setEnabled(interactive); - } + if(m_team.isNetTeam()) { + butt->setEnabled(interactive); + } - colorButt->setEnabled(interactive); - phhoger->setEnabled(interactive); + colorButt->setEnabled(interactive); + phhoger->setEnabled(interactive); } void TeamShowWidget::setHHNum(unsigned int num) @@ -120,30 +120,30 @@ void TeamShowWidget::changeTeamColor(QColor color) { - FrameTeams* pOurFrameTeams=dynamic_cast(parentWidget()); - if(!color.isValid()) { - if(++pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.end()) { - pOurFrameTeams->currentColor=pOurFrameTeams->availableColors.begin(); - } - color=*pOurFrameTeams->currentColor; - } else { - // set according color iterator - pOurFrameTeams->currentColor=std::find(pOurFrameTeams->availableColors.begin(), - pOurFrameTeams->availableColors.end(), color); - if(pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.end()) { - // error condition - pOurFrameTeams->currentColor=pOurFrameTeams->availableColors.begin(); - } - } + FrameTeams* pOurFrameTeams=dynamic_cast(parentWidget()); + if(!color.isValid()) { + if(++pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.end()) { + pOurFrameTeams->currentColor=pOurFrameTeams->availableColors.begin(); + } + color=*pOurFrameTeams->currentColor; + } else { + // set according color iterator + pOurFrameTeams->currentColor=std::find(pOurFrameTeams->availableColors.begin(), + pOurFrameTeams->availableColors.end(), color); + if(pOurFrameTeams->currentColor==pOurFrameTeams->availableColors.end()) { + // error condition + pOurFrameTeams->currentColor=pOurFrameTeams->availableColors.begin(); + } + } - colorButt->setStyleSheet(QString("QPushButton{" - "background-color: %1;" - "border-width: 1px;" - "border-radius: 2px;" - "}").arg(pOurFrameTeams->currentColor->name())); + colorButt->setStyleSheet(QString("QPushButton{" + "background-color: %1;" + "border-width: 1px;" + "border-radius: 2px;" + "}").arg(pOurFrameTeams->currentColor->name())); - m_team.teamColor=color; - emit teamColorChanged(m_team); + m_team.teamColor=color; + emit teamColorChanged(m_team); } HWTeam TeamShowWidget::getTeam() const diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/togglebutton.cpp --- a/QTfrontend/togglebutton.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/togglebutton.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -20,60 +20,60 @@ ToggleButtonWidget::ToggleButtonWidget(QWidget * parent, QString img) { - QVBoxLayout * l = new QVBoxLayout(this); - setLayout(l); + QVBoxLayout * l = new QVBoxLayout(this); + setLayout(l); - pbMain = new QPushButton(this); - pbMain->setCheckable(true); + pbMain = new QPushButton(this); + pbMain->setCheckable(true); - QPixmap pm(":/res/btnDisabled.png"); - QPainter * painter = new QPainter(); + QPixmap pm(":/res/btnDisabled.png"); + QPainter * painter = new QPainter(); - pmChecked.load(img); - pmDisabled.load(img); + pmChecked.load(img); + pmDisabled.load(img); - pbMain->setMaximumWidth(pmChecked.width() + 6); + pbMain->setMaximumWidth(pmChecked.width() + 6); - l->addWidget(pbMain); + l->addWidget(pbMain); - painter->begin(&pmDisabled); - painter->drawPixmap(pmDisabled.rect(), pm); - painter->end(); + painter->begin(&pmDisabled); + painter->drawPixmap(pmDisabled.rect(), pm); + painter->end(); - pbMain->setIconSize(pmDisabled.size()); - pbMain->setIcon(pmDisabled); + pbMain->setIconSize(pmDisabled.size()); + pbMain->setIcon(pmDisabled); - connect(pbMain, SIGNAL(toggled(bool)), this, SLOT(eventToggled(bool))); + connect(pbMain, SIGNAL(toggled(bool)), this, SLOT(eventToggled(bool))); - lbMain = new QLabel(this); - lbMain->setWordWrap(true); -// lbMain->setFixedHeight(32); + lbMain = new QLabel(this); + lbMain->setWordWrap(true); +// lbMain->setFixedHeight(32); - l->addWidget(lbMain); + l->addWidget(lbMain); } ToggleButtonWidget::~ToggleButtonWidget() { - delete pbMain; - delete lbMain; + delete pbMain; + delete lbMain; } bool ToggleButtonWidget::isChecked() { - return pbMain->isChecked(); + return pbMain->isChecked(); } void ToggleButtonWidget::setChecked(bool checked) { - pbMain->setChecked(checked); + pbMain->setChecked(checked); } void ToggleButtonWidget::setText(QString s) { - lbMain->setText(s); + lbMain->setText(s); } void ToggleButtonWidget::eventToggled(bool checked) { - if (checked) pbMain->setIcon(pmChecked); else pbMain->setIcon(pmDisabled); + if (checked) pbMain->setIcon(pmChecked); else pbMain->setIcon(pmDisabled); } diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/togglebutton.h --- a/QTfrontend/togglebutton.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/togglebutton.h Sat Mar 06 10:59:20 2010 +0000 @@ -27,24 +27,24 @@ class ToggleButtonWidget : public QWidget { - Q_OBJECT + Q_OBJECT public: - ToggleButtonWidget(QWidget * parent, QString img); - ~ToggleButtonWidget(); - bool isChecked(); - void setChecked(bool checked); - void setText(QString s); - QPushButton * button() - { - return pbMain; - } + ToggleButtonWidget(QWidget * parent, QString img); + ~ToggleButtonWidget(); + bool isChecked(); + void setChecked(bool checked); + void setText(QString s); + QPushButton * button() + { + return pbMain; + } private: - QLabel * lbMain; - QPushButton * pbMain; - QPixmap pmChecked; - QPixmap pmDisabled; + QLabel * lbMain; + QPushButton * pbMain; + QPixmap pmChecked; + QPixmap pmDisabled; private slots: - void eventToggled(bool checked); + void eventToggled(bool checked); }; #endif // TOGGLEBUTTONWIDGET_H diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/ui_hwform.cpp --- a/QTfrontend/ui_hwform.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/ui_hwform.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -30,87 +30,87 @@ void Ui_HWForm::setupUi(HWForm *HWForm) { - SetupFonts(); + SetupFonts(); - HWForm->setObjectName(QString::fromUtf8("HWForm")); - HWForm->resize(QSize(640, 480).expandedTo(HWForm->minimumSizeHint())); - HWForm->setMinimumSize(QSize(720, 450)); - HWForm->setWindowTitle(QMainWindow::tr("Hedgewars %1").arg(*cVersionString)); - centralWidget = new QWidget(HWForm); - centralWidget->setObjectName(QString::fromUtf8("centralWidget")); + HWForm->setObjectName(QString::fromUtf8("HWForm")); + HWForm->resize(QSize(640, 480).expandedTo(HWForm->minimumSizeHint())); + HWForm->setMinimumSize(QSize(720, 450)); + HWForm->setWindowTitle(QMainWindow::tr("Hedgewars %1").arg(*cVersionString)); + centralWidget = new QWidget(HWForm); + centralWidget->setObjectName(QString::fromUtf8("centralWidget")); - SetupPages(centralWidget, HWForm); + SetupPages(centralWidget, HWForm); - HWForm->setCentralWidget(centralWidget); + HWForm->setCentralWidget(centralWidget); - Pages->setCurrentIndex(0); + Pages->setCurrentIndex(0); - QMetaObject::connectSlotsByName(HWForm); + QMetaObject::connectSlotsByName(HWForm); } void Ui_HWForm::SetupFonts() { - font14 = new QFont("MS Shell Dlg", 14); + font14 = new QFont("MS Shell Dlg", 14); } void Ui_HWForm::SetupPages(QWidget *Parent, HWForm *HWForm) { - Pages = new QStackedLayout(Parent); + Pages = new QStackedLayout(Parent); - pageEditTeam = new PageEditTeam(Parent, &HWForm->sdli); - Pages->addWidget(pageEditTeam); + pageEditTeam = new PageEditTeam(Parent, &HWForm->sdli); + Pages->addWidget(pageEditTeam); - pageOptions = new PageOptions(); - Pages->addWidget(pageOptions); + pageOptions = new PageOptions(); + Pages->addWidget(pageOptions); - pageMultiplayer = new PageMultiplayer(); - Pages->addWidget(pageMultiplayer); + pageMultiplayer = new PageMultiplayer(); + Pages->addWidget(pageMultiplayer); - pagePlayDemo = new PagePlayDemo(); - Pages->addWidget(pagePlayDemo); + pagePlayDemo = new PagePlayDemo(); + Pages->addWidget(pagePlayDemo); - pageNet = new PageNet(); - Pages->addWidget(pageNet); + pageNet = new PageNet(); + Pages->addWidget(pageNet); - pageNetGame = new PageNetGame(Parent, HWForm->gameSettings, &HWForm->sdli); - Pages->addWidget(pageNetGame); + pageNetGame = new PageNetGame(Parent, HWForm->gameSettings, &HWForm->sdli); + Pages->addWidget(pageNetGame); - pageInfo = new PageInfo(); - Pages->addWidget(pageInfo); + pageInfo = new PageInfo(); + Pages->addWidget(pageInfo); - pageMain = new PageMain(); - Pages->addWidget(pageMain); + pageMain = new PageMain(); + Pages->addWidget(pageMain); - pageGameStats = new PageGameStats(); - Pages->addWidget(pageGameStats); + pageGameStats = new PageGameStats(); + Pages->addWidget(pageGameStats); - pageSinglePlayer = new PageSinglePlayer(); - Pages->addWidget(pageSinglePlayer); + pageSinglePlayer = new PageSinglePlayer(); + Pages->addWidget(pageSinglePlayer); - pageTraining = new PageTraining(); - Pages->addWidget(pageTraining); + pageTraining = new PageTraining(); + Pages->addWidget(pageTraining); - pageSelectWeapon = new PageSelectWeapon(); - Pages->addWidget(pageSelectWeapon); + pageSelectWeapon = new PageSelectWeapon(); + Pages->addWidget(pageSelectWeapon); - pageNetServer = new PageNetServer(); - Pages->addWidget(pageNetServer); + pageNetServer = new PageNetServer(); + Pages->addWidget(pageNetServer); - pageInGame = new PageInGame(); - Pages->addWidget(pageInGame); + pageInGame = new PageInGame(); + Pages->addWidget(pageInGame); - pageRoomsList = new PageRoomsList(Parent, HWForm->gameSettings, &HWForm->sdli); - Pages->addWidget(pageRoomsList); + pageRoomsList = new PageRoomsList(Parent, HWForm->gameSettings, &HWForm->sdli); + Pages->addWidget(pageRoomsList); - pageConnecting = new PageConnecting(); - Pages->addWidget(pageConnecting); + pageConnecting = new PageConnecting(); + Pages->addWidget(pageConnecting); - pageScheme = new PageScheme(); - Pages->addWidget(pageScheme); + pageScheme = new PageScheme(); + Pages->addWidget(pageScheme); - pageAdmin = new PageAdmin(); - Pages->addWidget(pageAdmin); + pageAdmin = new PageAdmin(); + Pages->addWidget(pageAdmin); - pageNetType = new PageNetType(); - Pages->addWidget(pageNetType); + pageNetType = new PageNetType(); + Pages->addWidget(pageNetType); } diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/ui_hwform.h --- a/QTfrontend/ui_hwform.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/ui_hwform.h Sat Mar 06 10:59:20 2010 +0000 @@ -48,37 +48,37 @@ class Ui_HWForm { public: - QWidget *centralWidget; + QWidget *centralWidget; - PageMain *pageMain; - PageEditTeam *pageEditTeam; - PageMultiplayer *pageMultiplayer; - PagePlayDemo *pagePlayDemo; - PageOptions *pageOptions; - PageNet *pageNet; - PageNetServer * pageNetServer; - PageNetChat *pageNetChat; - PageNetGame *pageNetGame; - PageInfo *pageInfo; - PageGameStats *pageGameStats; - PageSinglePlayer *pageSinglePlayer; - PageTraining *pageTraining; - PageSelectWeapon *pageSelectWeapon; - PageInGame *pageInGame; - PageRoomsList *pageRoomsList; - PageConnecting *pageConnecting; - PageScheme *pageScheme; - PageAdmin *pageAdmin; - PageNetType *pageNetType; + PageMain *pageMain; + PageEditTeam *pageEditTeam; + PageMultiplayer *pageMultiplayer; + PagePlayDemo *pagePlayDemo; + PageOptions *pageOptions; + PageNet *pageNet; + PageNetServer * pageNetServer; + PageNetChat *pageNetChat; + PageNetGame *pageNetGame; + PageInfo *pageInfo; + PageGameStats *pageGameStats; + PageSinglePlayer *pageSinglePlayer; + PageTraining *pageTraining; + PageSelectWeapon *pageSelectWeapon; + PageInGame *pageInGame; + PageRoomsList *pageRoomsList; + PageConnecting *pageConnecting; + PageScheme *pageScheme; + PageAdmin *pageAdmin; + PageNetType *pageNetType; - QStackedLayout *Pages; - QFont *font14; + QStackedLayout *Pages; + QFont *font14; - void setupUi(HWForm *HWForm); - void SetupFonts(); - void SetupPages(QWidget *Parent, HWForm *HWForm); - void SetupPageNetChat(QWidget *Parent); - void SetupPageNetGame(QWidget *Parent); + void setupUi(HWForm *HWForm); + void SetupFonts(); + void SetupPages(QWidget *Parent, HWForm *HWForm); + void SetupPageNetChat(QWidget *Parent); + void SetupPageNetGame(QWidget *Parent); }; #endif // UI_HWFORM_H diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/vertScrollArea.cpp --- a/QTfrontend/vertScrollArea.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/vertScrollArea.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -23,12 +23,12 @@ VertScrArea::VertScrArea(QColor frameColor, QWidget * parent) : QScrollArea(parent) { - QPalette newPalette = palette(); - newPalette.setColor(QPalette::Background, frameColor); - setPalette(newPalette); + QPalette newPalette = palette(); + newPalette.setColor(QPalette::Background, frameColor); + setPalette(newPalette); } void VertScrArea::resizeEvent(QResizeEvent * event) { - widget()->resize(event->size().width(), widget()->sizeHint().height()); + widget()->resize(event->size().width(), widget()->sizeHint().height()); } diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/vertScrollArea.h --- a/QTfrontend/vertScrollArea.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/vertScrollArea.h Sat Mar 06 10:59:20 2010 +0000 @@ -23,13 +23,13 @@ class VertScrArea : public QScrollArea { - Q_OBJECT + Q_OBJECT public: - VertScrArea(QColor frameColor, QWidget * parent = 0); + VertScrArea(QColor frameColor, QWidget * parent = 0); protected: - virtual void resizeEvent(QResizeEvent * event); + virtual void resizeEvent(QResizeEvent * event); }; #endif // _VERT_SCROLL_AREA_INCLUDED diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/xfire.cpp --- a/QTfrontend/xfire.cpp Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/xfire.cpp Sat Mar 06 10:59:20 2010 +0000 @@ -30,53 +30,53 @@ // xfire_init(): used to initialize all variables and set their default values void xfire_init(void) { - if(use_xfire) - return; - use_xfire = XfireIsLoaded() == 1; - - if(!use_xfire) - return; - - for(int i = 0; i < XFIRE_KEY_COUNT; i++) - { - keys[i] = new char[256]; - values[i] = new char[256]; - strcpy(keys[i], ""); - strcpy(values[i], ""); - } - - strcpy(keys[XFIRE_NICKNAME], "Nickname"); - strcpy(keys[XFIRE_ROOM], "Room"); - strcpy(keys[XFIRE_SERVER], "Server"); - strcpy(keys[XFIRE_STATUS], "Status"); - xfire_update(); + if(use_xfire) + return; + use_xfire = XfireIsLoaded() == 1; + + if(!use_xfire) + return; + + for(int i = 0; i < XFIRE_KEY_COUNT; i++) + { + keys[i] = new char[256]; + values[i] = new char[256]; + strcpy(keys[i], ""); + strcpy(values[i], ""); + } + + strcpy(keys[XFIRE_NICKNAME], "Nickname"); + strcpy(keys[XFIRE_ROOM], "Room"); + strcpy(keys[XFIRE_SERVER], "Server"); + strcpy(keys[XFIRE_STATUS], "Status"); + xfire_update(); } // xfire_free(): used to free up ressources used etc. void xfire_free(void) { - if(!use_xfire) - return; - - for(int i = 0; i < XFIRE_KEY_COUNT; i++) - { - delete [] keys[i]; - delete [] values[i]; - } + if(!use_xfire) + return; + + for(int i = 0; i < XFIRE_KEY_COUNT; i++) + { + delete [] keys[i]; + delete [] values[i]; + } } // xfire_setvalue(): set a specific value void xfire_setvalue(const XFIRE_KEYS status, const char *value) { - if(!use_xfire || strlen(value) > 255) - return; - strcpy(values[status], value); + if(!use_xfire || strlen(value) > 255) + return; + strcpy(values[status], value); } // xfire_update(): submits current values to the xfire app void xfire_update(void) { - if(!use_xfire) - return; - XfireSetCustomGameDataA(XFIRE_KEY_COUNT, (const char**)keys, (const char**)values); + if(!use_xfire) + return; + XfireSetCustomGameDataA(XFIRE_KEY_COUNT, (const char**)keys, (const char**)values); } diff -r 803b277e4894 -r 3f21a9dc93d0 QTfrontend/xfire.h --- a/QTfrontend/xfire.h Sat Mar 06 10:54:24 2010 +0000 +++ b/QTfrontend/xfire.h Sat Mar 06 10:59:20 2010 +0000 @@ -27,11 +27,11 @@ #ifdef USE_XFIRE enum XFIRE_KEYS { - XFIRE_STATUS = 0, - XFIRE_NICKNAME, - XFIRE_SERVER, - XFIRE_ROOM, - XFIRE_KEY_COUNT, + XFIRE_STATUS = 0, + XFIRE_NICKNAME, + XFIRE_SERVER, + XFIRE_ROOM, + XFIRE_KEY_COUNT, }; void xfire_init(void); diff -r 803b277e4894 -r 3f21a9dc93d0 gameServer/Actions.hs --- a/gameServer/Actions.hs Sat Mar 06 10:54:24 2010 +0000 +++ b/gameServer/Actions.hs Sat Mar 06 10:59:20 2010 +0000 @@ -312,7 +312,7 @@ processAction (clID, serverInfo, clients, rooms) (RemoveTeam teamName) = do - newRooms <- if not $ gameinprogress room then + newRooms <- if not $ gameinprogress room then do processAction (clID, serverInfo, clients, rooms) $ AnswerOthersInRoom ["REMOVE_TEAM", teamName] return $ diff -r 803b277e4894 -r 3f21a9dc93d0 gameServer/ServerCore.hs --- a/gameServer/ServerCore.hs Sat Mar 06 10:54:24 2010 +0000 +++ b/gameServer/ServerCore.hs Sat Mar 06 10:59:20 2010 +0000 @@ -60,7 +60,7 @@ PingAll : [StatsAction | even tick] - {- let hadRooms = (not $ null rooms) && (null mrooms) + {- let hadRooms = (not $ null rooms) && (null mrooms) in unless ((not $ isDedicated serverInfo) && ((null clientsIn) || hadRooms)) $ mainLoop serverInfo acceptChan messagesChan clientsIn mrooms -} diff -r 803b277e4894 -r 3f21a9dc93d0 gameServer/stresstest.hs --- a/gameServer/stresstest.hs Sat Mar 06 10:54:24 2010 +0000 +++ b/gameServer/stresstest.hs Sat Mar 06 10:59:20 2010 +0000 @@ -19,33 +19,33 @@ session3 nick room = ["NICK", nick, "", "PROTO", "24", "", "LIST", "", "JOIN", room, "", "CHAT", "room 2", "", "QUIT", "bye-bye", ""] emulateSession sock s = do - mapM_ (\x -> hPutStrLn sock x >> hFlush sock >> randomRIO (50000::Int, 90000) >>= threadDelay) s - hFlush sock - threadDelay 225000 + mapM_ (\x -> hPutStrLn sock x >> hFlush sock >> randomRIO (50000::Int, 90000) >>= threadDelay) s + hFlush sock + threadDelay 225000 testing = Control.Exception.handle print $ do - putStrLn "Start" - sock <- connectTo "127.0.0.1" (PortNumber 46631) + putStrLn "Start" + sock <- connectTo "127.0.0.1" (PortNumber 46631) - num1 <- randomRIO (70000::Int, 70100) - num2 <- randomRIO (0::Int, 2) - num3 <- randomRIO (0::Int, 5) - let nick1 = show num1 - let room1 = show num2 - case num2 of - 0 -> emulateSession sock $ session1 nick1 room1 - 1 -> emulateSession sock $ session2 nick1 room1 - 2 -> emulateSession sock $ session3 nick1 room1 - hClose sock - putStrLn "Finish" + num1 <- randomRIO (70000::Int, 70100) + num2 <- randomRIO (0::Int, 2) + num3 <- randomRIO (0::Int, 5) + let nick1 = show num1 + let room1 = show num2 + case num2 of + 0 -> emulateSession sock $ session1 nick1 room1 + 1 -> emulateSession sock $ session2 nick1 room1 + 2 -> emulateSession sock $ session3 nick1 room1 + hClose sock + putStrLn "Finish" forks = forever $ do - delay <- randomRIO (10000::Int, 19000) - threadDelay delay - forkIO testing + delay <- randomRIO (10000::Int, 19000) + threadDelay delay + forkIO testing main = withSocketsDo $ do #if !defined(mingw32_HOST_OS) - installHandler sigPIPE Ignore Nothing; + installHandler sigPIPE Ignore Nothing; #endif - forks + forks diff -r 803b277e4894 -r 3f21a9dc93d0 gameServer/stresstest2.hs --- a/gameServer/stresstest2.hs Sat Mar 06 10:54:24 2010 +0000 +++ b/gameServer/stresstest2.hs Sat Mar 06 10:59:20 2010 +0000 @@ -15,21 +15,21 @@ #endif testing = Control.Exception.handle print $ do - delay <- randomRIO (100::Int, 300) - threadDelay delay - sock <- connectTo "127.0.0.1" (PortNumber 46631) - hClose sock + delay <- randomRIO (100::Int, 300) + threadDelay delay + sock <- connectTo "127.0.0.1" (PortNumber 46631) + hClose sock forks i = do - delay <- randomRIO (50::Int, 190) - if i `mod` 10 == 0 then putStr (show i) else putStr "." - hFlush stdout - threadDelay delay - forkIO testing - forks (i + 1) + delay <- randomRIO (50::Int, 190) + if i `mod` 10 == 0 then putStr (show i) else putStr "." + hFlush stdout + threadDelay delay + forkIO testing + forks (i + 1) main = withSocketsDo $ do #if !defined(mingw32_HOST_OS) - installHandler sigPIPE Ignore Nothing; + installHandler sigPIPE Ignore Nothing; #endif - forks 1 + forks 1 diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/CCHandlers.inc --- a/hedgewars/CCHandlers.inc Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/CCHandlers.inc Sat Mar 06 10:59:20 2010 +0000 @@ -670,13 +670,13 @@ {$IFDEF SDL13} window:= SDL_CreateWindow('Hedgewars', 0, 0, cScreenWidth, cScreenHeight, - SDL_WINDOW_OPENGL or SDL_WINDOW_SHOWN - {$IFDEF IPHONEOS} or SDL_WINDOW_BORDERLESS{$ENDIF}); - SDL_CreateRenderer(window, -1, 0); - PixelFormat:= nil; + SDL_WINDOW_OPENGL or SDL_WINDOW_SHOWN + {$IFDEF IPHONEOS} or SDL_WINDOW_BORDERLESS{$ENDIF}); + SDL_CreateRenderer(window, -1, 0); + PixelFormat:= nil; - SDL_SetRenderDrawColor(0, 0, 0, 255); - SDL_RenderFill(nil); + SDL_SetRenderDrawColor(0, 0, 0, 255); + SDL_RenderFill(nil); SDL_RenderPresent(); {$ELSE} SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags); diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/GSHandlers.inc --- a/hedgewars/GSHandlers.inc Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/GSHandlers.inc Sat Mar 06 10:59:20 2010 +0000 @@ -20,26 +20,26 @@ var gi: PGear; d: LongInt; begin - gi:= GearsList; - while gi <> nil do - begin - d:= r - hwRound(Distance(gi^.X - x, gi^.Y - y)); - if (d > 1) and (gi^.Kind = gtHedgehog) and not gi^.Invulnerable and (GetRandom(2) = 0) then - begin - if (CurrentHedgehog^.Gear = gi) then - PlaySound(sndOops, PHedgehog(gi^.Hedgehog)^.Team^.voicepack) - else - begin - if (gi^.State and gstMoving) = 0 then - gi^.State:= gi^.State or gstLoser; - if d > r div 2 then - PlaySound(sndNooo, PHedgehog(gi^.Hedgehog)^.Team^.voicepack) - else - PlaySound(sndUhOh, PHedgehog(gi^.Hedgehog)^.Team^.voicepack); - end; - end; - gi:= gi^.NextGear - end; + gi:= GearsList; + while gi <> nil do + begin + d:= r - hwRound(Distance(gi^.X - x, gi^.Y - y)); + if (d > 1) and (gi^.Kind = gtHedgehog) and not gi^.Invulnerable and (GetRandom(2) = 0) then + begin + if (CurrentHedgehog^.Gear = gi) then + PlaySound(sndOops, PHedgehog(gi^.Hedgehog)^.Team^.voicepack) + else + begin + if (gi^.State and gstMoving) = 0 then + gi^.State:= gi^.State or gstLoser; + if d > r div 2 then + PlaySound(sndNooo, PHedgehog(gi^.Hedgehog)^.Team^.voicepack) + else + PlaySound(sndUhOh, PHedgehog(gi^.Hedgehog)^.Team^.voicepack); + end; + end; + gi:= gi^.NextGear + end; end; //////////////////////////////////////////////////////////////////////////////// procedure doStepDrowningGear(Gear: PGear); forward; @@ -68,50 +68,50 @@ Gear^.State:= gstDrowning; Gear^.RenderTimer:= false; Gear^.doStep:= @doStepDrowningGear; - if Gear^.Kind = gtHedgehog then - begin - Gear^.State:= Gear^.State and (not gstHHDriven); - AddCaption(Format(GetEventString(eidDrowned), PHedgehog(Gear^.Hedgehog)^.Name), cWhiteColor, capgrpMessage); - end + if Gear^.Kind = gtHedgehog then + begin + Gear^.State:= Gear^.State and (not gstHHDriven); + AddCaption(Format(GetEventString(eidDrowned), PHedgehog(Gear^.Hedgehog)^.Name), cWhiteColor, capgrpMessage); + end end; PlaySound(sndSplash) end else - CheckGearDrowning:= false + CheckGearDrowning:= false end; procedure CheckCollision(Gear: PGear); begin if TestCollisionXwithGear(Gear, hwSign(Gear^.X)) or TestCollisionYwithGear(Gear, hwSign(Gear^.Y)) - then Gear^.State:= Gear^.State or gstCollision - else Gear^.State:= Gear^.State and not gstCollision + then Gear^.State:= Gear^.State or gstCollision + else Gear^.State:= Gear^.State and not gstCollision end; procedure CheckHHDamage(Gear: PGear); var - dmg: Longword; - i: LongInt; - particle: PVisualGear; + dmg: Longword; + i: LongInt; + particle: PVisualGear; begin if _0_4 < Gear^.dY then - begin - dmg:= ModifyDamage(1 + hwRound((hwAbs(Gear^.dY) - _0_4) * 70), Gear); + begin + dmg:= ModifyDamage(1 + hwRound((hwAbs(Gear^.dY) - _0_4) * 70), Gear); if dmg < 1 then exit; - for i:= min(12, (3 + dmg div 10)) downto 0 do begin - particle := AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12, vgtDust); + for i:= min(12, (3 + dmg div 10)) downto 0 do begin + particle := AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12, vgtDust); if particle <> nil then particle^.dX := particle^.dX + (Gear^.dX / 5); - end; + end; if(Gear^.Invulnerable) then exit; - if _0_6 < Gear^.dY then - PlaySound(sndOw4, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack) - else - PlaySound(sndOw1, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack); + if _0_6 < Gear^.dY then + PlaySound(sndOw4, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack) + else + PlaySound(sndOw1, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack); ApplyDamage(Gear, dmg); - end + end end; //////////////////////////////////////////////////////////////////////////////// @@ -121,9 +121,9 @@ begin dAngle:= (hwAbs(Gear^.dX) + hwAbs(Gear^.dY)).QWordValue / $80000000; if not Gear^.dX.isNegative then - Gear^.DirAngle:= Gear^.DirAngle + dAngle + Gear^.DirAngle:= Gear^.DirAngle + dAngle else - Gear^.DirAngle:= Gear^.DirAngle - dAngle; + Gear^.DirAngle:= Gear^.DirAngle - dAngle; if Gear^.DirAngle < 0 then Gear^.DirAngle:= Gear^.DirAngle + 360 else if 360 < Gear^.DirAngle then Gear^.DirAngle:= Gear^.DirAngle - 360 @@ -151,29 +151,29 @@ Gear^.State:= Gear^.State and not gstCollision; if Gear^.dY.isNegative then - begin - isFalling:= true; - if TestCollisionYwithGear(Gear, -1) then - begin - Gear^.dX:= Gear^.dX * Gear^.Friction; - Gear^.dY:= - Gear^.dY * Gear^.Elasticity; - Gear^.State:= Gear^.State or gstCollision - end - end else - if TestCollisionYwithGear(Gear, 1) then - begin - isFalling:= false; - Gear^.dX:= Gear^.dX * Gear^.Friction; - Gear^.dY:= - Gear^.dY * Gear^.Elasticity; - Gear^.State:= Gear^.State or gstCollision - end else isFalling:= true; + begin + isFalling:= true; + if TestCollisionYwithGear(Gear, -1) then + begin + Gear^.dX:= Gear^.dX * Gear^.Friction; + Gear^.dY:= - Gear^.dY * Gear^.Elasticity; + Gear^.State:= Gear^.State or gstCollision + end + end else + if TestCollisionYwithGear(Gear, 1) then + begin + isFalling:= false; + Gear^.dX:= Gear^.dX * Gear^.Friction; + Gear^.dY:= - Gear^.dY * Gear^.Elasticity; + Gear^.State:= Gear^.State or gstCollision + end else isFalling:= true; if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then - begin - Gear^.dX:= - Gear^.dX * Gear^.Elasticity; - Gear^.dY:= Gear^.dY * Gear^.Elasticity; - Gear^.State:= Gear^.State or gstCollision - end; + begin + Gear^.dX:= - Gear^.dX * Gear^.Elasticity; + Gear^.dY:= Gear^.dY * Gear^.Elasticity; + Gear^.State:= Gear^.State or gstCollision + end; if isFalling then Gear^.dY:= Gear^.dY + cGravity; @@ -181,10 +181,10 @@ Gear^.Y:= Gear^.Y + Gear^.dY; CheckGearDrowning(Gear); if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) < _0_0002) and - (not isFalling) then - Gear^.State:= Gear^.State and not gstMoving + (not isFalling) then + Gear^.State:= Gear^.State and not gstMoving else - Gear^.State:= Gear^.State or gstMoving + Gear^.State:= Gear^.State or gstMoving end; //////////////////////////////////////////////////////////////////////////////// @@ -199,97 +199,97 @@ dec(Gear^.Timer); if Gear^.Timer = 1000 then // might need adjustments - case Gear^.Kind of - gtAmmo_Bomb: makeHogsWorry(Gear^.X, Gear^.Y, 50); - gtClusterBomb: makeHogsWorry(Gear^.X, Gear^.Y, 20); - gtWatermelon: makeHogsWorry(Gear^.X, Gear^.Y, 75); - gtHellishBomb: makeHogsWorry(Gear^.X, Gear^.Y, 90); - end; + case Gear^.Kind of + gtAmmo_Bomb: makeHogsWorry(Gear^.X, Gear^.Y, 50); + gtClusterBomb: makeHogsWorry(Gear^.X, Gear^.Y, 20); + gtWatermelon: makeHogsWorry(Gear^.X, Gear^.Y, 75); + gtHellishBomb: makeHogsWorry(Gear^.X, Gear^.Y, 90); + end; if Gear^.Timer = 0 then - begin - case Gear^.Kind of - gtAmmo_Bomb: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); - gtBall: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 40, EXPLAutoSound); - gtClusterBomb: begin - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); - for i:= 0 to 4 do - begin - dX:= rndSign(GetRandom * _0_1); - dY:= (GetRandom - _3) * _0_08; - AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 25); - end - end; - gtWatermelon: begin - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); - for i:= 0 to 5 do - begin - dX:= rndSign(GetRandom * _0_1); - dY:= (GetRandom - _1_5) * _0_3; - AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMelonPiece, 0, dX, dY, 75)^.DirAngle:= i * 60; - end - end; - gtHellishBomb: begin - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 90, EXPLAutoSound); - for i:= 0 to 127 do - begin - dX:= AngleCos(i * 16) * _0_5 * (GetRandom + _1); - dY:= AngleSin(i * 16) * _0_5 * (GetRandom + _1); + begin + case Gear^.Kind of + gtAmmo_Bomb: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); + gtBall: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 40, EXPLAutoSound); + gtClusterBomb: begin + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); + for i:= 0 to 4 do + begin + dX:= rndSign(GetRandom * _0_1); + dY:= (GetRandom - _3) * _0_08; + AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 25); + end + end; + gtWatermelon: begin + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); + for i:= 0 to 5 do + begin + dX:= rndSign(GetRandom * _0_1); + dY:= (GetRandom - _1_5) * _0_3; + AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMelonPiece, 0, dX, dY, 75)^.DirAngle:= i * 60; + end + end; + gtHellishBomb: begin + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 90, EXPLAutoSound); + for i:= 0 to 127 do + begin + dX:= AngleCos(i * 16) * _0_5 * (GetRandom + _1); + dY:= AngleSin(i * 16) * _0_5 * (GetRandom + _1); Fire:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, dY, 0); if i mod 2 = 0 then Fire^.State:= Fire^.State or gsttmpFlag; Fire:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, -dY, 0); if i mod 2 <> 0 then Fire^.State:= Fire^.State or gsttmpFlag; - end - end; - end; - DeleteGear(Gear); - exit - end; + end + end; + end; + DeleteGear(Gear); + exit + end; CalcRotationDirAngle(Gear); if Gear^.Kind = gtHellishBomb then - begin - if Gear^.Timer = 3000 then PlaySound(sndHellish); + begin + if Gear^.Timer = 3000 then PlaySound(sndHellish); - if (GameTicks and $3F) = 0 then - if (Gear^.State and gstCollision) = 0 then - AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtEvilTrace, 0, _0, _0, 0); - end; + if (GameTicks and $3F) = 0 then + if (Gear^.State and gstCollision) = 0 then + AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtEvilTrace, 0, _0, _0, 0); + end; if (Gear^.State and (gstCollision or gstMoving)) = (gstCollision or gstMoving) then - if (hwAbs(Gear^.dX) > _0_1) or - (hwAbs(Gear^.dY) > _0_1) then - PlaySound(sndGrenadeImpact) + if (hwAbs(Gear^.dX) > _0_1) or + (hwAbs(Gear^.dY) > _0_1) then + PlaySound(sndGrenadeImpact) end; //////////////////////////////////////////////////////////////////////////////// procedure doStepMolotov(Gear: PGear); var i: LongInt; dX, dY: hwFloat; - Fire: PGear; + Fire: PGear; begin - AllInactive:= false; - - doStepFallingGear(Gear); - CalcRotationDirAngle(Gear); + AllInactive:= false; + + doStepFallingGear(Gear); + CalcRotationDirAngle(Gear); - if (Gear^.State and gstCollision) <> 0 then begin - PlaySound(sndMolotov); - //doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 5, EXPLAutoSound); - for i:= 0 to 20 do begin - dX:= AngleCos(i * 2) * ((_0_1*(i div 5))) * (GetRandom + _1); - dY:= AngleSin(i * 8) * _0_5 * (GetRandom + _1); - Fire:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, dY, 0); - Fire^.State:= Fire^.State or gsttmpFlag; - Fire:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, -dY, 0); - Fire^.State:= Fire^.State or gsttmpFlag; - Fire:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, -dX, dY, 0); - Fire^.State:= Fire^.State or gsttmpFlag; - Fire:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, -dX, -dY, 0); - Fire^.State:= Fire^.State or gsttmpFlag; - end; - DeleteGear(Gear); - exit - end; + if (Gear^.State and gstCollision) <> 0 then begin + PlaySound(sndMolotov); + //doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 5, EXPLAutoSound); + for i:= 0 to 20 do begin + dX:= AngleCos(i * 2) * ((_0_1*(i div 5))) * (GetRandom + _1); + dY:= AngleSin(i * 8) * _0_5 * (GetRandom + _1); + Fire:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, dY, 0); + Fire^.State:= Fire^.State or gsttmpFlag; + Fire:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, -dY, 0); + Fire^.State:= Fire^.State or gsttmpFlag; + Fire:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, -dX, dY, 0); + Fire^.State:= Fire^.State or gsttmpFlag; + Fire:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, -dX, -dY, 0); + Fire^.State:= Fire^.State or gsttmpFlag; + end; + DeleteGear(Gear); + exit + end; end; procedure doStepWatermelon(Gear: PGear); @@ -303,17 +303,17 @@ AllInactive:= false; doStepFallingGear(Gear); if (Gear^.State and gstCollision) <> 0 then - begin - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Timer, EXPLAutoSound); - DeleteGear(Gear); - exit - end; + begin + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Timer, EXPLAutoSound); + DeleteGear(Gear); + exit + end; if Gear^.Kind = gtMelonPiece then - CalcRotationDirAngle(Gear) + CalcRotationDirAngle(Gear) else - if (GameTicks and $1F) = 0 then - AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) + if (GameTicks and $1F) = 0 then + AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) end; //////////////////////////////////////////////////////////////////////////////// @@ -323,30 +323,30 @@ Gear^.dX:= Gear^.dX + cWindSpeed; doStepFallingGear(Gear); if (Gear^.State and gstCollision) <> 0 then - begin - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); - DeleteGear(Gear); - exit - end; + begin + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); + DeleteGear(Gear); + exit + end; if (GameTicks and $3F) = 0 then - AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) + AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) end; //////////////////////////////////////////////////////////////////////////////// procedure doStepHealthTagWork(Gear: PGear); begin if Gear^.Kind = gtHealthTag then - AllInactive:= false; + AllInactive:= false; dec(Gear^.Timer); Gear^.Y:= Gear^.Y + Gear^.dY; if Gear^.Timer = 0 then - begin - if (Gear^.Kind = gtHealthTag) and (PHedgehog(Gear^.Hedgehog)^.Gear <> nil) then - PHedgehog(Gear^.Hedgehog)^.Gear^.Active:= true; // to let current hh die - DeleteGear(Gear) - end + begin + if (Gear^.Kind = gtHealthTag) and (PHedgehog(Gear^.Hedgehog)^.Gear <> nil) then + PHedgehog(Gear^.Hedgehog)^.Gear^.Active:= true; // to let current hh die + DeleteGear(Gear) + end end; procedure doStepHealthTagWorkUnderWater(Gear: PGear); @@ -356,7 +356,7 @@ Gear^.Y:= Gear^.Y - _0_08; if hwRound(Gear^.Y) < cWaterLine + 10 then - DeleteGear(Gear) + DeleteGear(Gear) end; procedure doStepHealthTag(Gear: PGear); @@ -369,9 +369,9 @@ Gear^.Tex:= RenderStringTex(s, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color, fnt16); if hwRound(Gear^.Y) < cWaterLine then - Gear^.doStep:= @doStepHealthTagWork + Gear^.doStep:= @doStepHealthTagWork else - Gear^.doStep:= @doStepHealthTagWorkUnderWater; + Gear^.doStep:= @doStepHealthTagWorkUnderWater; Gear^.Y:= Gear^.Y - int2hwFloat(Gear^.Tex^.h) end; @@ -459,10 +459,10 @@ AllInactive:= false; inc(Gear^.Timer); if Gear^.Timer > 75 then - begin - DeleteGear(Gear); - AfterAttack - end + begin + DeleteGear(Gear); + AfterAttack + end end; procedure doStepShotgunShot(Gear: PGear); @@ -472,23 +472,23 @@ AllInactive:= false; if ((Gear^.State and gstAnimation) = 0) then - begin - dec(Gear^.Timer); - if Gear^.Timer = 0 then - begin - PlaySound(sndShotgunFire); - shell:= AddVisualGear(hwRound(Gear^.x), hwRound(Gear^.y), vgtShell); + begin + dec(Gear^.Timer); + if Gear^.Timer = 0 then + begin + PlaySound(sndShotgunFire); + shell:= AddVisualGear(hwRound(Gear^.x), hwRound(Gear^.y), vgtShell); if shell <> nil then begin shell^.dX:= gear^.dX / -4; shell^.dY:= gear^.dY / -4; shell^.Frame:= 0 end; - Gear^.State:= Gear^.State or gstAnimation - end; - exit - end - else inc(Gear^.Timer); + Gear^.State:= Gear^.State or gstAnimation + end; + exit + end + else inc(Gear^.Timer); i:= 200; repeat @@ -496,17 +496,17 @@ Gear^.Y:= Gear^.Y + Gear^.dY; CheckCollision(Gear); if (Gear^.State and gstCollision) <> 0 then - begin - Gear^.X:= Gear^.X + Gear^.dX * 8; - Gear^.Y:= Gear^.Y + Gear^.dY * 8; - ShotgunShot(Gear); - Gear^.doStep:= @doStepShotIdle; - exit - end; + begin + Gear^.X:= Gear^.X + Gear^.dX * 8; + Gear^.Y:= Gear^.Y + Gear^.dY * 8; + ShotgunShot(Gear); + Gear^.doStep:= @doStepShotIdle; + exit + end; dec(i) until i = 0; if (hwRound(Gear^.X) and LAND_WIDTH_MASK <> 0) or (hwRound(Gear^.Y) and LAND_HEIGHT_MASK <> 0) then - Gear^.doStep:= @doStepShotIdle + Gear^.doStep:= @doStepShotIdle end; //////////////////////////////////////////////////////////////////////////////// @@ -541,13 +541,13 @@ end; if (Gear^.Health <= 0) - or (hwRound(Gear^.X) and LAND_WIDTH_MASK <> 0) - or (hwRound(Gear^.Y) and LAND_HEIGHT_MASK <> 0) then + or (hwRound(Gear^.X) and LAND_WIDTH_MASK <> 0) + or (hwRound(Gear^.Y) and LAND_HEIGHT_MASK <> 0) then begin if (Gear^.Kind = gtSniperRifleShot) and ((GameFlags and gfLaserSight) = 0) then cLaserSighting:= false; if (Gear^.Ammo^.NumPerTurn <= CurrentHedgehog^.MultiShootAttacks) and ((GameFlags and gfArtillery) = 0) then cArtillery:= false; - Gear^.doStep:= @doStepShotIdle + Gear^.doStep:= @doStepShotIdle end; end; @@ -600,8 +600,8 @@ dec(TurnTimeLeft) else begin - DeleteGear(Gear); - AfterAttack + DeleteGear(Gear); + AfterAttack end; end; @@ -645,48 +645,48 @@ HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; dec(Gear^.Timer); if (Gear^.Timer = 0)or((Gear^.Message and gm_Destroy) <> 0)or((HHGear^.State and gstHHDriven) = 0) then - begin - StopSound(Gear^.SoundChannel); - DeleteGear(Gear); - AfterAttack; - exit - end; + begin + StopSound(Gear^.SoundChannel); + DeleteGear(Gear); + AfterAttack; + exit + end; if (Gear^.Timer mod 33) = 0 then - begin - HHGear^.State:= HHGear^.State or gstNoDamage; - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y) + 7, 6, EXPLDontDraw); - HHGear^.State:= HHGear^.State and not gstNoDamage - end; + begin + HHGear^.State:= HHGear^.State or gstNoDamage; + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y) + 7, 6, EXPLDontDraw); + HHGear^.State:= HHGear^.State and not gstNoDamage + end; if (Gear^.Timer mod 47) = 0 then - begin - i:= hwRound(Gear^.X) - Gear^.Radius - LongInt(GetRandom(2)); - ei:= hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2)); - while i <= ei do - begin - DrawExplosion(i, hwRound(Gear^.Y) + 3, 3); - inc(i, 1) - end; + begin + i:= hwRound(Gear^.X) - Gear^.Radius - LongInt(GetRandom(2)); + ei:= hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2)); + while i <= ei do + begin + DrawExplosion(i, hwRound(Gear^.Y) + 3, 3); + inc(i, 1) + end; if CheckLandValue(hwRound(Gear^.X + Gear^.dX + SignAs(_6,Gear^.dX)), hwRound(Gear^.Y + _1_9), COLOR_INDESTRUCTIBLE) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.Y:= Gear^.Y + _1_9; end; - SetAllHHToActive; - end; + SetAllHHToActive; + end; if TestCollisionYwithGear(Gear, 1) then - begin - Gear^.dY:= _0; - SetLittle(HHGear^.dX); - HHGear^.dY:= _0; - end else - begin - Gear^.dY:= Gear^.dY + cGravity; - Gear^.Y:= Gear^.Y + Gear^.dY; - if hwRound(Gear^.Y) > cWaterLine then Gear^.Timer:= 1 - end; + begin + Gear^.dY:= _0; + SetLittle(HHGear^.dX); + HHGear^.dY:= _0; + end else + begin + Gear^.dY:= Gear^.dY + cGravity; + Gear^.Y:= Gear^.Y + Gear^.dY; + if hwRound(Gear^.Y) > cWaterLine then Gear^.Timer:= 1 + end; Gear^.X:= Gear^.X + HHGear^.dX; HHGear^.X:= Gear^.X; @@ -731,8 +731,8 @@ procedure doStepBlowTorchWork(Gear: PGear); var HHGear: PGear; - b: boolean; - prevX: LongInt; + b: boolean; + prevX: LongInt; begin AllInactive:= false; dec(Gear^.Timer); @@ -743,31 +743,31 @@ b:= false; if abs(LongInt(HHGear^.Angle) - BTPrevAngle) > 7 then - begin - Gear^.dX:= SignAs(AngleSin(HHGear^.Angle) * _0_5, HHGear^.dX); - Gear^.dY:= AngleCos(HHGear^.Angle) * ( - _0_5); - BTPrevAngle:= HHGear^.Angle; - b:= true - end; + begin + Gear^.dX:= SignAs(AngleSin(HHGear^.Angle) * _0_5, HHGear^.dX); + Gear^.dY:= AngleCos(HHGear^.Angle) * ( - _0_5); + BTPrevAngle:= HHGear^.Angle; + b:= true + end; if ((HHGear^.State and gstMoving) <> 0) then - begin - doStepHedgehogMoving(HHGear); - if (HHGear^.State and gstHHDriven) = 0 then Gear^.Timer:= 0 - end; + begin + doStepHedgehogMoving(HHGear); + if (HHGear^.State and gstHHDriven) = 0 then Gear^.Timer:= 0 + end; if Gear^.Timer mod cHHStepTicks = 0 then - begin - b:= true; - if Gear^.dX.isNegative then - HHGear^.Message:= (HHGear^.Message and (gm_Attack or gm_Up or gm_Down)) or gm_Left - else - HHGear^.Message:= (HHGear^.Message and (gm_Attack or gm_Up or gm_Down)) or gm_Right; + begin + b:= true; + if Gear^.dX.isNegative then + HHGear^.Message:= (HHGear^.Message and (gm_Attack or gm_Up or gm_Down)) or gm_Left + else + HHGear^.Message:= (HHGear^.Message and (gm_Attack or gm_Up or gm_Down)) or gm_Right; - if ((HHGear^.State and gstMoving) = 0) then - begin - HHGear^.State:= HHGear^.State and not gstAttacking; - prevX:= hwRound(HHGear^.X); + if ((HHGear^.State and gstMoving) = 0) then + begin + HHGear^.State:= HHGear^.State and not gstAttacking; + prevX:= hwRound(HHGear^.X); // why the call to HedgehogStep then a further increment of X? if (prevX = hwRound(HHGear^.X)) and @@ -775,23 +775,23 @@ if (prevX = hwRound(HHGear^.X)) and CheckLandValue(hwRound(HHGear^.X + SignAs(_6, HHGear^.dX)), hwRound(HHGear^.Y), COLOR_INDESTRUCTIBLE) then HHGear^.X:= HHGear^.X + SignAs(_1, HHGear^.dX); - HHGear^.State:= HHGear^.State or gstAttacking - end; + HHGear^.State:= HHGear^.State or gstAttacking + end; - inc(BTSteps); - if BTSteps = 7 then - begin - BTSteps:= 0; + inc(BTSteps); + if BTSteps = 7 then + begin + BTSteps:= 0; if CheckLandValue(hwRound(HHGear^.X + Gear^.dX * (cHHRadius + cBlowTorchC) + SignAs(_6,Gear^.dX)), hwRound(HHGear^.Y + Gear^.dY * (cHHRadius + cBlowTorchC)), COLOR_INDESTRUCTIBLE) then begin - Gear^.X:= HHGear^.X + Gear^.dX * (cHHRadius + cBlowTorchC); - Gear^.Y:= HHGear^.Y + Gear^.dY * (cHHRadius + cBlowTorchC); + Gear^.X:= HHGear^.X + Gear^.dX * (cHHRadius + cBlowTorchC); + Gear^.Y:= HHGear^.Y + Gear^.dY * (cHHRadius + cBlowTorchC); end; - HHGear^.State:= HHGear^.State or gstNoDamage; - AmmoShove(Gear, 2, 15); - HHGear^.State:= HHGear^.State and not gstNoDamage - end; - end; + HHGear^.State:= HHGear^.State or gstNoDamage; + AmmoShove(Gear, 2, 15); + HHGear^.State:= HHGear^.State and not gstNoDamage + end; + end; if b then DrawTunnel(HHGear^.X - Gear^.dX * cHHRadius, HHGear^.Y - _4 - Gear^.dY * cHHRadius + hwAbs(Gear^.dY) * 7, @@ -799,12 +799,12 @@ cHHRadius * 5, cHHRadius * 2 + 7); if (Gear^.Timer = 0) or ((HHGear^.Message and gm_Attack) <> 0) then - begin - HHGear^.Message:= 0; - HHGear^.State:= HHGear^.State and (not gstNotKickable); - DeleteGear(Gear); - AfterAttack - end + begin + HHGear^.Message:= 0; + HHGear^.State:= HHGear^.State and (not gstNotKickable); + DeleteGear(Gear); + AfterAttack + end end; procedure doStepBlowTorch(Gear: PGear); @@ -827,13 +827,13 @@ begin HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; if ((HHGear^.State and gstHHDriven) = 0) - or (CheckGearDrowning(HHGear)) - or TestCollisionYwithGear(HHGear, 1) then - begin - DeleteGear(Gear); - isCursorVisible:= false; - exit - end; + or (CheckGearDrowning(HHGear)) + or TestCollisionYwithGear(HHGear, 1) then + begin + DeleteGear(Gear); + isCursorVisible:= false; + exit + end; HedgehogChAngle(HHGear); @@ -845,59 +845,59 @@ HHGear^.dY:= HHGear^.dY + cGravity; if (Gear^.Message and gm_Attack) <> 0 then - begin - Gear^.X:= HHGear^.X; - Gear^.Y:= HHGear^.Y; + begin + Gear^.X:= HHGear^.X; + Gear^.Y:= HHGear^.Y; - ApplyAngleBounds(PHedgehog(Gear^.Hedgehog)^, amRope); + ApplyAngleBounds(PHedgehog(Gear^.Hedgehog)^, amRope); - Gear^.dX:= SignAs(AngleSin(HHGear^.Angle), HHGear^.dX); - Gear^.dY:= -AngleCos(HHGear^.Angle); - Gear^.Friction:= _450; - Gear^.Elasticity:= _0; - Gear^.State:= Gear^.State and not gsttmpflag; - Gear^.doStep:= @doStepRope - end + Gear^.dX:= SignAs(AngleSin(HHGear^.Angle), HHGear^.dX); + Gear^.dY:= -AngleCos(HHGear^.Angle); + Gear^.Friction:= _450; + Gear^.Elasticity:= _0; + Gear^.State:= Gear^.State and not gsttmpflag; + Gear^.doStep:= @doStepRope + end end; procedure doStepRopeWork(Gear: PGear); var HHGear: PGear; - len, tx, ty, nx, ny, ropeDx, ropeDy, mdX, mdY: hwFloat; - lx, ly: LongInt; - haveCollision, - haveDivided: boolean; + len, tx, ty, nx, ny, ropeDx, ropeDy, mdX, mdY: hwFloat; + lx, ly: LongInt; + haveCollision, + haveDivided: boolean; - procedure DeleteMe; - begin - with HHGear^ do - begin - Message:= Message and not gm_Attack; - State:= (State or gstMoving) and not gstWinner; - end; - DeleteGear(Gear) - end; + procedure DeleteMe; + begin + with HHGear^ do + begin + Message:= Message and not gm_Attack; + State:= (State or gstMoving) and not gstWinner; + end; + DeleteGear(Gear) + end; - procedure WaitCollision; - begin - with HHGear^ do - begin - Message:= Message and not gm_Attack; - State:= State or gstMoving; - end; - RopePoints.Count:= 0; - Gear^.Elasticity:= _0; - Gear^.doStep:= @doStepRopeAfterAttack - end; + procedure WaitCollision; + begin + with HHGear^ do + begin + Message:= Message and not gm_Attack; + State:= State or gstMoving; + end; + RopePoints.Count:= 0; + Gear^.Elasticity:= _0; + Gear^.doStep:= @doStepRopeAfterAttack + end; begin HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; if ((HHGear^.State and gstHHDriven) = 0) - or (CheckGearDrowning(HHGear)) then - begin - DeleteMe; - exit - end; + or (CheckGearDrowning(HHGear)) then + begin + DeleteMe; + exit + end; if (Gear^.Message and gm_Left <> 0) then HHGear^.dX:= HHGear^.dX - _0_0002 else if (Gear^.Message and gm_Right <> 0) then HHGear^.dX:= HHGear^.dX + _0_0002; @@ -917,135 +917,135 @@ Gear^.dY:= mdY; ///// - tx:= HHGear^.X; - ty:= HHGear^.Y; + tx:= HHGear^.X; + ty:= HHGear^.Y; - if ((Gear^.Message and gm_Down) <> 0) and (Gear^.Elasticity < Gear^.Friction) then - if not (TestCollisionXwithGear(HHGear, hwSign(ropeDx)) - or TestCollisionYwithGear(HHGear, hwSign(ropeDy))) then - Gear^.Elasticity:= Gear^.Elasticity + _0_3; + if ((Gear^.Message and gm_Down) <> 0) and (Gear^.Elasticity < Gear^.Friction) then + if not (TestCollisionXwithGear(HHGear, hwSign(ropeDx)) + or TestCollisionYwithGear(HHGear, hwSign(ropeDy))) then + Gear^.Elasticity:= Gear^.Elasticity + _0_3; - if ((Gear^.Message and gm_Up) <> 0) and (Gear^.Elasticity > _30) then - if not (TestCollisionXwithGear(HHGear, -hwSign(ropeDx)) - or TestCollisionYwithGear(HHGear, -hwSign(ropeDy))) then - Gear^.Elasticity:= Gear^.Elasticity - _0_3; + if ((Gear^.Message and gm_Up) <> 0) and (Gear^.Elasticity > _30) then + if not (TestCollisionXwithGear(HHGear, -hwSign(ropeDx)) + or TestCollisionYwithGear(HHGear, -hwSign(ropeDy))) then + Gear^.Elasticity:= Gear^.Elasticity - _0_3; - HHGear^.X:= Gear^.X + mdX * Gear^.Elasticity; - HHGear^.Y:= Gear^.Y + mdY * Gear^.Elasticity; + HHGear^.X:= Gear^.X + mdX * Gear^.Elasticity; + HHGear^.Y:= Gear^.Y + mdY * Gear^.Elasticity; - HHGear^.dX:= HHGear^.X - tx; - HHGear^.dY:= HHGear^.Y - ty; + HHGear^.dX:= HHGear^.X - tx; + HHGear^.dY:= HHGear^.Y - ty; //// - haveDivided:= false; - // check whether rope needs dividing - len:= _1 / Distance(ropeDx, ropeDy); // old rope pos - nx:= ropeDx * len; - ny:= ropeDy * len; + haveDivided:= false; + // check whether rope needs dividing + len:= _1 / Distance(ropeDx, ropeDy); // old rope pos + nx:= ropeDx * len; + ny:= ropeDy * len; - len:= Gear^.Elasticity - _0_3x70; - while len > _3 do - begin - lx:= hwRound(Gear^.X + mdX * len); - ly:= hwRound(Gear^.Y + mdY * len); - if ((ly and LAND_HEIGHT_MASK) = 0) and ((lx and LAND_WIDTH_MASK) = 0) and (Land[ly, lx] <> 0) then - begin - with RopePoints.ar[RopePoints.Count] do - begin - X:= Gear^.X; - Y:= Gear^.Y; - if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle(Gear^.dY, Gear^.dX); - b:= (nx * HHGear^.dY) > (ny * HHGear^.dX); - dLen:= len - end; - with RopePoints.rounded[RopePoints.Count] do - begin - X:= hwRound(Gear^.X); - Y:= hwRound(Gear^.Y); - end; + len:= Gear^.Elasticity - _0_3x70; + while len > _3 do + begin + lx:= hwRound(Gear^.X + mdX * len); + ly:= hwRound(Gear^.Y + mdY * len); + if ((ly and LAND_HEIGHT_MASK) = 0) and ((lx and LAND_WIDTH_MASK) = 0) and (Land[ly, lx] <> 0) then + begin + with RopePoints.ar[RopePoints.Count] do + begin + X:= Gear^.X; + Y:= Gear^.Y; + if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle(Gear^.dY, Gear^.dX); + b:= (nx * HHGear^.dY) > (ny * HHGear^.dX); + dLen:= len + end; + with RopePoints.rounded[RopePoints.Count] do + begin + X:= hwRound(Gear^.X); + Y:= hwRound(Gear^.Y); + end; - Gear^.X:= Gear^.X + nx * len; - Gear^.Y:= Gear^.Y + ny * len; - inc(RopePoints.Count); - TryDo(RopePoints.Count <= MAXROPEPOINTS, 'Rope points overflow', true); - Gear^.Elasticity:= Gear^.Elasticity - len; - Gear^.Friction:= Gear^.Friction - len; - haveDivided:= true; - break - end; - len:= len - _0_3 // should be the same as increase step - end; + Gear^.X:= Gear^.X + nx * len; + Gear^.Y:= Gear^.Y + ny * len; + inc(RopePoints.Count); + TryDo(RopePoints.Count <= MAXROPEPOINTS, 'Rope points overflow', true); + Gear^.Elasticity:= Gear^.Elasticity - len; + Gear^.Friction:= Gear^.Friction - len; + haveDivided:= true; + break + end; + len:= len - _0_3 // should be the same as increase step + end; if not haveDivided then - if RopePoints.Count > 0 then // check whether the last dividing point could be removed - begin - tx:= RopePoints.ar[Pred(RopePoints.Count)].X; - ty:= RopePoints.ar[Pred(RopePoints.Count)].Y; - if RopePoints.ar[Pred(RopePoints.Count)].b xor ((tx - Gear^.X) * (ty - HHGear^.Y) > (tx - HHGear^.X) * (ty - Gear^.Y)) then - begin - dec(RopePoints.Count); - Gear^.X:= RopePoints.ar[RopePoints.Count].X; - Gear^.Y:= RopePoints.ar[RopePoints.Count].Y; - Gear^.Elasticity:= Gear^.Elasticity + RopePoints.ar[RopePoints.Count].dLen; - Gear^.Friction:= Gear^.Friction + RopePoints.ar[RopePoints.Count].dLen - end - end; + if RopePoints.Count > 0 then // check whether the last dividing point could be removed + begin + tx:= RopePoints.ar[Pred(RopePoints.Count)].X; + ty:= RopePoints.ar[Pred(RopePoints.Count)].Y; + if RopePoints.ar[Pred(RopePoints.Count)].b xor ((tx - Gear^.X) * (ty - HHGear^.Y) > (tx - HHGear^.X) * (ty - Gear^.Y)) then + begin + dec(RopePoints.Count); + Gear^.X:= RopePoints.ar[RopePoints.Count].X; + Gear^.Y:= RopePoints.ar[RopePoints.Count].Y; + Gear^.Elasticity:= Gear^.Elasticity + RopePoints.ar[RopePoints.Count].dLen; + Gear^.Friction:= Gear^.Friction + RopePoints.ar[RopePoints.Count].dLen + end + end; haveCollision:= false; if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then - begin - HHGear^.dX:= -_0_6 * HHGear^.dX; - haveCollision:= true - end; + begin + HHGear^.dX:= -_0_6 * HHGear^.dX; + haveCollision:= true + end; if TestCollisionYwithGear(HHGear, hwSign(HHGear^.dY)) then - begin - HHGear^.dY:= -_0_6 * HHGear^.dY; - haveCollision:= true - end; + begin + HHGear^.dY:= -_0_6 * HHGear^.dY; + haveCollision:= true + end; if haveCollision - and (Gear^.Message and (gm_Left or gm_Right) <> 0) - and (Gear^.Message and (gm_Up or gm_Down) <> 0) then - begin - HHGear^.dX:= SignAs(hwAbs(HHGear^.dX) + _0_2, HHGear^.dX); - HHGear^.dY:= SignAs(hwAbs(HHGear^.dY) + _0_2, HHGear^.dY) - end; + and (Gear^.Message and (gm_Left or gm_Right) <> 0) + and (Gear^.Message and (gm_Up or gm_Down) <> 0) then + begin + HHGear^.dX:= SignAs(hwAbs(HHGear^.dX) + _0_2, HHGear^.dX); + HHGear^.dY:= SignAs(hwAbs(HHGear^.dY) + _0_2, HHGear^.dY) + end; len:= Distance(HHGear^.dX, HHGear^.dY); if len > _0_8 then - begin - len:= _0_8 / len; - HHGear^.dX:= HHGear^.dX * len; - HHGear^.dY:= HHGear^.dY * len; - end; + begin + len:= _0_8 / len; + HHGear^.dX:= HHGear^.dX * len; + HHGear^.dY:= HHGear^.dY * len; + end; if (Gear^.Message and gm_Attack) <> 0 then - if (Gear^.State and gsttmpFlag) <> 0 then - with PHedgehog(Gear^.Hedgehog)^ do - if Ammo^[CurSlot, CurAmmo].AmmoType <> amParachute then - WaitCollision - else - DeleteMe - else + if (Gear^.State and gsttmpFlag) <> 0 then + with PHedgehog(Gear^.Hedgehog)^ do + if Ammo^[CurSlot, CurAmmo].AmmoType <> amParachute then + WaitCollision + else + DeleteMe + else else - if (Gear^.State and gsttmpFlag) = 0 then - Gear^.State:= Gear^.State or gsttmpFlag; + if (Gear^.State and gsttmpFlag) = 0 then + Gear^.State:= Gear^.State or gsttmpFlag; end; procedure doStepRopeAttach(Gear: PGear); var HHGear: PGear; - tx, ty, tt: hwFloat; + tx, ty, tt: hwFloat; - procedure RemoveFromAmmo; - begin - if (Gear^.State and gstAttacked) = 0 then - begin - OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); - Gear^.State:= Gear^.State or gstAttacked - end; - ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^) - end; + procedure RemoveFromAmmo; + begin + if (Gear^.State and gstAttacked) = 0 then + begin + OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); + Gear^.State:= Gear^.State or gstAttacked + end; + ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^) + end; begin Gear^.X:= Gear^.X - Gear^.dX; @@ -1056,77 +1056,77 @@ DeleteCI(HHGear); if (HHGear^.State and gstMoving) <> 0 then - begin - if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); - if HHGear^.dY.isNegative and TestCollisionYwithGear(HHGear, -1) then HHGear^.dY:= _0; + begin + if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); + if HHGear^.dY.isNegative and TestCollisionYwithGear(HHGear, -1) then HHGear^.dY:= _0; - HHGear^.X:= HHGear^.X + HHGear^.dX; - Gear^.X:= Gear^.X + HHGear^.dX; + HHGear^.X:= HHGear^.X + HHGear^.dX; + Gear^.X:= Gear^.X + HHGear^.dX; - if TestCollisionYwithGear(HHGear, 1) then - begin - CheckHHDamage(HHGear); - HHGear^.dY:= _0; - //HHGear^.State:= HHGear^.State and not (gstHHJumping or gstHHHJump); - end else - begin - HHGear^.Y:= HHGear^.Y + HHGear^.dY; - Gear^.Y:= Gear^.Y + HHGear^.dY; - HHGear^.dY:= HHGear^.dY + cGravity; - end; - - tt:= Gear^.Elasticity; - tx:= _0; - ty:= _0; - while tt > _20 do - begin - if TestCollisionXwithXYShift(Gear, tx, hwRound(ty), -hwSign(Gear^.dX)) - or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), -hwSign(Gear^.dY)) then - begin - Gear^.X:= Gear^.X + tx; - Gear^.Y:= Gear^.Y + ty; - Gear^.Elasticity:= tt; - Gear^.doStep:= @doStepRopeWork; - with HHGear^ do State:= State and not (gstAttacking or gstHHJumping or gstHHHJump); + if TestCollisionYwithGear(HHGear, 1) then + begin + CheckHHDamage(HHGear); + HHGear^.dY:= _0; + //HHGear^.State:= HHGear^.State and not (gstHHJumping or gstHHHJump); + end else + begin + HHGear^.Y:= HHGear^.Y + HHGear^.dY; + Gear^.Y:= Gear^.Y + HHGear^.dY; + HHGear^.dY:= HHGear^.dY + cGravity; + end; + + tt:= Gear^.Elasticity; + tx:= _0; + ty:= _0; + while tt > _20 do + begin + if TestCollisionXwithXYShift(Gear, tx, hwRound(ty), -hwSign(Gear^.dX)) + or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), -hwSign(Gear^.dY)) then + begin + Gear^.X:= Gear^.X + tx; + Gear^.Y:= Gear^.Y + ty; + Gear^.Elasticity:= tt; + Gear^.doStep:= @doStepRopeWork; + with HHGear^ do State:= State and not (gstAttacking or gstHHJumping or gstHHHJump); - RemoveFromAmmo; + RemoveFromAmmo; - tt:= _0; - exit - end; - tx:= tx + Gear^.dX + Gear^.dX; - ty:= ty + Gear^.dY + Gear^.dY; - tt:= tt - _2; - end; - end; + tt:= _0; + exit + end; + tx:= tx + Gear^.dX + Gear^.dX; + ty:= ty + Gear^.dY + Gear^.dY; + tt:= tt - _2; + end; + end; CheckCollision(Gear); if (Gear^.State and gstCollision) <> 0 then - if Gear^.Elasticity < _10 then - Gear^.Elasticity:= _10000 - else - begin - Gear^.doStep:= @doStepRopeWork; - with HHGear^ do State:= State and not (gstAttacking or gstHHJumping or gstHHHJump); + if Gear^.Elasticity < _10 then + Gear^.Elasticity:= _10000 + else + begin + Gear^.doStep:= @doStepRopeWork; + with HHGear^ do State:= State and not (gstAttacking or gstHHJumping or gstHHHJump); - RemoveFromAmmo; + RemoveFromAmmo; - exit - end; + exit + end; if (Gear^.Elasticity > Gear^.Friction) or ((Gear^.Message and gm_Attack) = 0) or ((HHGear^.State and gstHHDriven) = 0) or (HHGear^.Damage > 0) then - begin - with PHedgehog(Gear^.Hedgehog)^.Gear^ do - begin - State:= State and not gstAttacking; - Message:= Message and not gm_Attack - end; - DeleteGear(Gear) - end + begin + with PHedgehog(Gear^.Hedgehog)^.Gear^ do + begin + State:= State and not gstAttacking; + Message:= Message and not gm_Attack + end; + DeleteGear(Gear) + end end; procedure doStepRope(Gear: PGear); @@ -1141,10 +1141,10 @@ begin inc(Gear^.Timer); if Gear^.Timer > 64 then - begin - Gear^.Timer:= 0; - dec(Gear^.State) - end; + begin + Gear^.Timer:= 0; + dec(Gear^.State) + end; Gear^.dX:= Gear^.dX + cWindSpeed; Gear^.X:= Gear^.X + Gear^.dX; if Gear^.State = 0 then DeleteGear(Gear) @@ -1155,11 +1155,11 @@ begin inc(Gear^.Timer); if Gear^.Timer > 75 then - begin - inc(Gear^.State); - Gear^.Timer:= 0; - if Gear^.State > 5 then DeleteGear(Gear) - end; + begin + inc(Gear^.State); + Gear^.Timer:= 0; + if Gear^.State > 5 then DeleteGear(Gear) + end; end; procedure doStepExplosion(Gear: PGear); @@ -1175,50 +1175,50 @@ procedure doStepMine(Gear: PGear); begin if (Gear^.State and gstMoving) <> 0 then - begin - DeleteCI(Gear); - doStepFallingGear(Gear); - if (Gear^.State and gstMoving) = 0 then - begin - AddGearCI(Gear); - Gear^.dX:= _0; - Gear^.dY:= _0 - end; - CalcRotationDirAngle(Gear); - AllInactive:= false - end else - if ((GameTicks and $3F) = 25) then - doStepFallingGear(Gear); + begin + DeleteCI(Gear); + doStepFallingGear(Gear); + if (Gear^.State and gstMoving) = 0 then + begin + AddGearCI(Gear); + Gear^.dX:= _0; + Gear^.dY:= _0 + end; + CalcRotationDirAngle(Gear); + AllInactive:= false + end else + if ((GameTicks and $3F) = 25) then + doStepFallingGear(Gear); if ((Gear^.State and gsttmpFlag) <> 0) and (Gear^.Health <> 0) then - if ((Gear^.State and gstAttacking) = 0) then - begin - if ((GameTicks and $1F) = 0) then - if CheckGearNear(Gear, gtHedgehog, 46, 32) <> nil then Gear^.State:= Gear^.State or gstAttacking - end else // gstAttacking <> 0 - begin - AllInactive:= false; - if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick); - if Gear^.Timer = 0 then - begin + if ((Gear^.State and gstAttacking) = 0) then + begin + if ((GameTicks and $1F) = 0) then + if CheckGearNear(Gear, gtHedgehog, 46, 32) <> nil then Gear^.State:= Gear^.State or gstAttacking + end else // gstAttacking <> 0 + begin + AllInactive:= false; + if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick); + if Gear^.Timer = 0 then + begin if ((Gear^.State and gstWait) <> 0) or (cMineDudPercent = 0) or - (getRandom(100) > cMineDudPercent) then + (getRandom(100) > cMineDudPercent) then begin - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); - DeleteGear(Gear) + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); + DeleteGear(Gear) end else begin - AddVisualGear(hwRound(Gear^.X) - 4 + Random(8), hwRound(Gear^.Y) - 4 - Random(4), vgtSmoke); - PlaySound(sndVaporize); + AddVisualGear(hwRound(Gear^.X) - 4 + Random(8), hwRound(Gear^.Y) - 4 - Random(4), vgtSmoke); + PlaySound(sndVaporize); Gear^.Health:= 0; end; - exit - end; - dec(Gear^.Timer); - end else // gsttmpFlag = 0 - if TurnTimeLeft = 0 then Gear^.State:= Gear^.State or gsttmpFlag; + exit + end; + dec(Gear^.Timer); + end else // gsttmpFlag = 0 + if TurnTimeLeft = 0 then Gear^.State:= Gear^.State or gsttmpFlag; end; //////////////////////////////////////////////////////////////////////////////// @@ -1228,13 +1228,13 @@ AllInactive:= false; if Gear^.Timer mod 166 = 0 then inc(Gear^.Tag); if Gear^.Timer = 1000 then // might need better timing - makeHogsWorry(Gear^.X, Gear^.Y, 75); + makeHogsWorry(Gear^.X, Gear^.Y, 75); if Gear^.Timer = 0 then - begin - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); - DeleteGear(Gear); - exit - end; + begin + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); + DeleteGear(Gear); + exit + end; dec(Gear^.Timer); end; @@ -1247,7 +1247,7 @@ *) procedure doStepRollingBarrel(Gear: PGear); var i: LongInt; - particle: PVisualGear; + particle: PVisualGear; begin Gear^.State:= Gear^.State or gstAnimation; if ((Gear^.dX.QWordValue <> 0) or (Gear^.dY.QWordValue <> 0)) then @@ -1257,9 +1257,9 @@ if not Gear^.dY.isNegative and (Gear^.dY > _0_03) and TestCollisionYwithGear(Gear, 1) then begin inc(Gear^.Damage, hwRound(Gear^.dY * _30)); - for i:= min(12, hwRound(Gear^.dY*_10)) downto 0 do + for i:= min(12, hwRound(Gear^.dY*_10)) downto 0 do begin - particle:= AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12, vgtDust); + particle:= AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12, vgtDust); if particle <> nil then particle^.dX := particle^.dX + (Gear^.dX / 5) end end @@ -1272,7 +1272,7 @@ if Gear^.Damage <> 0 then PlaySound(sndGraveImpact); doStepFallingGear(Gear); CalcRotationDirAngle(Gear); - CheckGearDrowning(Gear) + CheckGearDrowning(Gear) end else AddGearCI(Gear); (* @@ -1281,7 +1281,7 @@ x:= hwRound(Gear^.X); y:= hwRound(Gear^.Y); if (((y+1) and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) then - if (Land[y+1, x] = 0) then + if (Land[y+1, x] = 0) then begin if (((y+1) and LAND_HEIGHT_MASK) = 0) and (((x+Gear^.Radius-2) and LAND_WIDTH_MASK) = 0) and (Land[y+1, x+Gear^.Radius-2] = 0) then Gear^.dX:= -_0_08 @@ -1307,25 +1307,25 @@ procedure doStepCase(Gear: PGear); var i, x, y: LongInt; - k: TGearType; - exBoom: boolean; - dX, dY: HWFloat; + k: TGearType; + exBoom: boolean; + dX, dY: HWFloat; begin k:= Gear^.Kind; exBoom:= false; if (Gear^.Message and gm_Destroy) > 0 then - begin - DeleteGear(Gear); - FreeActionsList; - SetAllToActive; // something (hh, mine, etc...) could be on top of the case - with CurrentHedgehog^ do - if Gear <> nil then Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); - exit - end; + begin + DeleteGear(Gear); + FreeActionsList; + SetAllToActive; // something (hh, mine, etc...) could be on top of the case + with CurrentHedgehog^ do + if Gear <> nil then Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); + exit + end; if k = gtExplosives then - begin + begin //if V > _0_03 then Gear^.State:= Gear^.State or gstAnimation; if hwAbs(Gear^.dX) > _0_15 then Gear^.doStep:= @doStepRollingBarrel; @@ -1334,60 +1334,60 @@ AddVisualGear(hwRound(Gear^.X) - 16 + Random(32), hwRound(Gear^.Y) - 2, vgtSmoke) else AddVisualGear(hwRound(Gear^.X) - 16 + Random(32), hwRound(Gear^.Y) - 2, vgtSmokeWhite); - dec(Gear^.Health, Gear^.Damage); - Gear^.Damage:= 0; - if Gear^.Health <= 0 then - exBoom:= true; - end; + dec(Gear^.Health, Gear^.Damage); + Gear^.Damage:= 0; + if Gear^.Health <= 0 then + exBoom:= true; + end; if (Gear^.Damage > 0) or exBoom then - begin - x:= hwRound(Gear^.X); - y:= hwRound(Gear^.Y); - DeleteGear(Gear); // <-- delete gear! + begin + x:= hwRound(Gear^.X); + y:= hwRound(Gear^.Y); + DeleteGear(Gear); // <-- delete gear! - if k = gtCase then - begin - doMakeExplosion(x, y, 25, EXPLAutoSound); - for i:= 0 to 63 do - AddGear(x, y, gtFlame, 0, _0, _0, 0); - end - else if k = gtExplosives then - begin - doMakeExplosion(x, y, 75, EXPLAutoSound); - for i:= 0 to 31 do - begin - dX:= AngleCos(i * 64) * _0_5 * (getrandom + _1); - dY:= AngleSin(i * 64) * _0_5 * (getrandom + _1); - AddGear(x, y, gtFlame, 0, dX, dY, 0); - AddGear(x, y, gtFlame, 0, -dX, -dY, 0)^.State:= gsttmpFlag; - end - end; - exit - end; + if k = gtCase then + begin + doMakeExplosion(x, y, 25, EXPLAutoSound); + for i:= 0 to 63 do + AddGear(x, y, gtFlame, 0, _0, _0, 0); + end + else if k = gtExplosives then + begin + doMakeExplosion(x, y, 75, EXPLAutoSound); + for i:= 0 to 31 do + begin + dX:= AngleCos(i * 64) * _0_5 * (getrandom + _1); + dY:= AngleSin(i * 64) * _0_5 * (getrandom + _1); + AddGear(x, y, gtFlame, 0, dX, dY, 0); + AddGear(x, y, gtFlame, 0, -dX, -dY, 0)^.State:= gsttmpFlag; + end + end; + exit + end; if (Gear^.dY.QWordValue <> 0) or (not TestCollisionYwithGear(Gear, 1)) then - begin - AllInactive:= false; + begin + AllInactive:= false; Gear^.dY:= Gear^.dY + cGravity; Gear^.Y:= Gear^.Y + Gear^.dY; if (not Gear^.dY.isNegative) and (Gear^.dY > _0_001) then SetAllHHToActive; - if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= _0; - if (not Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, 1) then - begin + if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= _0; + if (not Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, 1) then + begin if (Gear^.dY > _0_02) and (k = gtExplosives) then inc(Gear^.Damage, hwRound(Gear^.dY * _30)); - if Gear^.dY > _0_2 then - for i:= min(12, hwRound(Gear^.dY*_10)) downto 0 do - AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12, vgtDust); - Gear^.dY:= - Gear^.dY * Gear^.Elasticity; - if Gear^.dY > - _0_001 then Gear^.dY:= _0 - else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact) - end; - //if Gear^.dY > - _0_001 then Gear^.dY:= _0 - CheckGearDrowning(Gear); - end; + if Gear^.dY > _0_2 then + for i:= min(12, hwRound(Gear^.dY*_10)) downto 0 do + AddVisualGear(hwRound(Gear^.X) - 5 + Random(10), hwRound(Gear^.Y) + 12, vgtDust); + Gear^.dY:= - Gear^.dY * Gear^.Elasticity; + if Gear^.dY > - _0_001 then Gear^.dY:= _0 + else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact) + end; + //if Gear^.dY > - _0_001 then Gear^.dY:= _0 + CheckGearDrowning(Gear); + end; if (Gear^.dY.QWordValue = 0) then AddGearCI(Gear) else if (Gear^.dY.QWordValue <> 0) then DeleteCI(Gear) @@ -1398,36 +1398,36 @@ procedure doStepTarget(Gear: PGear); begin if (Gear^.Timer = 0) and (Gear^.Tag = 0) then - PlaySound(sndWarp); + PlaySound(sndWarp); if (Gear^.Tag = 0) and (Gear^.Timer < 1000) then - inc(Gear^.Timer) + inc(Gear^.Timer) else if Gear^.Tag = 1 then - begin - Gear^.Tag:= 2; - if (TrainingFlags and tfTimeTrial) <> 0 then - begin - inc(TurnTimeLeft, TrainingTimeInc); - - if TrainingTimeInc > TrainingTimeInM then - dec(TrainingTimeInc, TrainingTimeInD); - if TurnTimeLeft > TrainingTimeMax then - TurnTimeLeft:= TrainingTimeMax; - end; - end + begin + Gear^.Tag:= 2; + if (TrainingFlags and tfTimeTrial) <> 0 then + begin + inc(TurnTimeLeft, TrainingTimeInc); + + if TrainingTimeInc > TrainingTimeInM then + dec(TrainingTimeInc, TrainingTimeInD); + if TurnTimeLeft > TrainingTimeMax then + TurnTimeLeft:= TrainingTimeMax; + end; + end else if Gear^.Tag = 2 then - if Gear^.Timer > 0 then - dec(Gear^.Timer) - else - begin - if (TrainingFlags and tfTargetRespawn) <> 0 then - begin - TrainingTargetGear:= AddGear(0, 0, gtTarget, 0, _0, _0, 0); - FindPlace(TrainingTargetGear, false, 0, LAND_WIDTH); - end; - DeleteGear(Gear); - exit; - end; + if Gear^.Timer > 0 then + dec(Gear^.Timer) + else + begin + if (TrainingFlags and tfTargetRespawn) <> 0 then + begin + TrainingTargetGear:= AddGear(0, 0, gtTarget, 0, _0, _0, 0); + FindPlace(TrainingTargetGear, false, 0, LAND_WIDTH); + end; + DeleteGear(Gear); + exit; + end; doStepCase(Gear) end; @@ -1438,10 +1438,10 @@ AllInactive:= false; dec(Gear^.Timer); if Gear^.Timer = 0 then - begin - DeleteGear(Gear); - AfterAttack - end + begin + DeleteGear(Gear); + AfterAttack + end end; procedure doStepShover(Gear: PGear); @@ -1468,10 +1468,10 @@ DeleteCI(HHGear); for i:= 0 to 3 do - begin - AmmoShove(Gear, 30, 25); - Gear^.X:= Gear^.X + Gear^.dX * 5 - end; + begin + AmmoShove(Gear, 30, 25); + Gear^.X:= Gear^.X + Gear^.dX * 5 + end; HHGear^.State:= HHGear^.State and not gstNoDamage; Gear^.Timer:= 250; @@ -1485,26 +1485,26 @@ if (Gear^.State and gsttmpFlag) = 0 then AllInactive:= false; if not TestCollisionYwithGear(Gear, 1) then - begin + begin AllInactive:= false; - if hwAbs(Gear^.dX) > _0_01 then - Gear^.dX:= Gear^.dX * _0_995; - if (Gear^.State and gsttmpFlag) <> 0 then Gear^.dY:= Gear^.dY + _2*cGravity else - Gear^.dY:= Gear^.dY + cGravity; - if hwAbs(Gear^.dY) > _0_2 then Gear^.dY:= Gear^.dY * _0_995; + if hwAbs(Gear^.dX) > _0_01 then + Gear^.dX:= Gear^.dX * _0_995; + if (Gear^.State and gsttmpFlag) <> 0 then Gear^.dY:= Gear^.dY + _2*cGravity else + Gear^.dY:= Gear^.dY + cGravity; + if hwAbs(Gear^.dY) > _0_2 then Gear^.dY:= Gear^.dY * _0_995; - if (Gear^.State and gsttmpFlag) <> 0 then Gear^.X:= Gear^.X + Gear^.dX else - Gear^.X:= Gear^.X + Gear^.dX + cWindSpeed * 640; - Gear^.Y:= Gear^.Y + Gear^.dY; + if (Gear^.State and gsttmpFlag) <> 0 then Gear^.X:= Gear^.X + Gear^.dX else + Gear^.X:= Gear^.X + Gear^.dX + cWindSpeed * 640; + Gear^.Y:= Gear^.Y + Gear^.dY; - if (hwRound(Gear^.Y) > cWaterLine) then - begin - for i:= 0 to 3 do - AddVisualGear(hwRound(Gear^.X) - 16 + Random(32), hwRound(Gear^.Y) - 16 + Random(16), vgtSteam); - PlaySound(sndVaporize); - DeleteGear(Gear); - exit - end + if (hwRound(Gear^.Y) > cWaterLine) then + begin + for i:= 0 to 3 do + AddVisualGear(hwRound(Gear^.X) - 16 + Random(32), hwRound(Gear^.Y) - 16 + Random(16), vgtSteam); + PlaySound(sndVaporize); + DeleteGear(Gear); + exit + end end else begin if (Gear^.State and gsttmpFlag) <> 0 then begin @@ -1512,7 +1512,7 @@ AmmoShove(Gear, 2, 30); Gear^.Radius:= 1 end; - if Gear^.Timer > 0 then + if Gear^.Timer > 0 then begin dec(Gear^.Timer); inc(Gear^.Damage) @@ -1540,7 +1540,7 @@ AddVisualGear(hwRound(Gear^.X) - 3 + Random(6), hwRound(Gear^.Y) - 2, vgtSmoke); end; // This one is interesting. I think I understand the purpose, but I wonder if a bit more fuzzy of kicking could be done with getrandom. - Gear^.Timer:= 100 - Gear^.Tag * 3; + Gear^.Timer:= 100 - Gear^.Tag * 3; if (Gear^.Damage > 3000+Gear^.Tag*1500) then Gear^.Health:= 0 end end @@ -1568,31 +1568,31 @@ begin AllInactive:= false; if ((Gear^.Message and gm_Destroy) <> 0) then - begin - DeleteGear(Gear); - AfterAttack; - exit - end; + begin + DeleteGear(Gear); + AfterAttack; + exit + end; HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; if hwRound(HHGear^.Y) <= Gear^.Tag - 2 then - begin - Gear^.Tag:= hwRound(HHGear^.Y); - DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y - _1, _0_5, _0, cHHRadius * 4, 2); - HHGear^.State:= HHGear^.State or gstNoDamage; - Gear^.Y:= HHGear^.Y; - AmmoShove(Gear, 30, 40); - HHGear^.State:= HHGear^.State and not gstNoDamage - end; + begin + Gear^.Tag:= hwRound(HHGear^.Y); + DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y - _1, _0_5, _0, cHHRadius * 4, 2); + HHGear^.State:= HHGear^.State or gstNoDamage; + Gear^.Y:= HHGear^.Y; + AmmoShove(Gear, 30, 40); + HHGear^.State:= HHGear^.State and not gstNoDamage + end; HHGear^.dY:= HHGear^.dY + cGravity; if not (HHGear^.dY.isNegative) then - begin - HHGear^.State:= HHGear^.State or gstMoving; - DeleteGear(Gear); - AfterAttack; - exit - end; + begin + HHGear^.State:= HHGear^.State or gstMoving; + DeleteGear(Gear); + AfterAttack; + exit + end; if CheckLandValue(hwRound(HHGear^.X), hwRound(HHGear^.Y + HHGear^.dY + SignAs(_6,Gear^.dY)), COLOR_INDESTRUCTIBLE) then HHGear^.Y:= HHGear^.Y + HHGear^.dY @@ -1628,24 +1628,24 @@ inc(Gear^.Timer); if TestCollisionYwithGear(HHGear, 1) - or ((HHGear^.State and gstHHDriven) = 0) - or CheckGearDrowning(HHGear) - or ((Gear^.Message and gm_Attack) <> 0) then - begin - with HHGear^ do - begin - Message:= 0; - SetLittle(dX); - dY:= _0; - State:= State or gstMoving; - end; - DeleteGear(Gear); - isCursorVisible:= false; - exit - end; + or ((HHGear^.State and gstHHDriven) = 0) + or CheckGearDrowning(HHGear) + or ((Gear^.Message and gm_Attack) <> 0) then + begin + with HHGear^ do + begin + Message:= 0; + SetLittle(dX); + dY:= _0; + State:= State or gstMoving; + end; + DeleteGear(Gear); + isCursorVisible:= false; + exit + end; if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then - HHGear^.X:= HHGear^.X + cWindSpeed * 200; + HHGear^.X:= HHGear^.X + cWindSpeed * 200; if (Gear^.Message and gm_Left) <> 0 then HHGear^.X:= HHGear^.X - cMaxWindSpeed * 40 else if (Gear^.Message and gm_Right) <> 0 then HHGear^.X:= HHGear^.X + cMaxWindSpeed * 40; @@ -1684,19 +1684,19 @@ Gear^.X:= Gear^.X + cAirPlaneSpeed * Gear^.Tag; if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then - begin - dec(Gear^.Health); - case Gear^.State of - 0: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0); - 1: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed * Gear^.Tag, _0, 0); - 2: for i:= -19 to 19 do - FollowGear:= AddGear(hwRound(Gear^.X) + i div 3, hwRound(Gear^.Y), gtFlame, 0, _0_001 * i, _0, 0); - end; - Gear^.dX:= Gear^.dX + int2hwFloat(30 * Gear^.Tag) - end; + begin + dec(Gear^.Health); + case Gear^.State of + 0: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0); + 1: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed * Gear^.Tag, _0, 0); + 2: for i:= -19 to 19 do + FollowGear:= AddGear(hwRound(Gear^.X) + i div 3, hwRound(Gear^.Y), gtFlame, 0, _0_001 * i, _0, 0); + end; + Gear^.dX:= Gear^.dX + int2hwFloat(30 * Gear^.Tag) + end; if (GameTicks and $3F) = 0 then - AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); + AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); if (hwRound(Gear^.X) > (LAND_WIDTH+1024)) or (hwRound(Gear^.X) < -1024) then DeleteGear(Gear) end; @@ -1706,21 +1706,21 @@ AllInactive:= false; if Gear^.X.QWordValue = 0 then - begin - Gear^.Tag:= 1; - Gear^.X:= -_1024; - end + begin + Gear^.Tag:= 1; + Gear^.X:= -_1024; + end else - begin - Gear^.Tag:= -1; - Gear^.X:= int2hwFloat(LAND_WIDTH + 1024); - end; + begin + Gear^.Tag:= -1; + Gear^.X:= int2hwFloat(LAND_WIDTH + 1024); + end; Gear^.Y:= int2hwFloat(topY-300); Gear^.dX:= int2hwFloat(TargetPoint.X - 5 * Gear^.Tag * 15); if (int2hwFloat(TargetPoint.Y) - Gear^.Y > _0) and (Gear^.State <> 2) then - Gear^.dX:= Gear^.dX - cBombsSpeed * hwSqrt((int2hwFloat(TargetPoint.Y) - Gear^.Y) * 2 / cGravity) * Gear^.Tag; + Gear^.dX:= Gear^.dX - cBombsSpeed * hwSqrt((int2hwFloat(TargetPoint.Y) - Gear^.Y) * 2 / cGravity) * Gear^.Tag; Gear^.Health:= 6; Gear^.doStep:= @doStepAirAttackWork; @@ -1733,13 +1733,13 @@ AllInactive:= false; doStepFallingGear(Gear); if (Gear^.State and gstCollision) <> 0 then - begin - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); - DeleteGear(Gear); - exit - end; + begin + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); + DeleteGear(Gear); + exit + end; if (GameTicks and $3F) = 0 then - AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) + AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) end; //////////////////////////////////////////////////////////////////////////////// @@ -1760,20 +1760,20 @@ not TryPlaceOnLand(TargetPoint.X - SpritesData[sprAmGirder].Width div 2, TargetPoint.Y - SpritesData[sprAmGirder].Height div 2, sprAmGirder, Gear^.State, true) then - begin + begin PlaySound(sndDenied); - HHGear^.Message:= HHGear^.Message and not gm_Attack; - HHGear^.State:= HHGear^.State and not gstAttacking; - HHGear^.State:= HHGear^.State or gstHHChooseTarget; - isCursorVisible:= true; - DeleteGear(Gear) - end + HHGear^.Message:= HHGear^.Message and not gm_Attack; + HHGear^.State:= HHGear^.State and not gstAttacking; + HHGear^.State:= HHGear^.State or gstHHChooseTarget; + isCursorVisible:= true; + DeleteGear(Gear) + end else begin PlaySound(sndPlaced); - DeleteGear(Gear); + DeleteGear(Gear); OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^) - end; + end; HHGear^.State:= HHGear^.State and not (gstAttacking or gstAttacked); HHGear^.Message:= HHGear^.Message and not gm_Attack; @@ -1789,23 +1789,23 @@ HHGear^.Y:= HHGear^.Y + HHGear^.dY; // hedgehog falling to collect cases HHGear^.dY:= HHGear^.dY + cGravity; if TestCollisionYwithGear(HHGear, 1) - or CheckGearDrowning(HHGear) then - begin - DeleteGear(Gear); - AfterAttack - end + or CheckGearDrowning(HHGear) then + begin + DeleteGear(Gear); + AfterAttack + end end; procedure doStepTeleportAnim(Gear: PGear); begin inc(Gear^.Timer); if Gear^.Timer = 65 then - begin - Gear^.Timer:= 0; - inc(Gear^.Pos); - if Gear^.Pos = 11 then - Gear^.doStep:= @doStepTeleportAfter - end; + begin + Gear^.Timer:= 0; + inc(Gear^.Pos); + if Gear^.Pos = 11 then + Gear^.doStep:= @doStepTeleportAfter + end; end; procedure doStepTeleport(Gear: PGear); @@ -1817,25 +1817,25 @@ if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprHHTelepMask].Width div 2, TargetPoint.Y - SpritesData[sprHHTelepMask].Height div 2, sprHHTelepMask, 0, false) then - begin - HHGear^.Message:= HHGear^.Message and not gm_Attack; - HHGear^.State:= HHGear^.State and not gstAttacking; - HHGear^.State:= HHGear^.State or gstHHChooseTarget; - DeleteGear(Gear); - isCursorVisible:= true; - PlaySound(sndDenied) - end - else begin - DeleteCI(HHGear); - SetAllHHToActive; - Gear^.doStep:= @doStepTeleportAnim; - Gear^.X:= HHGear^.X; - Gear^.Y:= HHGear^.Y; - HHGear^.X:= int2hwFloat(TargetPoint.X); - HHGear^.Y:= int2hwFloat(TargetPoint.Y); - HHGear^.State:= HHGear^.State or gstMoving; - playSound(sndWarp) - end; + begin + HHGear^.Message:= HHGear^.Message and not gm_Attack; + HHGear^.State:= HHGear^.State and not gstAttacking; + HHGear^.State:= HHGear^.State or gstHHChooseTarget; + DeleteGear(Gear); + isCursorVisible:= true; + PlaySound(sndDenied) + end + else begin + DeleteCI(HHGear); + SetAllHHToActive; + Gear^.doStep:= @doStepTeleportAnim; + Gear^.X:= HHGear^.X; + Gear^.Y:= HHGear^.Y; + HHGear^.X:= int2hwFloat(TargetPoint.X); + HHGear^.Y:= int2hwFloat(TargetPoint.Y); + HHGear^.State:= HHGear^.State or gstMoving; + playSound(sndWarp) + end; TargetPoint.X:= NoPointX; end; @@ -1848,49 +1848,49 @@ AllInactive:= false; if ((Gear^.Message and not gm_Switch) <> 0) or (TurnTimeLeft = 0) then - begin - HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; - Msg:= Gear^.Message and not gm_Switch; - DeleteGear(Gear); - OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); - ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); + begin + HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; + Msg:= Gear^.Message and not gm_Switch; + DeleteGear(Gear); + OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); + ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); - HHGear:= CurrentHedgehog^.Gear; - ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); - HHGear^.Message:= Msg; - exit - end; + HHGear:= CurrentHedgehog^.Gear; + ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); + HHGear^.Message:= Msg; + exit + end; if (Gear^.Message and gm_Switch) <> 0 then - begin - HHGear:= CurrentHedgehog^.Gear; - HHGear^.Message:= HHGear^.Message and not gm_Switch; - Gear^.Message:= Gear^.Message and not gm_Switch; - State:= HHGear^.State; - HHGear^.State:= 0; - HHGear^.Active:= false; - HHGear^.Z:= cHHZ; - RemoveGearFromList(HHGear); - InsertGearToList(HHGear); + begin + HHGear:= CurrentHedgehog^.Gear; + HHGear^.Message:= HHGear^.Message and not gm_Switch; + Gear^.Message:= Gear^.Message and not gm_Switch; + State:= HHGear^.State; + HHGear^.State:= 0; + HHGear^.Active:= false; + HHGear^.Z:= cHHZ; + RemoveGearFromList(HHGear); + InsertGearToList(HHGear); - PlaySound(sndSwitchHog); - - repeat - CurrentTeam^.CurrHedgehog:= Succ(CurrentTeam^.CurrHedgehog) mod (CurrentTeam^.HedgehogsNumber); - until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil); + PlaySound(sndSwitchHog); + + repeat + CurrentTeam^.CurrHedgehog:= Succ(CurrentTeam^.CurrHedgehog) mod (CurrentTeam^.HedgehogsNumber); + until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil); - CurrentHedgehog:= @CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]; + CurrentHedgehog:= @CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]; - HHGear:= CurrentHedgehog^.Gear; - HHGear^.State:= State; - HHGear^.Active:= true; - FollowGear:= HHGear; - HHGear^.Z:= cCurrHHZ; - RemoveGearFromList(HHGear); - InsertGearToList(HHGear); - Gear^.X:= HHGear^.X; - Gear^.Y:= HHGear^.Y - end; + HHGear:= CurrentHedgehog^.Gear; + HHGear^.State:= State; + HHGear^.Active:= true; + FollowGear:= HHGear; + HHGear^.Z:= cCurrHHZ; + RemoveGearFromList(HHGear); + InsertGearToList(HHGear); + Gear^.X:= HHGear^.X; + Gear^.Y:= HHGear^.Y + end; end; procedure doStepSwitcher(Gear: PGear); @@ -1900,10 +1900,10 @@ HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; with HHGear^ do - begin - State:= State and not gstAttacking; - Message:= Message and not gm_Attack - end + begin + State:= State and not gstAttacking; + Message:= Message and not gm_Attack + end end; //////////////////////////////////////////////////////////////////////////////// @@ -1918,24 +1918,24 @@ doStepFallingGear(Gear); if (Gear^.State and gstCollision) <> 0 then - begin - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); + begin + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); - Gear^.dX.isNegative:= not dxn; - Gear^.dY.isNegative:= not dyn; - for i:= 0 to 4 do - begin - dX:= Gear^.dX + (GetRandom - _0_5) * _0_03; - dY:= Gear^.dY + (GetRandom - _0_5) * _0_03; - AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 25); - end; + Gear^.dX.isNegative:= not dxn; + Gear^.dY.isNegative:= not dyn; + for i:= 0 to 4 do + begin + dX:= Gear^.dX + (GetRandom - _0_5) * _0_03; + dY:= Gear^.dY + (GetRandom - _0_5) * _0_03; + AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 25); + end; - DeleteGear(Gear); - exit - end; + DeleteGear(Gear); + exit + end; if (GameTicks and $3F) = 0 then - AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) + AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) end; //////////////////////////////////////////////////////////////////////////////// @@ -1952,47 +1952,47 @@ i:= 2; repeat - Gear^.X:= Gear^.X + HHGear^.dX; - Gear^.Y:= Gear^.Y + HHGear^.dY; - HHGear^.X:= Gear^.X; - HHGear^.Y:= Gear^.Y; + Gear^.X:= Gear^.X + HHGear^.dX; + Gear^.Y:= Gear^.Y + HHGear^.dY; + HHGear^.X:= Gear^.X; + HHGear^.Y:= Gear^.Y; - inc(Gear^.Damage, 2); + inc(Gear^.Damage, 2); -// if TestCollisionXwithGear(HHGear, hwSign(Gear^.dX)) -// or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY)) then inc(Gear^.Damage, 3); +// if TestCollisionXwithGear(HHGear, hwSign(Gear^.dX)) +// or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY)) then inc(Gear^.Damage, 3); - dec(i) + dec(i) until (i = 0) or (Gear^.Damage > Gear^.Health); inc(upd); if upd > 3 then - begin - if Gear^.Health < 1500 then Gear^.Pos:= 2; + begin + if Gear^.Health < 1500 then Gear^.Pos:= 2; - AmmoShove(Gear, 30, 40); + AmmoShove(Gear, 30, 40); - DrawTunnel(HHGear^.X - HHGear^.dX * 10, - HHGear^.Y - _2 - HHGear^.dY * 10 + hwAbs(HHGear^.dY) * 2, - HHGear^.dX, - HHGear^.dY, - 20 + cHHRadius * 2, - cHHRadius * 2 + 6); + DrawTunnel(HHGear^.X - HHGear^.dX * 10, + HHGear^.Y - _2 - HHGear^.dY * 10 + hwAbs(HHGear^.dY) * 2, + HHGear^.dX, + HHGear^.dY, + 20 + cHHRadius * 2, + cHHRadius * 2 + 6); - upd:= 0 - end; + upd:= 0 + end; if Gear^.Health < Gear^.Damage then - begin - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); - AfterAttack; - DeleteGear(Gear); - DeleteGear(HHGear); - end else - begin - dec(Gear^.Health, Gear^.Damage); - Gear^.Damage:= 0 - end + begin + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); + AfterAttack; + DeleteGear(Gear); + DeleteGear(HHGear); + end else + begin + dec(Gear^.Health, Gear^.Damage); + Gear^.Damage:= 0 + end end; procedure doStepKamikazeIdle(Gear: PGear); @@ -2000,11 +2000,11 @@ AllInactive:= false; dec(Gear^.Timer); if Gear^.Timer = 0 then - begin - Gear^.Pos:= 1; - PlaySound(sndKamikaze, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack); - Gear^.doStep:= @doStepKamikazeWork - end + begin + Gear^.Pos:= 1; + PlaySound(sndKamikaze, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack); + Gear^.doStep:= @doStepKamikazeWork + end end; procedure doStepKamikaze(Gear: PGear); @@ -2029,7 +2029,7 @@ const cakeh = 27; cakeDmg = 75; var CakePoints: array[0..Pred(cakeh)] of record x, y: hwFloat; end; - CakeI: Longword; + CakeI: Longword; procedure doStepCakeExpl(Gear: PGear); begin @@ -2045,7 +2045,7 @@ procedure doStepCakeDown(Gear: PGear); var gi: PGear; - dmg: LongInt; + dmg: LongInt; begin AllInactive:= false; @@ -2054,39 +2054,39 @@ Gear^.Tag:= 0; if Gear^.Pos = 0 then - begin - gi:= GearsList; - while gi <> nil do - begin - dmg:= cakeDmg * 2 - hwRound(Distance(gi^.X - Gear^.X, gi^.Y - Gear^.Y)); - if (dmg > 1) and (gi^.Kind = gtHedgehog) then + begin + gi:= GearsList; + while gi <> nil do + begin + dmg:= cakeDmg * 2 - hwRound(Distance(gi^.X - Gear^.X, gi^.Y - Gear^.Y)); + if (dmg > 1) and (gi^.Kind = gtHedgehog) then if (CurrentHedgehog^.Gear = gi) and (not gi^.Invulnerable) then - gi^.State:= gi^.State or gstLoser + gi^.State:= gi^.State or gstLoser else - gi^.State:= gi^.State or gstWinner; - gi:= gi^.NextGear - end; - Gear^.doStep:= @doStepCakeExpl; - PlaySound(sndCake) - end else dec(Gear^.Pos) + gi^.State:= gi^.State or gstWinner; + gi:= gi^.NextGear + end; + Gear^.doStep:= @doStepCakeExpl; + PlaySound(sndCake) + end else dec(Gear^.Pos) end; procedure doStepCakeWork(Gear: PGear); const dirs: array[0..3] of TPoint = ((x: 0; y: -1), (x: 1; y: 0),(x: 0; y: 1),(x: -1; y: 0)); var xx, yy, xxn, yyn: LongInt; - da: LongInt; - tdx, tdy: hwFloat; + da: LongInt; + tdx, tdy: hwFloat; - procedure PrevAngle; - begin - Gear^.Angle:= (LongInt(Gear^.Angle) + 4 - dA) mod 4 - end; + procedure PrevAngle; + begin + Gear^.Angle:= (LongInt(Gear^.Angle) + 4 - dA) mod 4 + end; - procedure NextAngle; - begin - Gear^.Angle:= (LongInt(Gear^.Angle) + 4 + dA) mod 4 - end; + procedure NextAngle; + begin + Gear^.Angle:= (LongInt(Gear^.Angle) + 4 + dA) mod 4 + end; begin AllInactive:= false; @@ -2101,49 +2101,49 @@ yyn:= dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].y; if (xx = 0) then - if TestCollisionYwithGear(Gear, yy) then - PrevAngle - else begin - Gear^.Tag:= 0; - Gear^.Y:= Gear^.Y + int2hwFloat(yy); - if not TestCollisionXwithGear(Gear, xxn) then - begin - Gear^.X:= Gear^.X + int2hwFloat(xxn); - NextAngle - end; - end; + if TestCollisionYwithGear(Gear, yy) then + PrevAngle + else begin + Gear^.Tag:= 0; + Gear^.Y:= Gear^.Y + int2hwFloat(yy); + if not TestCollisionXwithGear(Gear, xxn) then + begin + Gear^.X:= Gear^.X + int2hwFloat(xxn); + NextAngle + end; + end; if (yy = 0) then - if TestCollisionXwithGear(Gear, xx) then - PrevAngle - else begin - Gear^.Tag:= 0; - Gear^.X:= Gear^.X + int2hwFloat(xx); - if not TestCollisionYwithGear(Gear, yyn) then - begin - Gear^.Y:= Gear^.Y + int2hwFloat(yyn); - NextAngle - end; - end; + if TestCollisionXwithGear(Gear, xx) then + PrevAngle + else begin + Gear^.Tag:= 0; + Gear^.X:= Gear^.X + int2hwFloat(xx); + if not TestCollisionYwithGear(Gear, yyn) then + begin + Gear^.Y:= Gear^.Y + int2hwFloat(yyn); + NextAngle + end; + end; if Gear^.Tag = 0 then - begin - CakeI:= (CakeI + 1) mod cakeh; - tdx:= CakePoints[CakeI].x - Gear^.X; - tdy:= - CakePoints[CakeI].y + Gear^.Y; - CakePoints[CakeI].x:= Gear^.X; - CakePoints[CakeI].y:= Gear^.Y; - Gear^.DirAngle:= DxDy2Angle(tdx, tdy); - end; + begin + CakeI:= (CakeI + 1) mod cakeh; + tdx:= CakePoints[CakeI].x - Gear^.X; + tdy:= - CakePoints[CakeI].y + Gear^.Y; + CakePoints[CakeI].x:= Gear^.X; + CakePoints[CakeI].y:= Gear^.Y; + Gear^.DirAngle:= DxDy2Angle(tdx, tdy); + end; dec(Gear^.Health); Gear^.Timer:= Gear^.Health*10; // This is not seconds, but at least it is *some* feedback if (Gear^.Health = 0) or ((Gear^.Message and gm_Attack) <> 0) then - begin - FollowGear:= Gear; + begin + FollowGear:= Gear; Gear^.RenderTimer:= false; - Gear^.doStep:= @doStepCakeDown - end + Gear^.doStep:= @doStepCakeDown + end end; procedure doStepCakeUp(Gear: PGear); @@ -2156,15 +2156,15 @@ Gear^.Tag:= 0; if Gear^.Pos = 6 then - begin - for i:= 0 to Pred(cakeh) do - begin - CakePoints[i].x:= Gear^.X; - CakePoints[i].y:= Gear^.Y - end; - CakeI:= 0; - Gear^.doStep:= @doStepCakeWork - end else inc(Gear^.Pos) + begin + for i:= 0 to Pred(cakeh) do + begin + CakePoints[i].x:= Gear^.X; + CakePoints[i].y:= Gear^.Y + end; + CakeI:= 0; + Gear^.doStep:= @doStepCakeWork + end else inc(Gear^.Pos) end; procedure doStepCakeFall(Gear: PGear); @@ -2173,12 +2173,12 @@ Gear^.dY:= Gear^.dY + cGravity; if TestCollisionYwithGear(Gear, 1) then - Gear^.doStep:= @doStepCakeUp + Gear^.doStep:= @doStepCakeUp else - begin - Gear^.Y:= Gear^.Y + Gear^.dY; - if CheckGearDrowning(Gear) then AfterAttack - end + begin + Gear^.Y:= Gear^.Y + Gear^.dY; + if CheckGearDrowning(Gear) then AfterAttack + end end; procedure doStepCake(Gear: PGear); @@ -2207,22 +2207,22 @@ y:= hwRound(Gear^.Y); if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) then - if (Land[y, x] <> 0) then - begin - Gear^.dX.isNegative:= not Gear^.dX.isNegative; - Gear^.dY.isNegative:= not Gear^.dY.isNegative; - Gear^.dX:= Gear^.dX * _1_5; - Gear^.dY:= Gear^.dY * _1_5 - _0_3; - AmmoShove(Gear, 0, 40); - AfterAttack; - DeleteGear(Gear) - end - else + if (Land[y, x] <> 0) then + begin + Gear^.dX.isNegative:= not Gear^.dX.isNegative; + Gear^.dY.isNegative:= not Gear^.dY.isNegative; + Gear^.dX:= Gear^.dX * _1_5; + Gear^.dY:= Gear^.dY * _1_5 - _0_3; + AmmoShove(Gear, 0, 40); + AfterAttack; + DeleteGear(Gear) + end + else else - begin - AfterAttack; - DeleteGear(Gear) - end + begin + AfterAttack; + DeleteGear(Gear) + end end; procedure doStepSeductionWear(Gear: PGear); @@ -2230,15 +2230,15 @@ AllInactive:= false; inc(Gear^.Timer); if Gear^.Timer > 250 then - begin - Gear^.Timer:= 0; - inc(Gear^.Pos); - if Gear^.Pos = 5 then - PlaySound(sndYoohoo, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack) - end; + begin + Gear^.Timer:= 0; + inc(Gear^.Pos); + if Gear^.Pos = 5 then + PlaySound(sndYoohoo, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack) + end; if Gear^.Pos = 14 then - Gear^.doStep:= @doStepSeductionWork + Gear^.doStep:= @doStepSeductionWork end; procedure doStepSeduction(Gear: PGear); @@ -2256,43 +2256,43 @@ inc(Gear^.Timer); if Gear^.Timer = 17 then - Gear^.Timer:= 0 + Gear^.Timer:= 0 else - exit; + exit; if cWaterLine > 0 then - begin - dec(cWaterLine); - for i:= 0 to LAND_WIDTH - 1 do - Land[cWaterLine, i]:= 0; - SetAllToActive - end; + begin + dec(cWaterLine); + for i:= 0 to LAND_WIDTH - 1 do + Land[cWaterLine, i]:= 0; + SetAllToActive + end; inc(Gear^.Tag); if (Gear^.Tag = 47) or (cWaterLine = 0) then - DeleteGear(Gear) + DeleteGear(Gear) end; //////////////////////////////////////////////////////////////////////////////// procedure doStepDrillDrilling(Gear: PGear); var t: PGearArray; - ox, oy: hwFloat; + ox, oy: hwFloat; begin AllInactive:= false; if (Gear^.Timer > 0) and ((Gear^.Timer mod 10) = 0) then - begin - ox:= Gear^.X; - oy:= Gear^.Y; - Gear^.X:= Gear^.X + Gear^.dX; - Gear^.Y:= Gear^.Y + Gear^.dY; - DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 2, 6); + begin + ox:= Gear^.X; + oy:= Gear^.Y; + Gear^.X:= Gear^.X + Gear^.dX; + Gear^.Y:= Gear^.Y + Gear^.dY; + DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 2, 6); if(CheckGearDrowning(Gear)) then begin StopSound(Gear^.SoundChannel); - exit + exit end - end; + end; t:= CheckGearsCollision(Gear); //fixes drill not exploding when touching HH bug if (Gear^.Timer = 0) @@ -2300,20 +2300,20 @@ or (not TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) and not TestCollisionXWithGear(Gear, hwSign(Gear^.dX))) or (Land[hwRound(Gear^.Y), hwRound(Gear^.X)] = COLOR_INDESTRUCTIBLE) then - begin //out of time or exited ground + begin //out of time or exited ground StopSound(Gear^.SoundChannel); - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); - DeleteGear(Gear); - exit - end; + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); + DeleteGear(Gear); + exit + end; dec(Gear^.Timer); end; procedure doStepDrill(Gear: PGear); var t: PGearArray; - oldDx, oldDy: hwFloat; - t2: hwFloat; + oldDx, oldDy: hwFloat; + t2: hwFloat; begin AllInactive:= false; @@ -2324,56 +2324,56 @@ doStepFallingGear(Gear); if (GameTicks and $3F) = 0 then - AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); + AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); if ((Gear^.State and gstCollision) <> 0) then begin //hit - Gear^.dX:= oldDx; - Gear^.dY:= oldDy; + Gear^.dX:= oldDx; + Gear^.dY:= oldDy; - t:= CheckGearsCollision(Gear); - if (t^.Count = 0) then begin //hit the ground not the HH - t2 := _0_5 / Distance(Gear^.dX, Gear^.dY); - Gear^.dX:= Gear^.dX * t2; - Gear^.dY:= Gear^.dY * t2; - end else begin //explode right on contact with HH - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); - DeleteGear(Gear); - exit; - end; + t:= CheckGearsCollision(Gear); + if (t^.Count = 0) then begin //hit the ground not the HH + t2 := _0_5 / Distance(Gear^.dX, Gear^.dY); + Gear^.dX:= Gear^.dX * t2; + Gear^.dY:= Gear^.dY * t2; + end else begin //explode right on contact with HH + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); + DeleteGear(Gear); + exit; + end; Gear^.SoundChannel:= LoopSound(sndPickhammer); - Gear^.doStep:= @doStepDrillDrilling; - dec(Gear^.Timer) - end + Gear^.doStep:= @doStepDrillDrilling; + dec(Gear^.Timer) + end end; //////////////////////////////////////////////////////////////////////////////// procedure doStepBallgunWork(Gear: PGear); var HHGear: PGear; - rx, ry: hwFloat; + rx, ry: hwFloat; begin - AllInactive:= false; - dec(Gear^.Timer); - HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; - HedgehogChAngle(HHGear); - if (Gear^.Timer mod 100) = 0 then - begin - rx:= rndSign(getRandom * _0_1); - ry:= rndSign(getRandom * _0_1); + AllInactive:= false; + dec(Gear^.Timer); + HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; + HedgehogChAngle(HHGear); + if (Gear^.Timer mod 100) = 0 then + begin + rx:= rndSign(getRandom * _0_1); + ry:= rndSign(getRandom * _0_1); - AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtBall, 0, - SignAs(AngleSin(HHGear^.Angle) * _0_8, HHGear^.dX) + rx, - AngleCos(HHGear^.Angle) * ( - _0_8) + ry, - 0); + AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtBall, 0, + SignAs(AngleSin(HHGear^.Angle) * _0_8, HHGear^.dX) + rx, + AngleCos(HHGear^.Angle) * ( - _0_8) + ry, + 0); - PlaySound(sndGun); - end; + PlaySound(sndGun); + end; - if (Gear^.Timer = 0) or (HHGear^.Damage <> 0) then - begin - DeleteGear(Gear); - AfterAttack - end + if (Gear^.Timer = 0) or (HHGear^.Damage <> 0) then + begin + DeleteGear(Gear); + AfterAttack + end end; procedure doStepBallgun(Gear: PGear); @@ -2389,11 +2389,11 @@ procedure doStepRCPlaneWork(Gear: PGear); const cAngleSpeed = 3; var HHGear: PGear; - i: LongInt; - dX, dY: hwFloat; - fChanged: boolean; - trueAngle: Longword; - t: PGear; + i: LongInt; + dX, dY: hwFloat; + fChanged: boolean; + trueAngle: Longword; + t: PGear; begin AllInactive:= false; @@ -2406,123 +2406,123 @@ fChanged:= false; if ((HHGear^.State and gstHHDriven) = 0) or (Gear^.Timer = 0) then - begin - fChanged:= true; - if Gear^.Angle > 2048 then dec(Gear^.Angle) else - if Gear^.Angle < 2048 then inc(Gear^.Angle) else fChanged:= false - end + begin + fChanged:= true; + if Gear^.Angle > 2048 then dec(Gear^.Angle) else + if Gear^.Angle < 2048 then inc(Gear^.Angle) else fChanged:= false + end else - begin - if ((Gear^.Message and gm_Left) <> 0) then - begin - fChanged:= true; - Gear^.Angle:= (Gear^.Angle + (4096 - cAngleSpeed)) mod 4096 - end; + begin + if ((Gear^.Message and gm_Left) <> 0) then + begin + fChanged:= true; + Gear^.Angle:= (Gear^.Angle + (4096 - cAngleSpeed)) mod 4096 + end; - if ((Gear^.Message and gm_Right) <> 0) then - begin - fChanged:= true; - Gear^.Angle:= (Gear^.Angle + cAngleSpeed) mod 4096 - end - end; + if ((Gear^.Message and gm_Right) <> 0) then + begin + fChanged:= true; + Gear^.Angle:= (Gear^.Angle + cAngleSpeed) mod 4096 + end + end; if fChanged then - begin - Gear^.dX.isNegative:= (Gear^.Angle > 2048); - if Gear^.dX.isNegative then - trueAngle:= 4096 - Gear^.Angle - else - trueAngle:= Gear^.Angle; + begin + Gear^.dX.isNegative:= (Gear^.Angle > 2048); + if Gear^.dX.isNegative then + trueAngle:= 4096 - Gear^.Angle + else + trueAngle:= Gear^.Angle; - Gear^.dX:= SignAs(AngleSin(trueAngle), Gear^.dX) * _0_25; - Gear^.dY:= AngleCos(trueAngle) * -_0_25; - end; + Gear^.dX:= SignAs(AngleSin(trueAngle), Gear^.dX) * _0_25; + Gear^.dY:= AngleCos(trueAngle) * -_0_25; + end; Gear^.X:= Gear^.X + Gear^.dX; Gear^.Y:= Gear^.Y + Gear^.dY; if (TrainingFlags and tfRCPlane) = 0 then - begin - if (GameTicks and $FF) = 0 then - if Gear^.Timer < 3500 then - AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtEvilTrace, 0, _0, _0, 0) - else - AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); + begin + if (GameTicks and $FF) = 0 then + if Gear^.Timer < 3500 then + AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtEvilTrace, 0, _0, _0, 0) + else + AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); - if ((HHGear^.Message and gm_Attack) <> 0) and (Gear^.Health <> 0) then - begin - HHGear^.Message := HHGear^.Message and not gm_Attack; - AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, Gear^.dX * _0_5, Gear^.dY * _0_5, 0); - dec(Gear^.Health) - end; + if ((HHGear^.Message and gm_Attack) <> 0) and (Gear^.Health <> 0) then + begin + HHGear^.Message := HHGear^.Message and not gm_Attack; + AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, Gear^.dX * _0_5, Gear^.dY * _0_5, 0); + dec(Gear^.Health) + end; - if ((HHGear^.Message and gm_LJump) <> 0) - and ((Gear^.State and gsttmpFlag) = 0) then - begin - Gear^.State:= Gear^.State or gsttmpFlag; - PauseMusic; - playSound(sndRideOfTheValkyries); - end; + if ((HHGear^.Message and gm_LJump) <> 0) + and ((Gear^.State and gsttmpFlag) = 0) then + begin + Gear^.State:= Gear^.State or gsttmpFlag; + PauseMusic; + playSound(sndRideOfTheValkyries); + end; - // pickup bonuses - t:= CheckGearNear(Gear, gtCase, 36, 36); - if t <> nil then - PickUp(HHGear, t); - end + // pickup bonuses + t:= CheckGearNear(Gear, gtCase, 36, 36); + if t <> nil then + PickUp(HHGear, t); + end else - begin - if (GameTicks and $FF) = 0 then - AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); + begin + if (GameTicks and $FF) = 0 then + AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); - // pickup targets - t:= CheckGearNear(Gear, gtTarget, 36, 36); - if t <> nil then - begin - if t^.Tag <> 0 then // collect it only once - exit; - PlaySound(sndShotgunReload); - t^.Tag:= 1; - TrainingTargetGear:= nil; // remove target cursor - exit; - end; + // pickup targets + t:= CheckGearNear(Gear, gtTarget, 36, 36); + if t <> nil then + begin + if t^.Tag <> 0 then // collect it only once + exit; + PlaySound(sndShotgunReload); + t^.Tag:= 1; + TrainingTargetGear:= nil; // remove target cursor + exit; + end; - if (TurnTimeLeft > 0) then - dec(TurnTimeLeft) - end; - + if (TurnTimeLeft > 0) then + dec(TurnTimeLeft) + end; + CheckCollision(Gear); if ((Gear^.State and gstCollision) <> 0) or (((TrainingFlags and tfRCPlane) <> 0) and (TurnTimeLeft = 0)) - or CheckGearDrowning(Gear) then - begin - if ((TrainingFlags and tfRCPlane) <> 0) and ((TrainingFlags and tfTimeTrial) <> 0 ) and (TimeTrialStopTime = 0) then TimeTrialStopTime:= RealTicks; - StopSound(Gear^.SoundChannel); - StopSound(sndRideOfTheValkyries); - ResumeMusic; + or CheckGearDrowning(Gear) then + begin + if ((TrainingFlags and tfRCPlane) <> 0) and ((TrainingFlags and tfTimeTrial) <> 0 ) and (TimeTrialStopTime = 0) then TimeTrialStopTime:= RealTicks; + StopSound(Gear^.SoundChannel); + StopSound(sndRideOfTheValkyries); + ResumeMusic; - if ((Gear^.State and gstCollision) <> 0) or (((TrainingFlags and tfRCPlane) <> 0) and (TurnTimeLeft = 0)) then - begin - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, EXPLAutoSound); - for i:= 0 to 32 do - begin - dX:= AngleCos(i * 64) * _0_5 * (GetRandom + _1); - dY:= AngleSin(i * 64) * _0_5 * (GetRandom + _1); - AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, dY, 0); - AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, -dY, 0); - end; - DeleteGear(Gear) - end; + if ((Gear^.State and gstCollision) <> 0) or (((TrainingFlags and tfRCPlane) <> 0) and (TurnTimeLeft = 0)) then + begin + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, EXPLAutoSound); + for i:= 0 to 32 do + begin + dX:= AngleCos(i * 64) * _0_5 * (GetRandom + _1); + dY:= AngleSin(i * 64) * _0_5 * (GetRandom + _1); + AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, dY, 0); + AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, -dY, 0); + end; + DeleteGear(Gear) + end; - AfterAttack; - CurAmmoGear:= nil; - TurnTimeLeft:= 14 * 125; - - if (TrainingFlags and tfRCPlane) <> 0 then - TurnTimeLeft:= 0; // HACK: RCPlane training allows unlimited plane starts in last 2 seconds + AfterAttack; + CurAmmoGear:= nil; + TurnTimeLeft:= 14 * 125; + + if (TrainingFlags and tfRCPlane) <> 0 then + TurnTimeLeft:= 0; // HACK: RCPlane training allows unlimited plane starts in last 2 seconds - HHGear^.Message:= 0; - ParseCommand('/taunt '#1, true) - end + HHGear^.Message:= 0; + ParseCommand('/taunt '#1, true) + end end; procedure doStepRCPlane(Gear: PGear); @@ -2599,24 +2599,24 @@ if (Gear^.Health = 0) or (HHGear^.Damage <> 0) - or CheckGearDrowning(HHGear) + or CheckGearDrowning(HHGear) or (TurnTimeLeft = 0) // allow brief ground touches - to be fair on this, might need another counter or (((GameTicks and $1FF) = 0) and (not HHGear^.dY.isNegative) and TestCollisionYwithGear(HHGear, 1)) - or ((Gear^.Message and gm_Attack) <> 0) then - begin - with HHGear^ do - begin - Message:= 0; + or ((Gear^.Message and gm_Attack) <> 0) then + begin + with HHGear^ do + begin + Message:= 0; Active:= true; - State:= State or gstMoving - end; - DeleteGear(Gear); - isCursorVisible:= false; + State:= State or gstMoving + end; + DeleteGear(Gear); + isCursorVisible:= false; // if Gear^.Tex <> nil then FreeTexture(Gear^.Tex); // Gear^.Tex:= RenderStringTex(trmsg[sidFuel] + ': ' + inttostr(round(Gear^.Health / 20)) + '%', cWhiteColor, fntSmall) //AddCaption(trmsg[sidFuel]+': '+inttostr(round(Gear^.Health/20))+'%', cWhiteColor, capgrpAmmostate); - end + end end; //////////////////////////////////////////////////////////////////////////////// @@ -2630,13 +2630,13 @@ OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); with HHGear^ do - begin - State:= State and not gstAttacking; - Message:= Message and not (gm_Attack or gm_Up or gm_Precise or gm_Left or gm_Right); + begin + State:= State and not gstAttacking; + Message:= Message and not (gm_Attack or gm_Up or gm_Precise or gm_Left or gm_Right); if (dY < _0_1) and (dY > -_0_1) then begin Gear^.State:= Gear^.State or gsttmpFlag; dY:= dY - _0_2 end - end + end end; diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/HHHandlers.inc --- a/hedgewars/HHHandlers.inc Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/HHHandlers.inc Sat Mar 06 10:59:20 2010 +0000 @@ -23,42 +23,42 @@ slot:= Gear^.MsgParam; with PHedgehog(Gear^.Hedgehog)^ do - begin - Gear^.Message:= Gear^.Message and not gm_Slot; + begin + Gear^.Message:= Gear^.Message and not gm_Slot; - if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) - or (MultiShootAttacks > 0) - or ((Gear^.State and gstHHDriven) = 0) then exit; + if ((Gear^.State and (gstAttacking or gstAttacked)) <> 0) + or (MultiShootAttacks > 0) + or ((Gear^.State and gstHHDriven) = 0) then exit; - Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); + Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); - if CurSlot = slot then - begin - i:= 0; - repeat - inc(CurAmmo); - if (CurAmmo > cMaxSlotAmmoIndex) then - begin - CurAmmo:= 0; - inc(i); - TryDo(i < 2, 'Engine bug: no ammo in current slot', true) - end; - until (Ammo^[slot, CurAmmo].Count > 0) and (Team^.Clan^.TurnNumber > Ammoz[Ammo^[slot, CurAmmo].AmmoType].SkipTurns) - end else - begin - i:= 0; - // check whether there is ammo in slot - while (i <= cMaxSlotAmmoIndex) - and ((Ammo^[slot, i].Count = 0) - or (Team^.Clan^.TurnNumber <= Ammoz[Ammo^[slot, i].AmmoType].SkipTurns)) do inc(i); + if CurSlot = slot then + begin + i:= 0; + repeat + inc(CurAmmo); + if (CurAmmo > cMaxSlotAmmoIndex) then + begin + CurAmmo:= 0; + inc(i); + TryDo(i < 2, 'Engine bug: no ammo in current slot', true) + end; + until (Ammo^[slot, CurAmmo].Count > 0) and (Team^.Clan^.TurnNumber > Ammoz[Ammo^[slot, CurAmmo].AmmoType].SkipTurns) + end else + begin + i:= 0; + // check whether there is ammo in slot + while (i <= cMaxSlotAmmoIndex) + and ((Ammo^[slot, i].Count = 0) + or (Team^.Clan^.TurnNumber <= Ammoz[Ammo^[slot, i].AmmoType].SkipTurns)) do inc(i); - if i <= cMaxSlotAmmoIndex then - begin - CurSlot:= slot; - CurAmmo:= i - end - end - end + if i <= cMaxSlotAmmoIndex then + begin + CurSlot:= slot; + CurAmmo:= i + end + end + end end; procedure HHSetWeapon(Gear: PGear); @@ -76,11 +76,11 @@ Gear^.Message:= Gear^.Message and not gm_Weapon; with PHedgehog(Gear^.Hedgehog)^ do - while (Ammo^[CurSlot, CurAmmo].AmmoType <> weap) and (t >= 0) do - begin - ChangeAmmo(Gear); - dec(t) - end; + while (Ammo^[CurSlot, CurAmmo].AmmoType <> weap) and (t >= 0) do + begin + ChangeAmmo(Gear); + dec(t) + end; ApplyAmmoChanges(PHedgehog(Gear^.Hedgehog)^) end; @@ -89,12 +89,12 @@ begin Gear^.Message:= Gear^.Message and not gm_Timer; with PHedgehog(Gear^.Hedgehog)^ do - if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Timerable) <> 0 then - begin - Ammo^[CurSlot, CurAmmo].Timer:= 1000 * Gear^.MsgParam; - with CurrentTeam^ do - ApplyAmmoChanges(Hedgehogs[CurrHedgehog]); - end; + if (Ammo^[CurSlot, CurAmmo].Propz and ammoprop_Timerable) <> 0 then + begin + Ammo^[CurSlot, CurAmmo].Timer:= 1000 * Gear^.MsgParam; + with CurrentTeam^ do + ApplyAmmoChanges(Hedgehogs[CurrHedgehog]); + end; end; @@ -165,9 +165,9 @@ PlaySound(sndWhipCrack) end; amBaseballBat: begin - CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtShover, gsttmpFlag, xx * _0_5, yy * _0_5, 0); - PlaySound(sndBaseballBat) - end; + CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtShover, gsttmpFlag, xx * _0_5, yy * _0_5, 0); + PlaySound(sndBaseballBat) + end; amParachute: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtParachute, 0, _0, _0, 0); amAirAttack: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 0, _0, _0, 0); amMineStrike: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 1, _0, _0, 0); @@ -176,9 +176,9 @@ amTeleport: CurAmmoGear:= AddGear(0, 0, gtTeleport, 0, _0, _0, 0); amSwitch: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtSwitcher, 0, _0, _0, 0); amMortar: begin - playSound(sndMortar); - FollowGear:= AddGear(hwRound(X), hwRound(Y), gtMortar, 0, xx*cMaxPower/cPowerDivisor, yy*cMaxPower/cPowerDivisor, 0); - end; + playSound(sndMortar); + FollowGear:= AddGear(hwRound(X), hwRound(Y), gtMortar, 0, xx*cMaxPower/cPowerDivisor, yy*cMaxPower/cPowerDivisor, 0); + end; amRCPlane: begin CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtRCPlane, 0, xx * cMaxPower / cPowerDivisor / 4, yy * cMaxPower / cPowerDivisor / 4, 0); CurAmmoGear^.SoundChannel:= LoopSound(sndRCPlane, nil) @@ -237,38 +237,38 @@ var s: shortstring; begin with CurrentHedgehog^.Gear^, - CurrentHedgehog^ do - begin - State:= State and not gstAttacking; - if ((Ammo^[CurSlot, CurAmmo].Propz) and ammoprop_Utility) = 0 then - begin - Inc(MultiShootAttacks); - - if (Ammo^[CurSlot, CurAmmo].NumPerTurn >= MultiShootAttacks) then - begin - s:= inttostr(Ammo^[CurSlot, CurAmmo].NumPerTurn + 1 - MultiShootAttacks); - AddCaption(format(trmsg[sidRemaining], s), cWhiteColor, capgrpAmmostate); - end; - - if (Ammo^[CurSlot, CurAmmo].NumPerTurn >= MultiShootAttacks) or - ((GameFlags and gfMultiWeapon) <> 0) then - begin - isInMultiShoot:= true - end - else - begin - TurnTimeLeft:= Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].TimeAfterTurn; - State:= State or gstAttacked; - OnUsedAmmo(CurrentHedgehog^); - end; - end - else - begin - OnUsedAmmo(CurrentHedgehog^); - ApplyAmmoChanges(CurrentHedgehog^); - end; - AttackBar:= 0; - end + CurrentHedgehog^ do + begin + State:= State and not gstAttacking; + if ((Ammo^[CurSlot, CurAmmo].Propz) and ammoprop_Utility) = 0 then + begin + Inc(MultiShootAttacks); + + if (Ammo^[CurSlot, CurAmmo].NumPerTurn >= MultiShootAttacks) then + begin + s:= inttostr(Ammo^[CurSlot, CurAmmo].NumPerTurn + 1 - MultiShootAttacks); + AddCaption(format(trmsg[sidRemaining], s), cWhiteColor, capgrpAmmostate); + end; + + if (Ammo^[CurSlot, CurAmmo].NumPerTurn >= MultiShootAttacks) or + ((GameFlags and gfMultiWeapon) <> 0) then + begin + isInMultiShoot:= true + end + else + begin + TurnTimeLeft:= Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].TimeAfterTurn; + State:= State or gstAttacked; + OnUsedAmmo(CurrentHedgehog^); + end; + end + else + begin + OnUsedAmmo(CurrentHedgehog^); + ApplyAmmoChanges(CurrentHedgehog^); + end; + AttackBar:= 0; + end end; //////////////////////////////////////////////////////////////////////////////// @@ -278,35 +278,35 @@ begin if PHedgehog(Gear^.Hedgehog)^.Unplaced then exit; if Gear^.Timer > 1 then - begin - AllInactive:= false; - dec(Gear^.Timer); - if (Gear^.Timer mod frametime) = 0 then inc(Gear^.Pos) - end else + begin + AllInactive:= false; + dec(Gear^.Timer); + if (Gear^.Timer mod frametime) = 0 then inc(Gear^.Pos) + end else if Gear^.Timer = 1 then - begin - Gear^.State:= Gear^.State or gstNoDamage; - doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); - AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtGrave, 0, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; - DeleteGear(Gear); - SetAllToActive - end else // Gear^.Timer = 0 - begin - AllInactive:= false; - Gear^.Z:= cCurrHHZ; - RemoveGearFromList(Gear); - InsertGearToList(Gear); - PlaySound(sndByeBye, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack); - Gear^.Pos:= 0; - Gear^.Timer:= timertime - end + begin + Gear^.State:= Gear^.State or gstNoDamage; + doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); + AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtGrave, 0, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; + DeleteGear(Gear); + SetAllToActive + end else // Gear^.Timer = 0 + begin + AllInactive:= false; + Gear^.Z:= cCurrHHZ; + RemoveGearFromList(Gear); + InsertGearToList(Gear); + PlaySound(sndByeBye, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack); + Gear^.Pos:= 0; + Gear^.Timer:= timertime + end end; //////////////////////////////////////////////////////////////////////////////// procedure PickUp(HH, Gear: PGear); var s: shortstring; a: TAmmoType; - i: Integer; + i: Integer; begin Gear^.Message:= gm_Destroy; PlaySound(sndShotgunReload); @@ -334,12 +334,12 @@ RenderHealth(PHedgehog(HH^.Hedgehog)^); RecountTeamHealth(PHedgehog(HH^.Hedgehog)^.Team); - i:= 0; - while i < Gear^.Health do - begin - AddVisualGear(hwRound(HH^.X), hwRound(HH^.Y), vgtHealth); - inc(i, 5); - end; + i:= 0; + while i < Gear^.Health do + begin + AddVisualGear(hwRound(HH^.X), hwRound(HH^.Y), vgtHealth); + inc(i, 5); + end; end; end end; @@ -365,14 +365,14 @@ exit end; - if ((Gear^.Message and gm_Animate) <> 0) then - begin - Gear^.Message:= 0; - Gear^.State:= Gear^.State or gstAnimation; - Gear^.Tag:= Gear^.MsgParam; - Gear^.Timer:= 0; - Gear^.Pos:= 0 - end; + if ((Gear^.Message and gm_Animate) <> 0) then + begin + Gear^.Message:= 0; + Gear^.State:= Gear^.State or gstAnimation; + Gear^.Tag:= Gear^.MsgParam; + Gear^.Timer:= 0; + Gear^.Pos:= 0 + end; if ((Gear^.Message and gm_LJump ) <> 0) then begin @@ -482,13 +482,13 @@ var da: LongWord; begin with PHedgehog(Gear^.Hedgehog)^ do - if (Ammo^[CurSlot, CurAmmo].AmmoType = amRope) - and ((Gear^.State and (gstMoving or gstHHJumping)) = gstMoving) then da:= 2 else da:= 1; + if (Ammo^[CurSlot, CurAmmo].AmmoType = amRope) + and ((Gear^.State and (gstMoving or gstHHJumping)) = gstMoving) then da:= 2 else da:= 1; if (((Gear^.Message and gm_Precise) = 0) or ((GameTicks mod 5) = 1)) then - if ((Gear^.Message and gm_Up) <> 0) and (Gear^.Angle >= CurMinAngle + da) then dec(Gear^.Angle, da) - else - if ((Gear^.Message and gm_Down) <> 0) and (Gear^.Angle + da <= CurMaxAngle) then inc(Gear^.Angle, da) + if ((Gear^.Message and gm_Up) <> 0) and (Gear^.Angle >= CurMinAngle + da) then dec(Gear^.Angle, da) + else + if ((Gear^.Message and gm_Down) <> 0) and (Gear^.Angle + da <= CurMaxAngle) then inc(Gear^.Angle, da) end; procedure doStepHedgehog(Gear: PGear); forward; @@ -583,22 +583,22 @@ if (hwAbs(Gear^.dY) > _0) and (Gear^.FlightTime > 0) then begin inc(Gear^.FlightTime, 1); - if Gear^.FlightTime = 2000 then - begin - AddCaption(GetEventString(eidHomerun), cWhiteColor, capgrpMessage); - PlaySound(sndHomerun) - end; - end + if Gear^.FlightTime = 2000 then + begin + AddCaption(GetEventString(eidHomerun), cWhiteColor, capgrpMessage); + PlaySound(sndHomerun) + end; + end else begin Gear^.FlightTime:= 0; - end; + end; end; procedure doStepHedgehogDriven(Gear: PGear); var t: PGear; - wasJumping: boolean; + wasJumping: boolean; begin if not isInMultiShoot then AllInactive:= false @@ -606,72 +606,72 @@ Gear^.Message:= 0; if (TurnTimeLeft = 0) or (Gear^.Damage > 0) then - begin - TurnTimeLeft:= 0; - isCursorVisible:= false; - Gear^.State:= Gear^.State and not (gstHHDriven or gstAnimation or gstAttacking); - AttackBar:= 0; - if Gear^.Damage > 0 then - Gear^.State:= Gear^.State and not (gstHHJumping or gstHHHJump); - exit - end; + begin + TurnTimeLeft:= 0; + isCursorVisible:= false; + Gear^.State:= Gear^.State and not (gstHHDriven or gstAnimation or gstAttacking); + AttackBar:= 0; + if Gear^.Damage > 0 then + Gear^.State:= Gear^.State and not (gstHHJumping or gstHHHJump); + exit + end; if (Gear^.State and gstAnimation) <> 0 then - begin - Gear^.Message:= 0; - if (Gear^.Pos = Wavez[TWave(Gear^.Tag)].VoiceDelay) and (Gear^.Timer = 0) then PlaySound(Wavez[TWave(Gear^.Tag)].Voice, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack); - inc(Gear^.Timer); - if Gear^.Timer = Wavez[TWave(Gear^.Tag)].Interval then - begin - Gear^.Timer:= 0; - inc(Gear^.Pos); - if Gear^.Pos = Wavez[TWave(Gear^.Tag)].FramesCount then - Gear^.State:= Gear^.State and not gstAnimation - end; - exit - end; + begin + Gear^.Message:= 0; + if (Gear^.Pos = Wavez[TWave(Gear^.Tag)].VoiceDelay) and (Gear^.Timer = 0) then PlaySound(Wavez[TWave(Gear^.Tag)].Voice, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack); + inc(Gear^.Timer); + if Gear^.Timer = Wavez[TWave(Gear^.Tag)].Interval then + begin + Gear^.Timer:= 0; + inc(Gear^.Pos); + if Gear^.Pos = Wavez[TWave(Gear^.Tag)].FramesCount then + Gear^.State:= Gear^.State and not gstAnimation + end; + exit + end; if ((Gear^.State and gstMoving) <> 0) or (StepTicks = cHHStepTicks) - or (CurAmmoGear <> nil) then // we are moving - begin - with PHedgehog(Gear^.Hedgehog)^ do - if (CurAmmoGear = nil) - and (Gear^.dY > _0_39) - and (Ammo^[CurSlot, CurAmmo].AmmoType = amParachute) then Gear^.Message:= Gear^.Message or gm_Attack; - // check for case with ammo - t:= CheckGearNear(Gear, gtCase, 36, 36); - if t <> nil then - PickUp(Gear, t) - end; + or (CurAmmoGear <> nil) then // we are moving + begin + with PHedgehog(Gear^.Hedgehog)^ do + if (CurAmmoGear = nil) + and (Gear^.dY > _0_39) + and (Ammo^[CurSlot, CurAmmo].AmmoType = amParachute) then Gear^.Message:= Gear^.Message or gm_Attack; + // check for case with ammo + t:= CheckGearNear(Gear, gtCase, 36, 36); + if t <> nil then + PickUp(Gear, t) + end; if (CurAmmoGear = nil) then - if (((Gear^.Message and gm_Attack) <> 0) - or ((Gear^.State and gstAttacking) <> 0)) then - Attack(Gear) // should be before others to avoid desync with '/put' msg and changing weapon msgs - else + if (((Gear^.Message and gm_Attack) <> 0) + or ((Gear^.State and gstAttacking) <> 0)) then + Attack(Gear) // should be before others to avoid desync with '/put' msg and changing weapon msgs + else else with PHedgehog(Gear^.Hedgehog)^ do - if ((CurAmmoGear^.Ammo^.Propz and ammoprop_AltAttack) <> 0) - and ((Gear^.Message and gm_LJump) <> 0) - and (((Ammo^[CurSlot, CurAmmo].Propz) and ammoprop_AltUse) <> 0) then - begin - Gear^.Message:= Gear^.Message and not gm_LJump; - Attack(Gear) - end; + if ((CurAmmoGear^.Ammo^.Propz and ammoprop_AltAttack) <> 0) + and ((Gear^.Message and gm_LJump) <> 0) + and (((Ammo^[CurSlot, CurAmmo].Propz) and ammoprop_AltUse) <> 0) then + begin + Gear^.Message:= Gear^.Message and not gm_LJump; + Attack(Gear) + end; if (CurAmmoGear = nil) - or ((CurAmmoGear^.Ammo^.Propz and ammoprop_AltAttack) <> 0) then - begin - if ((Gear^.Message and gm_Slot) <> 0) then - begin - ChangeAmmo(Gear); - ApplyAmmoChanges(PHedgehog(Gear^.Hedgehog)^) - end; + or ((CurAmmoGear^.Ammo^.Propz and ammoprop_AltAttack) <> 0) then + begin + if ((Gear^.Message and gm_Slot) <> 0) then + begin + ChangeAmmo(Gear); + ApplyAmmoChanges(PHedgehog(Gear^.Hedgehog)^) + end; - if ((Gear^.Message and gm_Weapon) <> 0) then HHSetWeapon(Gear); + if ((Gear^.Message and gm_Weapon) <> 0) then HHSetWeapon(Gear); - if ((Gear^.Message and gm_Timer) <> 0) then HHSetTimer(Gear); - end; + if ((Gear^.Message and gm_Timer) <> 0) then HHSetTimer(Gear); + end; if CurAmmoGear <> nil then begin @@ -683,43 +683,43 @@ HedgehogChAngle(Gear); if (Gear^.State and gstMoving) <> 0 then - begin - wasJumping:= ((Gear^.State and gstHHJumping) <> 0); + begin + wasJumping:= ((Gear^.State and gstHHJumping) <> 0); - if ((Gear^.Message and gm_HJump) <> 0) and - wasJumping and - ((Gear^.State and gstHHHJump) = 0) then - if (not (hwAbs(Gear^.dX) > cLittle)) and (Gear^.dY < -_0_02) then - begin - Gear^.State:= Gear^.State or gstHHHJump; - Gear^.dY:= -_0_25; - if not cArtillery then Gear^.dX:= -SignAs(_0_02, Gear^.dX); - PlaySound(sndJump2, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack) - end; + if ((Gear^.Message and gm_HJump) <> 0) and + wasJumping and + ((Gear^.State and gstHHHJump) = 0) then + if (not (hwAbs(Gear^.dX) > cLittle)) and (Gear^.dY < -_0_02) then + begin + Gear^.State:= Gear^.State or gstHHHJump; + Gear^.dY:= -_0_25; + if not cArtillery then Gear^.dX:= -SignAs(_0_02, Gear^.dX); + PlaySound(sndJump2, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack) + end; - Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); + Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); - if (not cArtillery) and wasJumping and - TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then SetLittle(Gear^.dX); + if (not cArtillery) and wasJumping and + TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then SetLittle(Gear^.dX); - doStepHedgehogMoving(Gear); + doStepHedgehogMoving(Gear); - if ((Gear^.State and (gstMoving or gstDrowning)) = 0) then - begin - AddGearCI(Gear); - if wasJumping then - StepTicks:= 410 - else - StepTicks:= 95 - end; - exit - end; + if ((Gear^.State and (gstMoving or gstDrowning)) = 0) then + begin + AddGearCI(Gear); + if wasJumping then + StepTicks:= 410 + else + StepTicks:= 95 + end; + exit + end; - if not isInMultiShoot then - begin - if StepTicks > 0 then dec(StepTicks); - if (StepTicks = 0) then HedgehogStep(Gear) - end + if not isInMultiShoot then + begin + if StepTicks > 0 then dec(StepTicks); + if (StepTicks = 0) then HedgehogStep(Gear) + end end; //////////////////////////////////////////////////////////////////////////////// @@ -731,44 +731,44 @@ doStepHedgehogMoving(Gear); if (Gear^.State and (gstMoving or gstDrowning)) <> 0 then - begin - if Gear^.Damage > 0 then CalcRotationDirAngle(Gear); - AllInactive:= false; - exit - end; + begin + if Gear^.Damage > 0 then CalcRotationDirAngle(Gear); + AllInactive:= false; + exit + end; if (Gear^.Health = 0) then - begin - if PrvInactive then - begin - Gear^.Timer:= 0; - Gear^.State:= Gear^.State or gstHHDeath; - Gear^.doStep:= @doStepHedgehogDead; - FollowGear:= Gear; - PrvInactive:= false; - AllInactive:= false; + begin + if PrvInactive then + begin + Gear^.Timer:= 0; + Gear^.State:= Gear^.State or gstHHDeath; + Gear^.doStep:= @doStepHedgehogDead; + FollowGear:= Gear; + PrvInactive:= false; + AllInactive:= false; - // Death message - AddCaption(Format(GetEventString(eidDied), PHedgehog(Gear^.Hedgehog)^.Name), cWhiteColor, capgrpMessage); - end; - exit - end; + // Death message + AddCaption(Format(GetEventString(eidDied), PHedgehog(Gear^.Hedgehog)^.Name), cWhiteColor, capgrpMessage); + end; + exit + end; if ((Gear^.State and gstWait) = 0) and - (prevState <> Gear^.State) then - begin - Gear^.State:= gstWait; - Gear^.Timer:= 150 - end else - begin - if Gear^.Timer = 0 then - begin - Gear^.State:= 0; - Gear^.Active:= false; - AddGearCI(Gear); - exit - end else dec(Gear^.Timer) - end; + (prevState <> Gear^.State) then + begin + Gear^.State:= gstWait; + Gear^.Timer:= 150 + end else + begin + if Gear^.Timer = 0 then + begin + Gear^.State:= 0; + Gear^.Active:= false; + AddGearCI(Gear); + exit + end else dec(Gear^.Timer) + end; AllInactive:= false end; @@ -777,17 +777,17 @@ procedure doStepHedgehog(Gear: PGear); begin if (Gear^.Message and gm_Destroy) <> 0 then - begin - DeleteGear(Gear); - exit - end; + begin + DeleteGear(Gear); + exit + end; if (Gear^.State and gstHHDriven) = 0 then - doStepHedgehogFree(Gear) + doStepHedgehogFree(Gear) else - begin - with PHedgehog(Gear^.Hedgehog)^ do - if Team^.hasGone then TeamGoneEffect(Team^); - doStepHedgehogDriven(Gear) - end; + begin + with PHedgehog(Gear^.Hedgehog)^ do + if Team^.hasGone then TeamGoneEffect(Team^); + doStepHedgehogDriven(Gear) + end; end; diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/LuaPas.pas --- a/hedgewars/LuaPas.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/LuaPas.pas Sat Mar 06 10:59:20 2010 +0000 @@ -90,7 +90,7 @@ */ #include #include -#define lua_stdin_is_tty() _isatty(_fileno(stdin)) +#define lua_stdin_is_tty() _isatty(_fileno(stdin)) *) const lua_stdin_is_tty = TRUE; @@ -165,7 +165,7 @@ LUA_TSTRING = 4; LUA_TTABLE = 5; LUA_TFUNCTION = 6; - LUA_TUSERDATA = 7; + LUA_TUSERDATA = 7; LUA_TTHREAD = 8; (* minimum Lua stack available to a C function *) @@ -360,7 +360,7 @@ LUA_GCRESTART = 1; LUA_GCCOLLECT = 2; LUA_GCCOUNT = 3; - LUA_GCCOUNTB = 4; + LUA_GCCOUNTB = 4; LUA_GCSTEP = 5; LUA_GCSETPAUSE = 6; LUA_GCSETSTEPMUL = 7; diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/PascalExports.pas --- a/hedgewars/PascalExports.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/PascalExports.pas Sat Mar 06 10:59:20 2010 +0000 @@ -51,88 +51,88 @@ {$IFDEF HWLIBRARY} procedure HW_versionInfo(netProto: PShortInt; versionStr: PString); cdecl; export; begin - if netProto <> nil then netProto^:= cNetProtoVersion; - if versionStr <> nil then versionStr^:= shortstring(cVersionString); + if netProto <> nil then netProto^:= cNetProtoVersion; + if versionStr <> nil then versionStr^:= shortstring(cVersionString); end; procedure HW_click; cdecl; export; begin - leftClick:= true; + leftClick:= true; end; procedure HW_zoomIn; cdecl; export; begin - wheelUp:= true; + wheelUp:= true; end; procedure HW_zoomOut; cdecl; export; begin - wheelDown:= true; + wheelDown:= true; end; procedure HW_zoomReset; cdecl; export; begin - middleClick:= true; + middleClick:= true; end; procedure HW_ammoMenu; cdecl; export; begin - rightClick:= true; + rightClick:= true; end; procedure HW_allKeysUp; cdecl; export; begin - // set all keys to released - init_uKeys(); + // set all keys to released + init_uKeys(); end; procedure HW_walkLeft; cdecl; export; begin - leftKey:= true; + leftKey:= true; end; procedure HW_walkRight; cdecl; export; begin - rightKey:= true; + rightKey:= true; end; procedure HW_aimUp; cdecl; export; begin - upKey:= true; + upKey:= true; end; procedure HW_aimDown; cdecl; export; begin - downKey:= true; + downKey:= true; end; procedure HW_shoot; cdecl; export; begin - spaceKey:= true; + spaceKey:= true; end; procedure HW_chat; cdecl; export; begin - chatAction:= true; + chatAction:= true; end; procedure HW_tab; cdecl; export; begin - switchAction:= true; + switchAction:= true; end; procedure HW_pause; cdecl; export; begin - pauseAction:= true; + pauseAction:= true; end; procedure HW_whereIsHog; cdecl; export; //var Xcoord, Ycoord: LongInt; begin - //Xcoord:= Gear^.dX + WorldDx; - WriteLnToConsole('HW - hog is at x: ' + ' y:'); + //Xcoord:= Gear^.dX + WorldDx; + WriteLnToConsole('HW - hog is at x: ' + ' y:'); - exit + exit end; {$ENDIF} diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/SDLh.pas --- a/hedgewars/SDLh.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/SDLh.pas Sat Mar 06 10:59:20 2010 +0000 @@ -57,24 +57,24 @@ (* SDL *) const {$IFDEF WIN32} - SDLLibName = 'SDL.dll'; - SDL_TTFLibName = 'SDL_ttf.dll'; - SDL_MixerLibName = 'SDL_mixer.dll'; - SDL_ImageLibName = 'SDL_image.dll'; - SDL_NetLibName = 'SDL_net.dll'; + SDLLibName = 'SDL.dll'; + SDL_TTFLibName = 'SDL_ttf.dll'; + SDL_MixerLibName = 'SDL_mixer.dll'; + SDL_ImageLibName = 'SDL_image.dll'; + SDL_NetLibName = 'SDL_net.dll'; {$ELSE} {$IFDEF DARWIN} - SDLLibName = 'SDL'; - SDL_TTFLibName = 'SDL_ttf'; - SDL_MixerLibName = 'SDL_mixer'; - SDL_ImageLibName = 'SDL_image'; - SDL_NetLibName = 'SDL_net'; + SDLLibName = 'SDL'; + SDL_TTFLibName = 'SDL_ttf'; + SDL_MixerLibName = 'SDL_mixer'; + SDL_ImageLibName = 'SDL_image'; + SDL_NetLibName = 'SDL_net'; {$ELSE} - SDLLibName = 'libSDL.so'; - SDL_TTFLibName = 'libSDL_ttf.so'; - SDL_MixerLibName = 'libSDL_mixer.so'; - SDL_ImageLibName = 'libSDL_image.so'; - SDL_NetLibName = 'libSDL_net.so'; + SDLLibName = 'libSDL.so'; + SDL_TTFLibName = 'libSDL_ttf.so'; + SDL_MixerLibName = 'libSDL_mixer.so'; + SDL_ImageLibName = 'libSDL_image.so'; + SDL_NetLibName = 'libSDL_net.so'; {$ENDIF} {$ENDIF} @@ -82,97 +82,97 @@ ///////////////////// CONSTANT DEFINITIONS ///////////////////// ///////////////////////////////////////////////////////////////// - SDL_SWSURFACE = $00000000; - SDL_HWSURFACE = $00000001; - SDL_SRCALPHA = $00010000; - - SDL_INIT_TIMER = $00000001; - SDL_INIT_AUDIO = $00000010; - SDL_INIT_VIDEO = $00000020; - SDL_INIT_JOYSTICK = $00000200; + SDL_SWSURFACE = $00000000; + SDL_HWSURFACE = $00000001; + SDL_SRCALPHA = $00010000; + + SDL_INIT_TIMER = $00000001; + SDL_INIT_AUDIO = $00000010; + SDL_INIT_VIDEO = $00000020; + SDL_INIT_JOYSTICK = $00000200; {$IFDEF SDL13} - SDL_INIT_HAPTIC = $00001000; + SDL_INIT_HAPTIC = $00001000; {$ELSE} - SDL_INIT_CDROM = $00000100; + SDL_INIT_CDROM = $00000100; {$ENDIF} - SDL_INIT_NOPARACHUTE = $00100000; - SDL_INIT_EVENTTHREAD = $01000000; - SDL_INIT_EVERYTHING = $0000FFFF; + SDL_INIT_NOPARACHUTE = $00100000; + SDL_INIT_EVENTTHREAD = $01000000; + SDL_INIT_EVERYTHING = $0000FFFF; - SDL_APPINPUTFOCUS = 2; - SDL_BUTTON_WHEELUP = 4; - SDL_BUTTON_WHEELDOWN = 5; - + SDL_APPINPUTFOCUS = 2; + SDL_BUTTON_WHEELUP = 4; + SDL_BUTTON_WHEELDOWN = 5; + {*begin SDL_Event binding*} - SDL_NOEVENT = 0; - SDL_KEYDOWN = 2; - SDL_KEYUP = 3; + SDL_NOEVENT = 0; + SDL_KEYDOWN = 2; + SDL_KEYUP = 3; {$IFDEF SDL13} SDL_WINDOWEVENT = 1; SDL_TEXTINPUT = 4; SDL_TEXTEDITING = 5; - SDL_MOUSEMOTION = 6; + SDL_MOUSEMOTION = 6; SDL_MOUSEBUTTONDOWN = 7; - SDL_MOUSEBUTTONUP = 8; + SDL_MOUSEBUTTONUP = 8; SDL_MOUSEWHEEL = 9; - SDL_JOYAXISMOTION = 10; - SDL_JOYBALLMOTION = 11; - SDL_JOYHATMOTION = 12; - SDL_JOYBUTTONDOWN = 13; - SDL_JOYBUTTONUP = 14; - SDL_QUITEV = 15; + SDL_JOYAXISMOTION = 10; + SDL_JOYBALLMOTION = 11; + SDL_JOYHATMOTION = 12; + SDL_JOYBUTTONDOWN = 13; + SDL_JOYBUTTONUP = 14; + SDL_QUITEV = 15; {$ELSE} SDL_ACTIVEEVENT = 1; - SDL_MOUSEMOTION = 4; - SDL_MOUSEBUTTONDOWN = 5; - SDL_MOUSEBUTTONUP = 6; - SDL_JOYAXISMOTION = 7; - SDL_JOYBALLMOTION = 8; - SDL_JOYHATMOTION = 9; - SDL_JOYBUTTONDOWN = 10; - SDL_JOYBUTTONUP = 11; - SDL_QUITEV = 12; - SDL_VIDEORESIZE = 16; // TODO: outdated? no longer in SDL 1.3? + SDL_MOUSEMOTION = 4; + SDL_MOUSEBUTTONDOWN = 5; + SDL_MOUSEBUTTONUP = 6; + SDL_JOYAXISMOTION = 7; + SDL_JOYBALLMOTION = 8; + SDL_JOYHATMOTION = 9; + SDL_JOYBUTTONDOWN = 10; + SDL_JOYBUTTONUP = 11; + SDL_QUITEV = 12; + SDL_VIDEORESIZE = 16; // TODO: outdated? no longer in SDL 1.3? {$ENDIF} {*end SDL_Event binding*} - + {$IFDEF SDL13} - SDL_ASYNCBLIT = $08000000; - SDL_ANYFORMAT = $10000000; - SDL_HWPALETTE = $00200000; - SDL_DOUBLEBUF = $00400000; - SDL_FULLSCREEN = $00800000; - SDL_HWACCEL = $08000000; - SDL_SRCCOLORKEY = $00020000; - SDL_RLEACCEL = $08000000; - SDL_NOFRAME = $02000000; - SDL_OPENGL = $04000000; - SDL_RESIZABLE = $01000000; + SDL_ASYNCBLIT = $08000000; + SDL_ANYFORMAT = $10000000; + SDL_HWPALETTE = $00200000; + SDL_DOUBLEBUF = $00400000; + SDL_FULLSCREEN = $00800000; + SDL_HWACCEL = $08000000; + SDL_SRCCOLORKEY = $00020000; + SDL_RLEACCEL = $08000000; + SDL_NOFRAME = $02000000; + SDL_OPENGL = $04000000; + SDL_RESIZABLE = $01000000; {$ELSE} - SDL_ASYNCBLIT = $00000004; - SDL_ANYFORMAT = $00100000; - SDL_HWPALETTE = $20000000; - SDL_DOUBLEBUF = $40000000; - SDL_FULLSCREEN = $80000000; - SDL_HWACCEL = $00000100; - SDL_SRCCOLORKEY = $00001000; - SDL_RLEACCEL = $00004000; - SDL_NOFRAME = $00000020; - SDL_OPENGL = $00000002; - SDL_RESIZABLE = $00000010; + SDL_ASYNCBLIT = $00000004; + SDL_ANYFORMAT = $00100000; + SDL_HWPALETTE = $20000000; + SDL_DOUBLEBUF = $40000000; + SDL_FULLSCREEN = $80000000; + SDL_HWACCEL = $00000100; + SDL_SRCCOLORKEY = $00001000; + SDL_RLEACCEL = $00004000; + SDL_NOFRAME = $00000020; + SDL_OPENGL = $00000002; + SDL_RESIZABLE = $00000010; {$ENDIF} {$IFDEF ENDIAN_LITTLE} - RMask = $000000FF; - GMask = $0000FF00; - BMask = $00FF0000; - AMask = $FF000000; + RMask = $000000FF; + GMask = $0000FF00; + BMask = $00FF0000; + AMask = $FF000000; {$ELSE} - RMask = $FF000000; - GMask = $00FF0000; - BMask = $0000FF00; - AMask = $000000FF; + RMask = $FF000000; + GMask = $00FF0000; + BMask = $0000FF00; + AMask = $000000FF; {$ENDIF} {$IFDEF SDL13} @@ -190,391 +190,391 @@ SDL_WINDOW_FOREIGN = $00000800; //*< window not created by SDL */ {$ENDIF} - {* SDL_mixer *} - MIX_MAX_VOLUME = 128; - MIX_INIT_FLAC = $00000001; - MIX_INIT_MOD = $00000002; - MIX_INIT_MP3 = $00000004; - MIX_INIT_OGG = $00000008; - - {* SDL_TTF *} - TTF_STYLE_NORMAL = 0; - TTF_STYLE_BOLD = 1; - TTF_STYLE_ITALIC = 2; + {* SDL_mixer *} + MIX_MAX_VOLUME = 128; + MIX_INIT_FLAC = $00000001; + MIX_INIT_MOD = $00000002; + MIX_INIT_MP3 = $00000004; + MIX_INIT_OGG = $00000008; + + {* SDL_TTF *} + TTF_STYLE_NORMAL = 0; + TTF_STYLE_BOLD = 1; + TTF_STYLE_ITALIC = 2; - {* SDL Joystick *} - SDL_HAT_CENTERED = $00; - SDL_HAT_UP = $01; - SDL_HAT_RIGHT = $02; - SDL_HAT_DOWN = $04; - SDL_HAT_LEFT = $08; - SDL_HAT_RIGHTUP = SDL_HAT_RIGHT or SDL_HAT_UP; - SDL_HAT_RIGHTDOWN = SDL_HAT_RIGHT or SDL_HAT_DOWN; - SDL_HAT_LEFTUP = SDL_HAT_LEFT or SDL_HAT_UP; - SDL_HAT_LEFTDOWN = SDL_HAT_LEFT or SDL_HAT_DOWN; + {* SDL Joystick *} + SDL_HAT_CENTERED = $00; + SDL_HAT_UP = $01; + SDL_HAT_RIGHT = $02; + SDL_HAT_DOWN = $04; + SDL_HAT_LEFT = $08; + SDL_HAT_RIGHTUP = SDL_HAT_RIGHT or SDL_HAT_UP; + SDL_HAT_RIGHTDOWN = SDL_HAT_RIGHT or SDL_HAT_DOWN; + SDL_HAT_LEFTUP = SDL_HAT_LEFT or SDL_HAT_UP; + SDL_HAT_LEFTDOWN = SDL_HAT_LEFT or SDL_HAT_DOWN; - {* SDL_image *} - IMG_INIT_JPG = $00000001; - IMG_INIT_PNG = $00000002; - IMG_INIT_TIF = $00000004; + {* SDL_image *} + IMG_INIT_JPG = $00000001; + IMG_INIT_PNG = $00000002; + IMG_INIT_TIF = $00000004; ///////////////////////////////////////////////////////////////// /////////////////////// TYPE DEFINITIONS /////////////////////// ///////////////////////////////////////////////////////////////// type - PSDL_Rect = ^TSDL_Rect; - TSDL_Rect = record + PSDL_Rect = ^TSDL_Rect; + TSDL_Rect = record {$IFDEF SDL13} - x, y, w, h: LongInt; + x, y, w, h: LongInt; {$ELSE} - x, y: SmallInt; - w, h: Word; + x, y: SmallInt; + w, h: Word; {$ENDIF} - end; + end; - TPoint = record - X: LongInt; - Y: LongInt; - end; + TPoint = record + X: LongInt; + Y: LongInt; + end; - PSDL_PixelFormat = ^TSDL_PixelFormat; - TSDL_PixelFormat = record - palette: Pointer; - BitsPerPixel : Byte; - BytesPerPixel: Byte; - Rloss : Byte; - Gloss : Byte; - Bloss : Byte; - Aloss : Byte; - Rshift: Byte; - Gshift: Byte; - Bshift: Byte; - Ashift: Byte; - RMask : Longword; - GMask : Longword; - BMask : Longword; - AMask : Longword; - colorkey: Longword; - alpha : Byte; - end; + PSDL_PixelFormat = ^TSDL_PixelFormat; + TSDL_PixelFormat = record + palette: Pointer; + BitsPerPixel : Byte; + BytesPerPixel: Byte; + Rloss : Byte; + Gloss : Byte; + Bloss : Byte; + Aloss : Byte; + Rshift: Byte; + Gshift: Byte; + Bshift: Byte; + Ashift: Byte; + RMask : Longword; + GMask : Longword; + BMask : Longword; + AMask : Longword; + colorkey: Longword; + alpha : Byte; + end; - PSDL_Surface = ^TSDL_Surface; - TSDL_Surface = record - flags : Longword; - format: PSDL_PixelFormat; - w, h : LongInt; - pitch : Word; - pixels: Pointer; - offset: LongInt; - end; + PSDL_Surface = ^TSDL_Surface; + TSDL_Surface = record + flags : Longword; + format: PSDL_PixelFormat; + w, h : LongInt; + pitch : Word; + pixels: Pointer; + offset: LongInt; + end; - PSDL_Color = ^TSDL_Color; - TSDL_Color = record - case byte of - 0: ( r: Byte; - g: Byte; - b: Byte; - unused: Byte; - ); - 1: ( value: Longword); - end; + PSDL_Color = ^TSDL_Color; + TSDL_Color = record + case byte of + 0: ( r: Byte; + g: Byte; + b: Byte; + unused: Byte; + ); + 1: ( value: Longword); + end; - PSDL_RWops = ^TSDL_RWops; - TSeek = function( context: PSDL_RWops; offset: LongInt; whence: LongInt ): LongInt; cdecl; - TRead = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; maxnum : LongInt ): LongInt; cdecl; - TWrite = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; num: LongInt ): LongInt; cdecl; - TClose = function( context: PSDL_RWops ): LongInt; cdecl; + PSDL_RWops = ^TSDL_RWops; + TSeek = function( context: PSDL_RWops; offset: LongInt; whence: LongInt ): LongInt; cdecl; + TRead = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; maxnum : LongInt ): LongInt; cdecl; + TWrite = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; num: LongInt ): LongInt; cdecl; + TClose = function( context: PSDL_RWops ): LongInt; cdecl; - TStdio = record - autoclose: LongInt; - fp: pointer; - end; + TStdio = record + autoclose: LongInt; + fp: pointer; + end; - TMem = record - base: PByte; - here: PByte; - stop: PByte; - end; + TMem = record + base: PByte; + here: PByte; + stop: PByte; + end; - TUnknown = record - data1: Pointer; - end; + TUnknown = record + data1: Pointer; + end; - TSDL_RWops = record - seek: TSeek; - read: TRead; - write: TWrite; - close: TClose; - type_: Longword; - case Byte of - 0: (stdio: TStdio); - 1: (mem: TMem); - 2: (unknown: TUnknown); - end; + TSDL_RWops = record + seek: TSeek; + read: TRead; + write: TWrite; + close: TClose; + type_: Longword; + case Byte of + 0: (stdio: TStdio); + 1: (mem: TMem); + 2: (unknown: TUnknown); + end; - TSDL_KeySym = record - scancode: Byte; - sym: Longword; - modifier: Longword; - unicode: Word; - end; + TSDL_KeySym = record + scancode: Byte; + sym: Longword; + modifier: Longword; + unicode: Word; + end; {* SDL_Event type definition *} {$IFDEF SDL13} - PSDL_Window = pointer; - PSDL_Texture = pointer; - - TSDL_WindowEvent = record - type_: byte; - gain: byte; - state: byte; - windowID: LongInt; - data1, data2: LongInt; - end; + PSDL_Window = pointer; + PSDL_Texture = pointer; + + TSDL_WindowEvent = record + type_: byte; + gain: byte; + state: byte; + windowID: LongInt; + data1, data2: LongInt; + end; // implement SDL_TextEditingEvent + SDL_TextInputEvent for sdl13 {$ELSE} - //these two are present in sdl1.3 but only for backward compatibility - TSDL_ActiveEvent = record - type_: byte; - gain: byte; - state: byte; - end; + //these two are present in sdl1.3 but only for backward compatibility + TSDL_ActiveEvent = record + type_: byte; + gain: byte; + state: byte; + end; - TSDL_ResizeEvent = record - type_: Byte; - w, h: LongInt; - end; + TSDL_ResizeEvent = record + type_: Byte; + w, h: LongInt; + end; {$ENDIF} - TSDL_MouseMotionEvent = record - type_: byte; - which: byte; - state: byte; + TSDL_MouseMotionEvent = record + type_: byte; + which: byte; + state: byte; {$IFDEF SDL13} - windowID: LongInt; - x, y, xrel, yrel : LongInt; - pressure, pressure_max, pressure_min, - rotation, tilt, cursor: LongInt; + windowID: LongInt; + x, y, xrel, yrel : LongInt; + pressure, pressure_max, pressure_min, + rotation, tilt, cursor: LongInt; {$ELSE} - x, y, xrel, yrel : word; + x, y, xrel, yrel : word; {$ENDIF} - end; + end; - TSDL_KeyboardEvent = record - type_: Byte; + TSDL_KeyboardEvent = record + type_: Byte; {$IFDEF SDL13} - windowID: LongInt; + windowID: LongInt; {$ENDIF} - which: Byte; - state: Byte; - keysym: TSDL_KeySym; - end; + which: Byte; + state: Byte; + keysym: TSDL_KeySym; + end; - TSDL_MouseButtonEvent = record - _type, - which, - button, - state: byte; + TSDL_MouseButtonEvent = record + _type, + which, + button, + state: byte; {$IFDEF SDL13} - windowID: LongInt; - x, y: LongInt; + windowID: LongInt; + x, y: LongInt; {$ELSE} - x, y: word; + x, y: word; {$ENDIF} - end; + end; {$IFDEF SDL13} - TSDL_MouseWheelEvent = record - type_: Byte; - windowID: LongInt; - which: Byte; - x, y: LongInt; - end; + TSDL_MouseWheelEvent = record + type_: Byte; + windowID: LongInt; + which: Byte; + x, y: LongInt; + end; {$ENDIF} - TSDL_JoyAxisEvent = record - type_: Byte; - which: Byte; - axis: Byte; + TSDL_JoyAxisEvent = record + type_: Byte; + which: Byte; + axis: Byte; {$IFDEF SDL13} - value: LongInt; + value: LongInt; {$ELSE} - value: word; -{$ENDIF} - end; - - TSDL_JoyBallEvent = record - type_: Byte; - which: Byte; - ball: Byte; + value: word; +{$ENDIF} + end; + + TSDL_JoyBallEvent = record + type_: Byte; + which: Byte; + ball: Byte; {$IFDEF SDL13} - xrel, yrel: LongInt; + xrel, yrel: LongInt; {$ELSE} - xrel, yrel: word; + xrel, yrel: word; {$ENDIF} - end; + end; - TSDL_JoyHatEvent = record - type_: Byte; - which: Byte; - hat: Byte; - value: Byte; - end; - - TSDL_JoyButtonEvent = record - type_: Byte; - which: Byte; - button: Byte; - state: Byte; - end; + TSDL_JoyHatEvent = record + type_: Byte; + which: Byte; + hat: Byte; + value: Byte; + end; + + TSDL_JoyButtonEvent = record + type_: Byte; + which: Byte; + button: Byte; + state: Byte; + end; - TSDL_QuitEvent = record + TSDL_QuitEvent = record type_: Byte; end; - PSDL_Event = ^TSDL_Event; - TSDL_Event = record - case Byte of - SDL_NOEVENT: (type_: byte); + PSDL_Event = ^TSDL_Event; + TSDL_Event = record + case Byte of + SDL_NOEVENT: (type_: byte); {$IFDEF SDL13} - SDL_WINDOWEVENT: (active: TSDL_WindowEvent); - SDL_KEYDOWN, - SDL_KEYUP: (key: TSDL_KeyboardEvent); - SDL_TEXTEDITING, - SDL_TEXTINPUT: (txtin: byte); - SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent); - SDL_MOUSEBUTTONDOWN, - SDL_MOUSEBUTTONUP: (button: TSDL_MouseButtonEvent); - SDL_MOUSEWHEEL: (wheel: TSDL_MouseWheelEvent); - SDL_JOYAXISMOTION: (jaxis: TSDL_JoyAxisEvent); - SDL_JOYHATMOTION: (jhat: TSDL_JoyHatEvent); - SDL_JOYBALLMOTION: (jball: TSDL_JoyBallEvent); - SDL_JOYBUTTONDOWN, - SDL_JOYBUTTONUP: (jbutton: TSDL_JoyButtonEvent); - SDL_QUITEV: (quit: TSDL_QuitEvent); + SDL_WINDOWEVENT: (active: TSDL_WindowEvent); + SDL_KEYDOWN, + SDL_KEYUP: (key: TSDL_KeyboardEvent); + SDL_TEXTEDITING, + SDL_TEXTINPUT: (txtin: byte); + SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent); + SDL_MOUSEBUTTONDOWN, + SDL_MOUSEBUTTONUP: (button: TSDL_MouseButtonEvent); + SDL_MOUSEWHEEL: (wheel: TSDL_MouseWheelEvent); + SDL_JOYAXISMOTION: (jaxis: TSDL_JoyAxisEvent); + SDL_JOYHATMOTION: (jhat: TSDL_JoyHatEvent); + SDL_JOYBALLMOTION: (jball: TSDL_JoyBallEvent); + SDL_JOYBUTTONDOWN, + SDL_JOYBUTTONUP: (jbutton: TSDL_JoyButtonEvent); + SDL_QUITEV: (quit: TSDL_QuitEvent); {$ELSE} - SDL_ACTIVEEVENT: (active: TSDL_ActiveEvent); - SDL_KEYDOWN, - SDL_KEYUP: (key: TSDL_KeyboardEvent); - SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent); - SDL_MOUSEBUTTONDOWN, - SDL_MOUSEBUTTONUP: (button: TSDL_MouseButtonEvent); - SDL_JOYAXISMOTION: (jaxis: TSDL_JoyAxisEvent); - SDL_JOYHATMOTION: (jhat: TSDL_JoyHatEvent); - SDL_JOYBALLMOTION: (jball: TSDL_JoyBallEvent); - SDL_JOYBUTTONDOWN, - SDL_JOYBUTTONUP: (jbutton: TSDL_JoyButtonEvent); - SDL_QUITEV: (quit: TSDL_QuitEvent); - //SDL_SYSWMEVENT,SDL_EVENT_RESERVEDA,SDL_EVENT_RESERVEDB - //SDL_VIDEORESIZE: (resize: TSDL_ResizeEvent); + SDL_ACTIVEEVENT: (active: TSDL_ActiveEvent); + SDL_KEYDOWN, + SDL_KEYUP: (key: TSDL_KeyboardEvent); + SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent); + SDL_MOUSEBUTTONDOWN, + SDL_MOUSEBUTTONUP: (button: TSDL_MouseButtonEvent); + SDL_JOYAXISMOTION: (jaxis: TSDL_JoyAxisEvent); + SDL_JOYHATMOTION: (jhat: TSDL_JoyHatEvent); + SDL_JOYBALLMOTION: (jball: TSDL_JoyBallEvent); + SDL_JOYBUTTONDOWN, + SDL_JOYBUTTONUP: (jbutton: TSDL_JoyButtonEvent); + SDL_QUITEV: (quit: TSDL_QuitEvent); + //SDL_SYSWMEVENT,SDL_EVENT_RESERVEDA,SDL_EVENT_RESERVEDB + //SDL_VIDEORESIZE: (resize: TSDL_ResizeEvent); {$ENDIF} - end; + end; - PByteArray = ^TByteArray; - TByteArray = array[0..65535] of Byte; - PLongWordArray = ^TLongWordArray; - TLongWordArray = array[0..16383] of LongWord; + PByteArray = ^TByteArray; + TByteArray = array[0..65535] of Byte; + PLongWordArray = ^TLongWordArray; + TLongWordArray = array[0..16383] of LongWord; - PSDL_Thread = Pointer; - PSDL_mutex = Pointer; + PSDL_Thread = Pointer; + PSDL_mutex = Pointer; - TSDL_GLattr = ( - SDL_GL_RED_SIZE, - SDL_GL_GREEN_SIZE, - SDL_GL_BLUE_SIZE, - SDL_GL_ALPHA_SIZE, - SDL_GL_BUFFER_SIZE, - SDL_GL_DOUBLEBUFFER, - SDL_GL_DEPTH_SIZE, - SDL_GL_STENCIL_SIZE, - SDL_GL_ACCUM_RED_SIZE, - SDL_GL_ACCUM_GREEN_SIZE, - SDL_GL_ACCUM_BLUE_SIZE, - SDL_GL_ACCUM_ALPHA_SIZE, - SDL_GL_STEREO, - SDL_GL_MULTISAMPLEBUFFERS, - SDL_GL_MULTISAMPLESAMPLES, - SDL_GL_ACCELERATED_VISUAL, + TSDL_GLattr = ( + SDL_GL_RED_SIZE, + SDL_GL_GREEN_SIZE, + SDL_GL_BLUE_SIZE, + SDL_GL_ALPHA_SIZE, + SDL_GL_BUFFER_SIZE, + SDL_GL_DOUBLEBUFFER, + SDL_GL_DEPTH_SIZE, + SDL_GL_STENCIL_SIZE, + SDL_GL_ACCUM_RED_SIZE, + SDL_GL_ACCUM_GREEN_SIZE, + SDL_GL_ACCUM_BLUE_SIZE, + SDL_GL_ACCUM_ALPHA_SIZE, + SDL_GL_STEREO, + SDL_GL_MULTISAMPLEBUFFERS, + SDL_GL_MULTISAMPLESAMPLES, + SDL_GL_ACCELERATED_VISUAL, {$IFDEF SDL13} - SDL_GL_RETAINED_BACKING, - SDL_GL_CONTEXT_MAJOR_VERSION, - SDL_GL_CONTEXT_MINOR_VERSION + SDL_GL_RETAINED_BACKING, + SDL_GL_CONTEXT_MAJOR_VERSION, + SDL_GL_CONTEXT_MINOR_VERSION {$ELSE} - SDL_GL_SWAP_CONTROL + SDL_GL_SWAP_CONTROL {$ENDIF} - ); + ); {$IFDEF SDL13} - TSDL_ArrayByteOrder = ( // array component order, low byte -> high byte - SDL_ARRAYORDER_NONE, - SDL_ARRAYORDER_RGB, - SDL_ARRAYORDER_RGBA, - SDL_ARRAYORDER_ARGB, - SDL_ARRAYORDER_BGR, - SDL_ARRAYORDER_BGRA, - SDL_ARRAYORDER_ABGR - ); + TSDL_ArrayByteOrder = ( // array component order, low byte -> high byte + SDL_ARRAYORDER_NONE, + SDL_ARRAYORDER_RGB, + SDL_ARRAYORDER_RGBA, + SDL_ARRAYORDER_ARGB, + SDL_ARRAYORDER_BGR, + SDL_ARRAYORDER_BGRA, + SDL_ARRAYORDER_ABGR + ); {$ENDIF} // Joystick/Controller support - PSDL_Joystick = ^TSDL_Joystick; - TSDL_Joystick = record - end; + PSDL_Joystick = ^TSDL_Joystick; + TSDL_Joystick = record + end; - {* SDL_TTF *} - PTTF_Font = ^TTTF_font; - TTTF_Font = record - end; + {* SDL_TTF *} + PTTF_Font = ^TTTF_font; + TTTF_Font = record + end; - {* SDL_mixer *} - PMixChunk = ^TMixChunk; - TMixChunk = record - allocated: Longword; - abuf : PByte; - alen : Longword; - volume : PByte; - end; - TMusic = (MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG, MUS_MP3); - TMix_Fading = (MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN); + {* SDL_mixer *} + PMixChunk = ^TMixChunk; + TMixChunk = record + allocated: Longword; + abuf : PByte; + alen : Longword; + volume : PByte; + end; + TMusic = (MUS_CMD, MUS_WAV, MUS_MOD, MUS_MID, MUS_OGG, MUS_MP3); + TMix_Fading = (MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN); - TMidiSong = record + TMidiSong = record samples : LongInt; events : pointer; end; - TMusicUnion = record - case Byte of - 0: ( midi : TMidiSong ); - 1: ( ogg : pointer); - end; + TMusicUnion = record + case Byte of + 0: ( midi : TMidiSong ); + 1: ( ogg : pointer); + end; - PMixMusic = ^TMixMusic; - TMixMusic = record + PMixMusic = ^TMixMusic; + TMixMusic = record end; - {* SDL_net *} - TIPAddress = record + {* SDL_net *} + TIPAddress = record host: Longword; port: Word; end; - PTCPSocket = ^TTCPSocket; - TTCPSocket = record + PTCPSocket = ^TTCPSocket; + TTCPSocket = record ready: LongInt; channel: LongInt; remoteAddress: TIPaddress; localAddress: TIPaddress; sflag: LongInt; end; - PSDLNet_SocketSet = ^TSDLNet_SocketSet; - TSDLNet_SocketSet = record + PSDLNet_SocketSet = ^TSDLNet_SocketSet; + TSDLNet_SocketSet = record numsockets, maxsockets: LongInt; sockets: PTCPSocket; @@ -627,8 +627,8 @@ function SDL_SaveBMP_RW(surface: PSDL_Surface; dst: PSDL_RWops; freedst: LongInt): LongInt; cdecl; external SDLLibName; {$IFDEF SDL13} -function SDL_CreateWindow(title: PChar; x,y,w,h, flags: LongInt): PSDL_Window; cdecl; external SDLLibName; -function SDL_CreateRenderer(window: PSDL_Window; index, flags: LongInt): LongInt; cdecl; external SDLLibName; +function SDL_CreateWindow(title: PChar; x,y,w,h, flags: LongInt): PSDL_Window; cdecl; external SDLLibName; +function SDL_CreateRenderer(window: PSDL_Window; index, flags: LongInt): LongInt; cdecl; external SDLLibName; function SDL_SetRenderDrawColor(r,g,b,a: byte): LongInt; cdecl; external SDLLibName; function SDL_RenderFill(rect: PSDL_Rect): LongInt; @@ -758,32 +758,32 @@ function SDL_MustLock(Surface: PSDL_Surface): Boolean; begin - SDL_MustLock:= ( surface^.offset <> 0 ) or (( surface^.flags and (SDL_HWSURFACE or SDL_ASYNCBLIT or SDL_RLEACCEL)) <> 0) + SDL_MustLock:= ( surface^.offset <> 0 ) or (( surface^.flags and (SDL_HWSURFACE or SDL_ASYNCBLIT or SDL_RLEACCEL)) <> 0) end; procedure SDLNet_Write16(value: Word; buf: pointer); begin - PByteArray(buf)^[1]:= value; - PByteArray(buf)^[0]:= value shr 8 + PByteArray(buf)^[1]:= value; + PByteArray(buf)^[0]:= value shr 8 end; procedure SDLNet_Write32(value: LongWord; buf: pointer); begin - PByteArray(buf)^[3]:= value; - PByteArray(buf)^[2]:= value shr 8; - PByteArray(buf)^[1]:= value shr 16; - PByteArray(buf)^[0]:= value shr 24 + PByteArray(buf)^[3]:= value; + PByteArray(buf)^[2]:= value shr 8; + PByteArray(buf)^[1]:= value shr 16; + PByteArray(buf)^[0]:= value shr 24 end; function SDLNet_Read16(buf: pointer): Word; begin - SDLNet_Read16:= PByteArray(buf)^[1] or + SDLNet_Read16:= PByteArray(buf)^[1] or (PByteArray(buf)^[0] shl 8) end; function SDLNet_Read32(buf: pointer): LongWord; begin - SDLNet_Read32:= PByteArray(buf)^[3] or + SDLNet_Read32:= PByteArray(buf)^[3] or (PByteArray(buf)^[2] shl 8) or (PByteArray(buf)^[1] shl 16) or (PByteArray(buf)^[0] shl 24) @@ -793,9 +793,9 @@ function SDL_RenderFill(rect: PSDL_Rect): LongInt; var res: LongInt; begin - if (rect <> nil) then res:= SDL_RenderFillRect(rect) - else res:= SDL_RenderClear(); - exit(res); + if (rect <> nil) then res:= SDL_RenderFillRect(rect) + else res:= SDL_RenderClear(); + exit(res); end; {$ENDIF} diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/hwengine.pas --- a/hedgewars/hwengine.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/hwengine.pas Sat Mar 06 10:59:20 2010 +0000 @@ -28,7 +28,7 @@ {$ELSE} program hwengine; {$ENDIF} -uses SDLh in 'SDLh.pas', +uses SDLh in 'SDLh.pas', uConsts in 'uConsts.pas', uGame in 'uGame.pas', uMisc in 'uMisc.pas', @@ -229,7 +229,7 @@ {$ELSE} procedure Game;cdecl; export; {$ENDIF} -var p: TPathType; +var p: TPathType; s: shortstring; begin {$IFDEF HWLIBRARY} @@ -321,7 +321,7 @@ begin init_uConsts(); init_uMisc(); - init_uConsole(); // MUST happen after uMisc + init_uConsole(); // MUST happen after uMisc init_uAI(); //uAIActions does not need initialization @@ -341,7 +341,7 @@ //uLandTemplates does not need initialization //uLandTexture does not need initialization //uLocale does not need initialization - init_uRandom(); + init_uRandom(); //uSHA does not need initialization init_uSound(); init_uStats(); @@ -356,21 +356,21 @@ procedure freeEverything; begin free_uWorld(); - free_uVisualGears(); //stub - free_uTriggers(); //stub + free_uVisualGears(); //stub + free_uTriggers(); //stub free_uTeams(); free_uStore(); - free_uStats(); //stub - free_uSound(); //stub + free_uStats(); //stub + free_uSound(); //stub //uSHA does not need to be freed - free_uRandom(); //stub + free_uRandom(); //stub //uLocale does not need to be freed //uLandTemplates does not need to be freed //uLandTexture does not need to be freed //uLandObjects does not need to be freed //uLandGraphics does not need to be freed free_uLand(); - free_uKeys(); //stub + free_uKeys(); //stub free_uIO(); free_uGears(); //uGame does not need to be freed @@ -378,14 +378,14 @@ free_uCollisions(); free_uChat(); free_uAmmos(); - free_uAIMisc(); //stub + free_uAIMisc(); //stub //uAIAmmoTests does not need to be freed //uAIActions does not need to be freed - free_uAI(); //stub + free_uAI(); //stub free_uConsole(); free_uMisc(); - free_uConsts(); //stub + free_uConsts(); //stub free_uScript(); end; @@ -485,7 +485,7 @@ PathPrefix:= ParamStr(1); recordFileName:= ParamStr(2); - if ParamStr(3) = '--set-video' then + if ParamStr(3) = '--set-video' then begin val(ParamStr(4), cScreenWidth); val(ParamStr(5), cScreenHeight); diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/uAI.pas --- a/hedgewars/uAI.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/uAI.pas Sat Mar 06 10:59:20 2010 +0000 @@ -347,7 +347,7 @@ procedure init_uAI; begin - hasThread:= 0; + hasThread:= 0; end; procedure free_uAI; diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/uAIAmmoTests.pas --- a/hedgewars/uAIAmmoTests.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/uAIAmmoTests.pas Sat Mar 06 10:59:20 2010 +0000 @@ -24,11 +24,11 @@ const amtest_OnTurn = $00000001; type TAttackParams = record - Time: Longword; - Angle, Power: LongInt; - ExplX, ExplY, ExplR: LongInt; - AttackPutX, AttackPutY: LongInt; - end; + Time: Longword; + Angle, Power: LongInt; + ExplX, ExplY, ExplR: LongInt; + AttackPutX, AttackPutY: LongInt; + end; function TestBazooka(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; function TestGrenade(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; @@ -40,55 +40,55 @@ function TestAirAttack(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; type TAmmoTestProc = function (Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; - TAmmoTest = record - proc: TAmmoTestProc; - flags: Longword; - end; + TAmmoTest = record + proc: TAmmoTestProc; + flags: Longword; + end; const AmmoTests: array[TAmmoType] of TAmmoTest = - ( - (proc: nil; flags: 0), // amNothing - (proc: @TestGrenade; flags: 0), // amGrenade - (proc: nil; flags: 0), // amClusterBomb - (proc: @TestBazooka; flags: 0), // amBazooka - (proc: nil; flags: 0), // amUFO - (proc: @TestShotgun; flags: 0), // amShotgun - (proc: nil; flags: 0), // amPickHammer - (proc: nil; flags: 0), // amSkip - (proc: nil; flags: 0), // amRope - (proc: nil; flags: 0), // amMine - (proc: @TestDesertEagle; flags: 0), // amDEagle - (proc: nil; flags: 0), // amDynamite - (proc: @TestFirePunch; flags: 0), // amFirePunch - (proc: nil; flags: 0), // amWhip - (proc: @TestBaseballBat; flags: 0), // amBaseballBat - (proc: nil; flags: 0), // amParachute - (proc: @TestAirAttack; flags: amtest_OnTurn), // amAirAttack - (proc: nil; flags: 0), // amMineStrike - (proc: nil; flags: 0), // amBlowTorch - (proc: nil; flags: 0), // amGirder - (proc: nil; flags: amtest_OnTurn), // amTeleport - (proc: nil; flags: 0), // amSwitch - (proc: @TestMortar; flags: 0), // amMortar - (proc: nil; flags: 0), // amKamikaze - (proc: nil; flags: 0), // amCake - (proc: nil; flags: 0), // amSeduction - (proc: nil; flags: 0), // amBanana - (proc: nil; flags: 0), // amHellishBomb - (proc: nil; flags: 0), // amNapalm - (proc: nil; flags: 0), // amDrill - (proc: nil; flags: 0), // amBallgun - (proc: nil; flags: 0), // amRCPlane - (proc: nil; flags: 0), // amLowGravity - (proc: nil; flags: 0), // amExtraDamage - (proc: nil; flags: 0), // amInvulnerable - (proc: nil; flags: 0), // amExtraTime - (proc: nil; flags: 0), // amLaserSight - (proc: nil; flags: 0), // amVampiric - (proc: nil; flags: 0), // amSniperRifle - (proc: nil; flags: 0), // amJetpack - (proc: nil; flags: 0) // amMolotov - ); + ( + (proc: nil; flags: 0), // amNothing + (proc: @TestGrenade; flags: 0), // amGrenade + (proc: nil; flags: 0), // amClusterBomb + (proc: @TestBazooka; flags: 0), // amBazooka + (proc: nil; flags: 0), // amUFO + (proc: @TestShotgun; flags: 0), // amShotgun + (proc: nil; flags: 0), // amPickHammer + (proc: nil; flags: 0), // amSkip + (proc: nil; flags: 0), // amRope + (proc: nil; flags: 0), // amMine + (proc: @TestDesertEagle; flags: 0), // amDEagle + (proc: nil; flags: 0), // amDynamite + (proc: @TestFirePunch; flags: 0), // amFirePunch + (proc: nil; flags: 0), // amWhip + (proc: @TestBaseballBat; flags: 0), // amBaseballBat + (proc: nil; flags: 0), // amParachute + (proc: @TestAirAttack; flags: amtest_OnTurn), // amAirAttack + (proc: nil; flags: 0), // amMineStrike + (proc: nil; flags: 0), // amBlowTorch + (proc: nil; flags: 0), // amGirder + (proc: nil; flags: amtest_OnTurn), // amTeleport + (proc: nil; flags: 0), // amSwitch + (proc: @TestMortar; flags: 0), // amMortar + (proc: nil; flags: 0), // amKamikaze + (proc: nil; flags: 0), // amCake + (proc: nil; flags: 0), // amSeduction + (proc: nil; flags: 0), // amBanana + (proc: nil; flags: 0), // amHellishBomb + (proc: nil; flags: 0), // amNapalm + (proc: nil; flags: 0), // amDrill + (proc: nil; flags: 0), // amBallgun + (proc: nil; flags: 0), // amRCPlane + (proc: nil; flags: 0), // amLowGravity + (proc: nil; flags: 0), // amExtraDamage + (proc: nil; flags: 0), // amInvulnerable + (proc: nil; flags: 0), // amExtraTime + (proc: nil; flags: 0), // amLaserSight + (proc: nil; flags: 0), // amVampiric + (proc: nil; flags: 0), // amSniperRifle + (proc: nil; flags: 0), // amJetpack + (proc: nil; flags: 0) // amMolotov + ); const BadTurn = Low(LongInt) div 4; @@ -216,56 +216,56 @@ Score, EX, EY, valueResult: LongInt; TestTime: Longword; - function CheckTrace: LongInt; - var x, y, dY: hwFloat; - value: LongInt; - begin - x:= Me^.X; - y:= Me^.Y; - dY:= -Vy; + function CheckTrace: LongInt; + var x, y, dY: hwFloat; + value: LongInt; + begin + x:= Me^.X; + y:= Me^.Y; + dY:= -Vy; - repeat - x:= x + Vx; - y:= y + dY; - dY:= dY + cGravity; - EX:= hwRound(x); - EY:= hwRound(y); - until TestCollExcludingMe(Me, EX, EY, 5) or (EY > 1000); + repeat + x:= x + Vx; + y:= y + dY; + dY:= dY + cGravity; + EX:= hwRound(x); + EY:= hwRound(y); + until TestCollExcludingMe(Me, EX, EY, 5) or (EY > 1000); - if (EY < 1000) and not dY.isNegative then - begin - value:= RateExplosion(Me, EX, EY, 91); - if (value = 0) then - if (dY > _0_15) then - value:= - abs(Targ.Y - EY) div 32 - else - value:= BadTurn - else if (value < 0) then value:= BadTurn - end - else - value:= BadTurn; + if (EY < 1000) and not dY.isNegative then + begin + value:= RateExplosion(Me, EX, EY, 91); + if (value = 0) then + if (dY > _0_15) then + value:= - abs(Targ.Y - EY) div 32 + else + value:= BadTurn + else if (value < 0) then value:= BadTurn + end + else + value:= BadTurn; - CheckTrace:= value; - end; + CheckTrace:= value; + end; - function Solve: LongWord; - var A, B, D, T: hwFloat; - C: LongInt; - begin - A:= hwSqr(cGravity) * _0_25; - B:= - cGravity * (Targ.Y - hwRound(Me^.Y)) - _1; - C:= sqr(Targ.Y - hwRound(Me^.Y)) + sqr(Targ.X - hwRound(Me^.X)); - D:= hwSqr(B) - (A * C * 4); - if D.isNegative = false then - begin - D:= ( - B + hwSqrt(D)) * _0_5 / A; - if D.isNegative = false then - T:= hwSqrt(D) - else - T:= _0; - Solve:= hwRound(T) - end else Solve:= 0 - end; + function Solve: LongWord; + var A, B, D, T: hwFloat; + C: LongInt; + begin + A:= hwSqr(cGravity) * _0_25; + B:= - cGravity * (Targ.Y - hwRound(Me^.Y)) - _1; + C:= sqr(Targ.Y - hwRound(Me^.Y)) + sqr(Targ.X - hwRound(Me^.X)); + D:= hwSqr(B) - (A * C * 4); + if D.isNegative = false then + begin + D:= ( - B + hwSqrt(D)) * _0_5 / A; + if D.isNegative = false then + T:= hwSqrt(D) + else + T:= _0; + Solve:= hwRound(T) + end else Solve:= 0 + end; begin valueResult:= BadTurn; @@ -277,19 +277,19 @@ if TestTime = 0 then exit(BadTurn); - Vx:= (int2hwFloat(Targ.X) - Me^.X) / int2hwFloat(TestTime); - Vy:= cGravity * (TestTime div 2) - (int2hwFloat(Targ.Y) - Me^.Y) / int2hwFloat(TestTime); + Vx:= (int2hwFloat(Targ.X) - Me^.X) / int2hwFloat(TestTime); + Vy:= cGravity * (TestTime div 2) - (int2hwFloat(Targ.Y) - Me^.Y) / int2hwFloat(TestTime); - Score:= CheckTrace; - if valueResult < Score then - begin - ap.Angle:= DxDy2AttackAngle(Vx, Vy) + AIrndSign(random(Level)); - ap.Power:= 1; - ap.ExplR:= 100; - ap.ExplX:= EX; - ap.ExplY:= EY; - valueResult:= Score - end; + Score:= CheckTrace; + if valueResult < Score then + begin + ap.Angle:= DxDy2AttackAngle(Vx, Vy) + AIrndSign(random(Level)); + ap.Power:= 1; + ap.ExplR:= 100; + ap.ExplX:= EX; + ap.ExplY:= EY; + valueResult:= Score + end; TestMortar:= valueResult; end; @@ -385,23 +385,23 @@ ap.Angle:= 0; if (Abs(hwRound(Me^.X) - Targ.X) > 25) or (Abs(hwRound(Me^.Y) - 50 - Targ.Y) > 50) then - begin - if TestColl(hwRound(Me^.Y), hwRound(Me^.Y) - 16, 6) - and (RateShove(Me, hwRound(Me^.X) + 10 * hwSign(Me^.dX), hwRound(Me^.Y) - 40, 30, 30) = 0) then - valueResult:= Succ(BadTurn) - else - valueResult:= BadTurn; - exit(valueResult) - end; + begin + if TestColl(hwRound(Me^.Y), hwRound(Me^.Y) - 16, 6) + and (RateShove(Me, hwRound(Me^.X) + 10 * hwSign(Me^.dX), hwRound(Me^.Y) - 40, 30, 30) = 0) then + valueResult:= Succ(BadTurn) + else + valueResult:= BadTurn; + exit(valueResult) + end; valueResult:= 0; for i:= 0 to 4 do - valueResult:= valueResult + RateShove(Me, hwRound(Me^.X) + 10 * hwSign(int2hwFloat(Targ.X) - Me^.X), + valueResult:= valueResult + RateShove(Me, hwRound(Me^.X) + 10 * hwSign(int2hwFloat(Targ.X) - Me^.X), hwRound(Me^.Y) - 20 * i - 5, 10, 30); if valueResult <= 0 then - valueResult:= BadTurn + valueResult:= BadTurn else - inc(valueResult); + inc(valueResult); TestFirePunch:= valueResult; end; diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/uAIMisc.pas --- a/hedgewars/uAIMisc.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/uAIMisc.pas Sat Mar 06 10:59:20 2010 +0000 @@ -85,30 +85,30 @@ f:= 0; e:= 0; for t:= 0 to Pred(TeamsCount) do - with TeamsArray[t]^ do - if not hasGone then - begin - for i:= 0 to cMaxHHIndex do - if (Hedgehogs[i].Gear <> nil) - and (Hedgehogs[i].Gear <> ThinkingHH) then - begin - with Targets.ar[Targets.Count], Hedgehogs[i] do - begin - Point.X:= hwRound(Gear^.X); - Point.Y:= hwRound(Gear^.Y); - if Clan <> CurrentTeam^.Clan then - begin - Score:= Gear^.Health; - inc(e) - end else - begin - Score:= -Gear^.Health; - inc(f) - end - end; - inc(Targets.Count) - end; - end; + with TeamsArray[t]^ do + if not hasGone then + begin + for i:= 0 to cMaxHHIndex do + if (Hedgehogs[i].Gear <> nil) + and (Hedgehogs[i].Gear <> ThinkingHH) then + begin + with Targets.ar[Targets.Count], Hedgehogs[i] do + begin + Point.X:= hwRound(Gear^.X); + Point.Y:= hwRound(Gear^.Y); + if Clan <> CurrentTeam^.Clan then + begin + Score:= Gear^.Health; + inc(e) + end else + begin + Score:= -Gear^.Health; + inc(f) + end + end; + inc(Targets.Count) + end; + end; if e > f then friendlyfactor:= 300 + (e - f) * 30 else friendlyfactor:= max(30, 300 - f * 80 div e) @@ -133,27 +133,27 @@ MyClan:= PHedgehog(ThinkingHH^.Hedgehog)^.Team^.Clan; Gear:= GearsList; while Gear <> nil do - begin - case Gear^.Kind of - gtCase: AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 33, 25); - gtMine: if (Gear^.State and gstAttacking) = 0 then - AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 50, -50) - else - AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 100, -50); // mine is on - gtDynamite: AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 150, -75); - gtHedgehog: begin - if Gear^.Damage >= Gear^.Health then - AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 60, -25) - else - if isAfterAttack and (ThinkingHH^.Hedgehog <> Gear^.Hedgehog) then - if (MyClan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan) then - AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 150, -3) // hedgehog-friend - else - AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 100, 3) - end; - end; - Gear:= Gear^.NextGear - end; + begin + case Gear^.Kind of + gtCase: AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 33, 25); + gtMine: if (Gear^.State and gstAttacking) = 0 then + AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 50, -50) + else + AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 100, -50); // mine is on + gtDynamite: AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 150, -75); + gtHedgehog: begin + if Gear^.Damage >= Gear^.Health then + AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 60, -25) + else + if isAfterAttack and (ThinkingHH^.Hedgehog <> Gear^.Hedgehog) then + if (MyClan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan) then + AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 150, -3) // hedgehog-friend + else + AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 100, 3) + end; + end; + Gear:= Gear^.NextGear + end; if isAfterAttack and (KnownExplosion.Radius > 0) then with KnownExplosion do AddBonus(X, Y, Radius + 10, -Radius); @@ -172,13 +172,13 @@ begin rate:= 0; for i:= 0 to Pred(bonuses.Count) do - with bonuses.ar[i] do - begin - r:= hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y))); - if r < Radius then - inc(rate, Score * (Radius - r)) - end; - RatePlace:= rate; + with bonuses.ar[i] do + begin + r:= hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y))); + if r < Radius then + inc(rate, Score * (Radius - r)) + end; + RatePlace:= rate; end; // Wrapper to test various approaches. If it works reasonably, will just replace. @@ -467,10 +467,10 @@ procedure init_uAIMisc; begin - friendlyfactor:= 300; - KnownExplosion.X:= 0; - KnownExplosion.Y:= 0; - KnownExplosion.Radius:= 0; + friendlyfactor:= 300; + KnownExplosion.X:= 0; + KnownExplosion.Y:= 0; + KnownExplosion.Radius:= 0; end; procedure free_uAIMisc; diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/uAmmos.pas --- a/hedgewars/uAmmos.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/uAmmos.pas Sat Mar 06 10:59:20 2010 +0000 @@ -108,7 +108,7 @@ Ammoz[a].Probability:= probability[byte(s[ord(a) + ord(High(TAmmoType))]) - byte('0')]; Ammoz[a].SkipTurns:= (byte(s[ord(a) + ord(High(TAmmoType)) + ord(High(TAmmoType))]) - byte('0')); Ammoz[a].NumberInCase:= (byte(s[ord(a) + ord(High(TAmmoType)) + ord(High(TAmmoType)) + ord(High(TAmmoType))]) - byte('0')); - if (TrainingFlags and tfIgnoreDelays) <> 0 then Ammoz[a].SkipTurns:= 0; + if (TrainingFlags and tfIgnoreDelays) <> 0 then Ammoz[a].SkipTurns:= 0; cnt:= byte(s[ord(a)]) - byte('0'); // avoid things we already have infinite number if cnt = 9 then @@ -206,19 +206,19 @@ procedure OnUsedAmmo(var Hedgehog: THedgehog); begin with Hedgehog do - begin - MultiShootAttacks:= 0; - with Ammo^[CurSlot, CurAmmo] do - if Count <> AMMO_INFINITE then - begin - dec(Count); - if Count = 0 then - begin - PackAmmo(Ammo, CurSlot); - SwitchNotHeldAmmo(Hedgehog) - end - end - end + begin + MultiShootAttacks:= 0; + with Ammo^[CurSlot, CurAmmo] do + if Count <> AMMO_INFINITE then + begin + dec(Count); + if Count = 0 then + begin + PackAmmo(Ammo, CurSlot); + SwitchNotHeldAmmo(Hedgehog) + end + end + end end; function HHHasAmmo(var Hedgehog: THedgehog; Ammo: TAmmoType): boolean; @@ -239,45 +239,45 @@ procedure ApplyAngleBounds(var Hedgehog: THedgehog; AmmoType: TAmmoType); begin with Hedgehog do - begin - CurMinAngle:= Ammoz[AmmoType].minAngle; - if Ammoz[AmmoType].maxAngle <> 0 then - CurMaxAngle:= Ammoz[AmmoType].maxAngle - else - CurMaxAngle:= cMaxAngle; + begin + CurMinAngle:= Ammoz[AmmoType].minAngle; + if Ammoz[AmmoType].maxAngle <> 0 then + CurMaxAngle:= Ammoz[AmmoType].maxAngle + else + CurMaxAngle:= cMaxAngle; - with Hedgehog.Gear^ do - begin - if Angle < CurMinAngle then Angle:= CurMinAngle; - if Angle > CurMaxAngle then Angle:= CurMaxAngle; - end - end + with Hedgehog.Gear^ do + begin + if Angle < CurMinAngle then Angle:= CurMinAngle; + if Angle > CurMaxAngle then Angle:= CurMaxAngle; + end + end end; procedure SwitchToFirstLegalAmmo(var Hedgehog: THedgehog); begin with Hedgehog do - begin - CurAmmo:= 0; - CurSlot:= 0; - while (CurSlot <= cMaxSlotIndex) and - ((Ammo^[CurSlot, CurAmmo].Count = 0) or - (Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0)) - do - begin - while (CurAmmo <= cMaxSlotAmmoIndex) and - ((Ammo^[CurSlot, CurAmmo].Count = 0) or - (Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0)) - do inc(CurAmmo); + begin + CurAmmo:= 0; + CurSlot:= 0; + while (CurSlot <= cMaxSlotIndex) and + ((Ammo^[CurSlot, CurAmmo].Count = 0) or + (Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0)) + do + begin + while (CurAmmo <= cMaxSlotAmmoIndex) and + ((Ammo^[CurSlot, CurAmmo].Count = 0) or + (Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0)) + do inc(CurAmmo); - if (CurAmmo > cMaxSlotAmmoIndex) then - begin - CurAmmo:= 0; - inc(CurSlot) - end - end; - TryDo(CurSlot <= cMaxSlotIndex, 'Ammo slot index overflow', true) - end + if (CurAmmo > cMaxSlotAmmoIndex) then + begin + CurAmmo:= 0; + inc(CurSlot) + end + end; + TryDo(CurSlot <= cMaxSlotIndex, 'Ammo slot index overflow', true) + end end; procedure ApplyAmmoChanges(var Hedgehog: THedgehog); @@ -286,44 +286,44 @@ TargetPoint.X:= NoPointX; with Hedgehog do - begin + begin - if (Ammo^[CurSlot, CurAmmo].Count = 0) then - SwitchToFirstLegalAmmo(Hedgehog); + if (Ammo^[CurSlot, CurAmmo].Count = 0) then + SwitchToFirstLegalAmmo(Hedgehog); //bad things could happen here in case CurSlot is overflowing - ApplyAngleBounds(Hedgehog, Ammo^[CurSlot, CurAmmo].AmmoType); + ApplyAngleBounds(Hedgehog, Ammo^[CurSlot, CurAmmo].AmmoType); - with Ammo^[CurSlot, CurAmmo] do - begin + with Ammo^[CurSlot, CurAmmo] do + begin if AmmoType <> amNothing then begin - s:= trammo[Ammoz[AmmoType].NameId]; - if (Count <> AMMO_INFINITE) and not (Hedgehog.Team^.ExtDriven or (Hedgehog.BotLevel > 0)) then - s:= s + ' (' + IntToStr(Count) + ')'; - if (Propz and ammoprop_Timerable) <> 0 then - s:= s + ', ' + inttostr(Timer div 1000) + ' ' + trammo[sidSeconds]; - AddCaption(s, Team^.Clan^.Color, capgrpAmmoinfo); + s:= trammo[Ammoz[AmmoType].NameId]; + if (Count <> AMMO_INFINITE) and not (Hedgehog.Team^.ExtDriven or (Hedgehog.BotLevel > 0)) then + s:= s + ' (' + IntToStr(Count) + ')'; + if (Propz and ammoprop_Timerable) <> 0 then + s:= s + ', ' + inttostr(Timer div 1000) + ' ' + trammo[sidSeconds]; + AddCaption(s, Team^.Clan^.Color, capgrpAmmoinfo); end; - if (Propz and ammoprop_NeedTarget) <> 0 - then begin - Gear^.State:= Gear^.State or gstHHChooseTarget; - isCursorVisible:= true - end else begin - Gear^.State:= Gear^.State and not gstHHChooseTarget; - isCursorVisible:= false - end; - ShowCrosshair:= (Propz and ammoprop_NoCrosshair) = 0 - end - end + if (Propz and ammoprop_NeedTarget) <> 0 + then begin + Gear^.State:= Gear^.State or gstHHChooseTarget; + isCursorVisible:= true + end else begin + Gear^.State:= Gear^.State and not gstHHChooseTarget; + isCursorVisible:= false + end; + ShowCrosshair:= (Propz and ammoprop_NoCrosshair) = 0 + end + end end; procedure SwitchNotHeldAmmo(var Hedgehog: THedgehog); begin with Hedgehog do - if ((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_DontHold) <> 0) or - (Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0) then - SwitchToFirstLegalAmmo(Hedgehog); + if ((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_DontHold) <> 0) or + (Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber >= 0) then + SwitchToFirstLegalAmmo(Hedgehog); end; procedure SetWeapon(weap: TAmmoType); @@ -333,52 +333,52 @@ procedure DisableSomeWeapons; var i, slot, a: Longword; - t: TAmmoType; + t: TAmmoType; begin for i:= 0 to Pred(StoreCnt) do - for slot:= 0 to cMaxSlotIndex do - begin - for a:= 0 to cMaxSlotAmmoIndex do - with StoresList[i]^[slot, a] do - if (Propz and ammoprop_NotBorder) <> 0 then Count:= 0; + for slot:= 0 to cMaxSlotIndex do + begin + for a:= 0 to cMaxSlotAmmoIndex do + with StoresList[i]^[slot, a] do + if (Propz and ammoprop_NotBorder) <> 0 then Count:= 0; - PackAmmo(StoresList[i], slot) - end; + PackAmmo(StoresList[i], slot) + end; for t:= Low(TAmmoType) to High(TAmmoType) do - if (Ammoz[t].Ammo.Propz and ammoprop_NotBorder) <> 0 then Ammoz[t].Probability:= 0 + if (Ammoz[t].Ammo.Propz and ammoprop_NotBorder) <> 0 then Ammoz[t].Probability:= 0 end; // Restore indefinitely disabled weapons and initial weapon counts. Only used for hog placement right now procedure ResetWeapons; var i, slot, a: Longword; - t: TAmmoType; + t: TAmmoType; begin for i:= 0 to Pred(StoreCnt) do - for slot:= 0 to cMaxSlotIndex do - begin - for a:= 0 to cMaxSlotAmmoIndex do - with StoresList[i]^[slot, a] do + for slot:= 0 to cMaxSlotIndex do + begin + for a:= 0 to cMaxSlotAmmoIndex do + with StoresList[i]^[slot, a] do Count:= InitialCount; - PackAmmo(StoresList[i], slot) - end; + PackAmmo(StoresList[i], slot) + end; for t:= Low(TAmmoType) to High(TAmmoType) do - if Ammoz[t].SkipTurns >= 10000 then dec(Ammoz[t].SkipTurns,10000); + if Ammoz[t].SkipTurns >= 10000 then dec(Ammoz[t].SkipTurns,10000); end; procedure init_uAmmos; begin - shoppa:= false; - StoreCnt:= 0 + shoppa:= false; + StoreCnt:= 0 end; procedure free_uAmmos; var i: LongWord; begin - if StoreCnt > 0 then - for i:= 0 to Pred(StoreCnt) do Dispose(StoresList[i]); - StoreCnt:= 0 + if StoreCnt > 0 then + for i:= 0 to Pred(StoreCnt) do Dispose(StoresList[i]); + StoreCnt:= 0 end; end. diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/uChat.pas --- a/hedgewars/uChat.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/uChat.pas Sat Mar 06 10:59:20 2010 +0000 @@ -38,11 +38,11 @@ const MaxStrIndex = 27; type TChatLine = record - Tex: PTexture; - Time: Longword; - Width: LongInt; - s: shortstring; - end; + Tex: PTexture; + Time: Longword; + Width: LongInt; + s: shortstring; + end; var Strs: array[0 .. MaxStrIndex] of TChatLine; lastStr: LongWord; @@ -51,37 +51,37 @@ InputStrL: array[0..260] of char; // for full str + 4-byte utf-8 char const colors: array[#1..#4] of TSDL_Color = ( - (r:$FF; g:$FF; b:$FF; unused:$FF), // chat message [White] - (r:$FF; g:$00; b:$FF; unused:$FF), // action message [Purple] - (r:$90; g:$FF; b:$90; unused:$FF), // join/leave message [Lime] - (r:$FF; g:$FF; b:$A0; unused:$FF) // team message [Light Yellow] - ); + (r:$FF; g:$FF; b:$FF; unused:$FF), // chat message [White] + (r:$FF; g:$00; b:$FF; unused:$FF), // action message [Purple] + (r:$90; g:$FF; b:$90; unused:$FF), // join/leave message [Lime] + (r:$FF; g:$FF; b:$A0; unused:$FF) // team message [Light Yellow] + ); procedure SetLine(var cl: TChatLine; str: shortstring; isInput: boolean); var strSurface, resSurface: PSDL_Surface; - w, h: LongInt; - color: TSDL_Color; + w, h: LongInt; + color: TSDL_Color; font: THWFont; begin if cl.Tex <> nil then - FreeTexture(cl.Tex); + FreeTexture(cl.Tex); cl.s:= str; if isInput then begin - // [Light Blue] - color.r:= $00; - color.g:= $FF; - color.b:= $FF; - color.unused:= $FF; - str:= UserNick + '> ' + str + '_' + // [Light Blue] + color.r:= $00; + color.g:= $FF; + color.b:= $FF; + color.unused:= $FF; + str:= UserNick + '> ' + str + '_' end else begin - color:= colors[str[1]]; - delete(str, 1, 1) + color:= colors[str[1]]; + delete(str, 1, 1) end; font:= CheckCJKFont(str, fnt16); @@ -111,7 +111,7 @@ procedure DrawChat; var i, t, cnt: Longword; - r: TSDL_Rect; + r: TSDL_Rect; begin cnt:= 0; t:= 0; @@ -122,33 +122,33 @@ r.h:= 16; if (GameState = gsChat) - and (InputStr.Tex <> nil) then - begin - r.w:= InputStr.Width; - DrawFillRect(r); - DrawTexture(8 - cScreenWidth div 2, visibleCount * 16 + 10, InputStr.Tex); - end; + and (InputStr.Tex <> nil) then + begin + r.w:= InputStr.Width; + DrawFillRect(r); + DrawTexture(8 - cScreenWidth div 2, visibleCount * 16 + 10, InputStr.Tex); + end; dec(r.y, 16); while - ( - ((t < 7) and (Strs[i].Time > RealTicks)) - or - ((t < MaxStrIndex) and showAll) - ) - and - (Strs[i].Tex <> nil) do - begin - r.w:= Strs[i].Width; - DrawFillRect(r); - DrawTexture(8 - cScreenWidth div 2, (visibleCount - t) * 16 - 6, Strs[i].Tex); - dec(r.y, 16); + ( + ((t < 7) and (Strs[i].Time > RealTicks)) + or + ((t < MaxStrIndex) and showAll) + ) + and + (Strs[i].Tex <> nil) do + begin + r.w:= Strs[i].Width; + DrawFillRect(r); + DrawTexture(8 - cScreenWidth div 2, (visibleCount - t) * 16 - 6, Strs[i].Tex); + dec(r.y, 16); - if i = 0 then i:= MaxStrIndex else dec(i); - inc(cnt); - inc(t) - end; + if i = 0 then i:= MaxStrIndex else dec(i); + inc(cnt); + inc(t) + end; visibleCount:= cnt; end; @@ -216,23 +216,23 @@ exit end; if (s[1] = '/') and (copy(s, 1, 4) <> '/me ') then - begin - if CurrentTeam^.ExtDriven then exit; + begin + if CurrentTeam^.ExtDriven then exit; - for i:= Low(TWave) to High(TWave) do - if (s = Wavez[i].cmd) then - begin - ParseCommand('/taunt ' + char(i), true); - exit - end; - if (s = '/newgrave') then + for i:= Low(TWave) to High(TWave) do + if (s = Wavez[i].cmd) then + begin + ParseCommand('/taunt ' + char(i), true); + exit + end; + if (s = '/newgrave') then begin - ParseCommand('/newgrave', true); + ParseCommand('/newgrave', true); exit end; end - else - ParseCommand('/say ' + s, true); + else + ParseCommand('/say ' + s, true); end; procedure KeyPressChat(Key: Longword); @@ -242,46 +242,46 @@ begin if Key <> 0 then - case Key of - {Backspace} - 8, 127: if Length(InputStr.s) > 0 then - begin - InputStr.s[0]:= InputStrL[byte(InputStr.s[0])]; - SetLine(InputStr, InputStr.s, true) - end; - {Esc} - 27: SetLine(InputStr, '', true); - {Return} - 3, 13, 271: begin - if Length(InputStr.s) > 0 then - begin - AcceptChatString(InputStr.s); - SetLine(InputStr, '', false) - end; - FreezeEnterKey; - GameState:= gsGame - end; - else - if (Key < $80) then btw:= 1 - else if (Key < $800) then btw:= 2 - else if (Key < $10000) then btw:= 3 - else btw:= 4; + case Key of + {Backspace} + 8, 127: if Length(InputStr.s) > 0 then + begin + InputStr.s[0]:= InputStrL[byte(InputStr.s[0])]; + SetLine(InputStr, InputStr.s, true) + end; + {Esc} + 27: SetLine(InputStr, '', true); + {Return} + 3, 13, 271: begin + if Length(InputStr.s) > 0 then + begin + AcceptChatString(InputStr.s); + SetLine(InputStr, '', false) + end; + FreezeEnterKey; + GameState:= gsGame + end; + else + if (Key < $80) then btw:= 1 + else if (Key < $800) then btw:= 2 + else if (Key < $10000) then btw:= 3 + else btw:= 4; - utf8:= ''; + utf8:= ''; - for i:= btw downto 2 do - begin - utf8:= char((Key or $80) and $BF) + utf8; - Key:= Key shr 6 - end; + for i:= btw downto 2 do + begin + utf8:= char((Key or $80) and $BF) + utf8; + Key:= Key shr 6 + end; - utf8:= char(Key or firstByteMark[btw]) + utf8; + utf8:= char(Key or firstByteMark[btw]) + utf8; - if byte(InputStr.s[0]) + btw > 240 then exit; + if byte(InputStr.s[0]) + btw > 240 then exit; - InputStrL[byte(InputStr.s[0]) + btw]:= InputStr.s[0]; - SetLine(InputStr, InputStr.s + utf8, true) - end + InputStrL[byte(InputStr.s[0]) + btw]:= InputStr.s[0]; + SetLine(InputStr, InputStr.s + utf8, true) + end end; procedure init_uChat; diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/uCollisions.pas --- a/hedgewars/uCollisions.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/uCollisions.pas Sat Mar 06 10:59:20 2010 +0000 @@ -25,10 +25,10 @@ const cMaxGearArrayInd = 255; type PGearArray = ^TGearArray; - TGearArray = record - ar: array[0..cMaxGearArrayInd] of PGear; - Count: Longword - end; + TGearArray = record + ar: array[0..cMaxGearArrayInd] of PGear; + Count: Longword + end; procedure init_uCollisions; procedure free_uCollisions; @@ -53,9 +53,9 @@ uses uMisc, uConsts, uLand, uLandGraphics, uConsole; type TCollisionEntry = record - X, Y, Radius: LongInt; - cGear: PGear; - end; + X, Y, Radius: LongInt; + cGear: PGear; + end; const MAXRECTSINDEX = 511; var Count: Longword; @@ -67,13 +67,13 @@ if Gear^.CollisionIndex >= 0 then exit; TryDo(Count <= MAXRECTSINDEX, 'Collision rects array overflow', true); with cinfos[Count] do - begin - X:= hwRound(Gear^.X); - Y:= hwRound(Gear^.Y); - Radius:= Gear^.Radius; - ChangeRoundInLand(X, Y, Radius - 1, true); - cGear:= Gear - end; + begin + X:= hwRound(Gear^.X); + Y:= hwRound(Gear^.Y); + Radius:= Gear^.Radius; + ChangeRoundInLand(X, Y, Radius - 1, true); + cGear:= Gear + end; Gear^.CollisionIndex:= Count; inc(Count) end; @@ -81,19 +81,19 @@ procedure DeleteCI(Gear: PGear); begin if Gear^.CollisionIndex >= 0 then - begin - with cinfos[Gear^.CollisionIndex] do - ChangeRoundInLand(X, Y, Radius - 1, false); - cinfos[Gear^.CollisionIndex]:= cinfos[Pred(Count)]; - cinfos[Gear^.CollisionIndex].cGear^.CollisionIndex:= Gear^.CollisionIndex; - Gear^.CollisionIndex:= -1; - dec(Count) - end; + begin + with cinfos[Gear^.CollisionIndex] do + ChangeRoundInLand(X, Y, Radius - 1, false); + cinfos[Gear^.CollisionIndex]:= cinfos[Pred(Count)]; + cinfos[Gear^.CollisionIndex].cGear^.CollisionIndex:= Gear^.CollisionIndex; + Gear^.CollisionIndex:= -1; + dec(Count) + end; end; function CheckGearsCollision(Gear: PGear): PGearArray; var mx, my: LongInt; - i: Longword; + i: Longword; begin CheckGearsCollision:= @ga; ga.Count:= 0; @@ -102,18 +102,18 @@ my:= hwRound(Gear^.Y); for i:= 0 to Pred(Count) do - with cinfos[i] do - if (Gear <> cGear) and - (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius)) then - begin - ga.ar[ga.Count]:= cinfos[i].cGear; - inc(ga.Count) - end + with cinfos[i] do + if (Gear <> cGear) and + (sqr(mx - x) + sqr(my - y) <= sqr(Radius + Gear^.Radius)) then + begin + ga.ar[ga.Count]:= cinfos[i].cGear; + inc(ga.Count) + end end; function TestCollisionXwithGear(Gear: PGear; Dir: LongInt): boolean; var x, y, i: LongInt; - TestWord: LongWord; + TestWord: LongWord; begin if Gear^.IntersectGear <> nil then with Gear^ do @@ -314,7 +314,7 @@ procedure init_uCollisions; begin - Count:= 0; + Count:= 0; end; procedure free_uCollisions; diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/uConsole.pas --- a/hedgewars/uConsole.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/uConsole.pas Sat Mar 06 10:59:20 2010 +0000 @@ -102,33 +102,33 @@ var Len: LongInt; done: boolean; begin - {$IFDEF DEBUGFILE}AddFileLog('Console write: ' + s);{$ENDIF} - Write(s); - done:= false; - - while not done do - begin - Len:= cLineWidth - Length(ConsoleLines[CurrLine].s); - SetLine(ConsoleLines[CurrLine], ConsoleLines[CurrLine].s + copy(s, 1, Len)); - Delete(s, 1, Len); - if byte(ConsoleLines[CurrLine].s[0]) = cLineWidth then - begin - inc(CurrLine); - if CurrLine = cLinesCount then CurrLine:= 0; - PByte(@ConsoleLines[CurrLine].s)^:= 0 - end; - done:= (Length(s) = 0); - end; + {$IFDEF DEBUGFILE}AddFileLog('Console write: ' + s);{$ENDIF} + Write(s); + done:= false; + + while not done do + begin + Len:= cLineWidth - Length(ConsoleLines[CurrLine].s); + SetLine(ConsoleLines[CurrLine], ConsoleLines[CurrLine].s + copy(s, 1, Len)); + Delete(s, 1, Len); + if byte(ConsoleLines[CurrLine].s[0]) = cLineWidth then + begin + inc(CurrLine); + if CurrLine = cLinesCount then CurrLine:= 0; + PByte(@ConsoleLines[CurrLine].s)^:= 0 + end; + done:= (Length(s) = 0); + end; end; procedure WriteLnToConsole(s: shortstring); begin - WriteToConsole(s); - WriteLn; - inc(CurrLine); - if CurrLine = cLinesCount then - CurrLine:= 0; - PByte(@ConsoleLines[CurrLine].s)^:= 0 + WriteToConsole(s); + WriteLn; + inc(CurrLine); + if CurrLine = cLinesCount then + CurrLine:= 0; + PByte(@ConsoleLines[CurrLine].s)^:= 0 end; procedure ParseCommand(CmdStr: shortstring; TrustedSource: boolean); @@ -188,7 +188,7 @@ function GetLastConsoleLine: shortstring; var valueStr: shortstring; - i: LongWord; + i: LongWord; begin i:= (CurrLine + cLinesCount - 2) mod cLinesCount; valueStr:= ConsoleLines[i].s; @@ -214,105 +214,105 @@ procedure init_uConsole; var i: LongInt; begin - CurrLine:= 0; - Variables:= nil; - isDeveloperMode:= true; - - // initConsole - cLineWidth:= cScreenWidth div 10; - if cLineWidth > 255 then - cLineWidth:= 255; - for i:= 0 to Pred(cLinesCount) do - PByte(@ConsoleLines[i])^:= 0; - - RegisterVariable('proto' , vtCommand, @chCheckProto , true ); - RegisterVariable('spectate', vtBoolean, @fastUntilLag , false); - RegisterVariable('capture' , vtCommand, @chCapture , true ); - RegisterVariable('rotmask' , vtCommand, @chRotateMask , true ); - RegisterVariable('addteam' , vtCommand, @chAddTeam , false); - RegisterVariable('addtrig' , vtCommand, @chAddTrigger , false); - RegisterVariable('rdriven' , vtCommand, @chTeamLocal , false); - RegisterVariable('map' , vtCommand, @chSetMap , false); - RegisterVariable('theme' , vtCommand, @chSetTheme , false); - RegisterVariable('seed' , vtCommand, @chSetSeed , false); - RegisterVariable('template_filter', vtLongInt, @cTemplateFilter, false); - RegisterVariable('delay' , vtLongInt, @cInactDelay , false); - RegisterVariable('casefreq', vtLongInt, @cCaseFactor , false); - RegisterVariable('sd_turns', vtLongInt, @cSuddenDTurns , false); - RegisterVariable('damagepct',vtLongInt, @cDamagePercent , false); - RegisterVariable('minedudpct',vtLongInt,@cMineDudPercent, false); - RegisterVariable('landadds', vtLongInt, @cLandAdditions , false); - RegisterVariable('explosives',vtLongInt,@cExplosives , false); - RegisterVariable('gmflags' , vtLongInt, @GameFlags , false); - RegisterVariable('trflags' , vtLongInt, @TrainingFlags , false); - RegisterVariable('turntime', vtLongInt, @cHedgehogTurnTime, false); - RegisterVariable('minestime',vtLongInt, @cMinesTime , false); - RegisterVariable('fort' , vtCommand, @chFort , false); - RegisterVariable('voicepack',vtCommand, @chVoicepack , false); - RegisterVariable('grave' , vtCommand, @chGrave , false); - RegisterVariable('bind' , vtCommand, @chBind , true ); - RegisterVariable('addhh' , vtCommand, @chAddHH , false); - RegisterVariable('hat' , vtCommand, @chSetHat , false); - RegisterVariable('hhcoords', vtCommand, @chSetHHCoords , false); - RegisterVariable('ammstore', vtCommand, @chAddAmmoStore , false); - RegisterVariable('quit' , vtCommand, @chQuit , true ); - RegisterVariable('confirm' , vtCommand, @chConfirm , true ); - RegisterVariable('+speedup', vtCommand, @chSpeedup_p , true ); - RegisterVariable('-speedup', vtCommand, @chSpeedup_m , true ); - RegisterVariable('zoomin' , vtCommand, @chZoomIn , true ); - RegisterVariable('zoomout' , vtCommand, @chZoomOut , true ); - RegisterVariable('zoomreset',vtCommand, @chZoomReset , true ); - RegisterVariable('skip' , vtCommand, @chSkip , false); - RegisterVariable('history' , vtCommand, @chHistory , true ); - RegisterVariable('chat' , vtCommand, @chChat , true ); - RegisterVariable('newgrave', vtCommand, @chNewGrave , false); - RegisterVariable('say' , vtCommand, @chSay , true ); - RegisterVariable('hogsay' , vtCommand, @chHogSay , true ); - RegisterVariable('team' , vtCommand, @chTeamSay , true ); - RegisterVariable('ammomenu', vtCommand, @chAmmoMenu , true); - RegisterVariable('+precise', vtCommand, @chPrecise_p , false); - RegisterVariable('-precise', vtCommand, @chPrecise_m , false); - RegisterVariable('+left' , vtCommand, @chLeft_p , false); - RegisterVariable('-left' , vtCommand, @chLeft_m , false); - RegisterVariable('+right' , vtCommand, @chRight_p , false); - RegisterVariable('-right' , vtCommand, @chRight_m , false); - RegisterVariable('+up' , vtCommand, @chUp_p , false); - RegisterVariable('-up' , vtCommand, @chUp_m , false); - RegisterVariable('+down' , vtCommand, @chDown_p , false); - RegisterVariable('-down' , vtCommand, @chDown_m , false); - RegisterVariable('+attack' , vtCommand, @chAttack_p , false); - RegisterVariable('-attack' , vtCommand, @chAttack_m , false); - RegisterVariable('switch' , vtCommand, @chSwitch , false); - RegisterVariable('nextturn', vtCommand, @chNextTurn , false); - RegisterVariable('timer' , vtCommand, @chTimer , false); - RegisterVariable('taunt' , vtCommand, @chTaunt , false); - RegisterVariable('setweap' , vtCommand, @chSetWeapon , false); - RegisterVariable('slot' , vtCommand, @chSlot , false); - RegisterVariable('put' , vtCommand, @chPut , false); - RegisterVariable('ljump' , vtCommand, @chLJump , false); - RegisterVariable('hjump' , vtCommand, @chHJump , false); - RegisterVariable('fullscr' , vtCommand, @chFullScr , true ); - RegisterVariable('+volup' , vtCommand, @chVol_p , true ); - RegisterVariable('-volup' , vtCommand, @chVol_m , true ); - RegisterVariable('+voldown', vtCommand, @chVol_m , true ); - RegisterVariable('-voldown', vtCommand, @chVol_p , true ); - RegisterVariable('findhh' , vtCommand, @chFindhh , true ); - RegisterVariable('pause' , vtCommand, @chPause , true ); - RegisterVariable('+cur_u' , vtCommand, @chCurU_p , true ); - RegisterVariable('-cur_u' , vtCommand, @chCurU_m , true ); - RegisterVariable('+cur_d' , vtCommand, @chCurD_p , true ); - RegisterVariable('-cur_d' , vtCommand, @chCurD_m , true ); - RegisterVariable('+cur_l' , vtCommand, @chCurL_p , true ); - RegisterVariable('-cur_l' , vtCommand, @chCurL_m , true ); - RegisterVariable('+cur_r' , vtCommand, @chCurR_p , true ); - RegisterVariable('-cur_r' , vtCommand, @chCurR_m , true ); - RegisterVariable('flag' , vtCommand, @chFlag , false); - RegisterVariable('script' , vtCommand, @chScript , false); + CurrLine:= 0; + Variables:= nil; + isDeveloperMode:= true; + + // initConsole + cLineWidth:= cScreenWidth div 10; + if cLineWidth > 255 then + cLineWidth:= 255; + for i:= 0 to Pred(cLinesCount) do + PByte(@ConsoleLines[i])^:= 0; + + RegisterVariable('proto' , vtCommand, @chCheckProto , true ); + RegisterVariable('spectate', vtBoolean, @fastUntilLag , false); + RegisterVariable('capture' , vtCommand, @chCapture , true ); + RegisterVariable('rotmask' , vtCommand, @chRotateMask , true ); + RegisterVariable('addteam' , vtCommand, @chAddTeam , false); + RegisterVariable('addtrig' , vtCommand, @chAddTrigger , false); + RegisterVariable('rdriven' , vtCommand, @chTeamLocal , false); + RegisterVariable('map' , vtCommand, @chSetMap , false); + RegisterVariable('theme' , vtCommand, @chSetTheme , false); + RegisterVariable('seed' , vtCommand, @chSetSeed , false); + RegisterVariable('template_filter', vtLongInt, @cTemplateFilter, false); + RegisterVariable('delay' , vtLongInt, @cInactDelay , false); + RegisterVariable('casefreq', vtLongInt, @cCaseFactor , false); + RegisterVariable('sd_turns', vtLongInt, @cSuddenDTurns , false); + RegisterVariable('damagepct',vtLongInt, @cDamagePercent , false); + RegisterVariable('minedudpct',vtLongInt,@cMineDudPercent, false); + RegisterVariable('landadds', vtLongInt, @cLandAdditions , false); + RegisterVariable('explosives',vtLongInt,@cExplosives , false); + RegisterVariable('gmflags' , vtLongInt, @GameFlags , false); + RegisterVariable('trflags' , vtLongInt, @TrainingFlags , false); + RegisterVariable('turntime', vtLongInt, @cHedgehogTurnTime, false); + RegisterVariable('minestime',vtLongInt, @cMinesTime , false); + RegisterVariable('fort' , vtCommand, @chFort , false); + RegisterVariable('voicepack',vtCommand, @chVoicepack , false); + RegisterVariable('grave' , vtCommand, @chGrave , false); + RegisterVariable('bind' , vtCommand, @chBind , true ); + RegisterVariable('addhh' , vtCommand, @chAddHH , false); + RegisterVariable('hat' , vtCommand, @chSetHat , false); + RegisterVariable('hhcoords', vtCommand, @chSetHHCoords , false); + RegisterVariable('ammstore', vtCommand, @chAddAmmoStore , false); + RegisterVariable('quit' , vtCommand, @chQuit , true ); + RegisterVariable('confirm' , vtCommand, @chConfirm , true ); + RegisterVariable('+speedup', vtCommand, @chSpeedup_p , true ); + RegisterVariable('-speedup', vtCommand, @chSpeedup_m , true ); + RegisterVariable('zoomin' , vtCommand, @chZoomIn , true ); + RegisterVariable('zoomout' , vtCommand, @chZoomOut , true ); + RegisterVariable('zoomreset',vtCommand, @chZoomReset , true ); + RegisterVariable('skip' , vtCommand, @chSkip , false); + RegisterVariable('history' , vtCommand, @chHistory , true ); + RegisterVariable('chat' , vtCommand, @chChat , true ); + RegisterVariable('newgrave', vtCommand, @chNewGrave , false); + RegisterVariable('say' , vtCommand, @chSay , true ); + RegisterVariable('hogsay' , vtCommand, @chHogSay , true ); + RegisterVariable('team' , vtCommand, @chTeamSay , true ); + RegisterVariable('ammomenu', vtCommand, @chAmmoMenu , true); + RegisterVariable('+precise', vtCommand, @chPrecise_p , false); + RegisterVariable('-precise', vtCommand, @chPrecise_m , false); + RegisterVariable('+left' , vtCommand, @chLeft_p , false); + RegisterVariable('-left' , vtCommand, @chLeft_m , false); + RegisterVariable('+right' , vtCommand, @chRight_p , false); + RegisterVariable('-right' , vtCommand, @chRight_m , false); + RegisterVariable('+up' , vtCommand, @chUp_p , false); + RegisterVariable('-up' , vtCommand, @chUp_m , false); + RegisterVariable('+down' , vtCommand, @chDown_p , false); + RegisterVariable('-down' , vtCommand, @chDown_m , false); + RegisterVariable('+attack' , vtCommand, @chAttack_p , false); + RegisterVariable('-attack' , vtCommand, @chAttack_m , false); + RegisterVariable('switch' , vtCommand, @chSwitch , false); + RegisterVariable('nextturn', vtCommand, @chNextTurn , false); + RegisterVariable('timer' , vtCommand, @chTimer , false); + RegisterVariable('taunt' , vtCommand, @chTaunt , false); + RegisterVariable('setweap' , vtCommand, @chSetWeapon , false); + RegisterVariable('slot' , vtCommand, @chSlot , false); + RegisterVariable('put' , vtCommand, @chPut , false); + RegisterVariable('ljump' , vtCommand, @chLJump , false); + RegisterVariable('hjump' , vtCommand, @chHJump , false); + RegisterVariable('fullscr' , vtCommand, @chFullScr , true ); + RegisterVariable('+volup' , vtCommand, @chVol_p , true ); + RegisterVariable('-volup' , vtCommand, @chVol_m , true ); + RegisterVariable('+voldown', vtCommand, @chVol_m , true ); + RegisterVariable('-voldown', vtCommand, @chVol_p , true ); + RegisterVariable('findhh' , vtCommand, @chFindhh , true ); + RegisterVariable('pause' , vtCommand, @chPause , true ); + RegisterVariable('+cur_u' , vtCommand, @chCurU_p , true ); + RegisterVariable('-cur_u' , vtCommand, @chCurU_m , true ); + RegisterVariable('+cur_d' , vtCommand, @chCurD_p , true ); + RegisterVariable('-cur_d' , vtCommand, @chCurD_m , true ); + RegisterVariable('+cur_l' , vtCommand, @chCurL_p , true ); + RegisterVariable('-cur_l' , vtCommand, @chCurL_m , true ); + RegisterVariable('+cur_r' , vtCommand, @chCurR_p , true ); + RegisterVariable('-cur_r' , vtCommand, @chCurR_m , true ); + RegisterVariable('flag' , vtCommand, @chFlag , false); + RegisterVariable('script' , vtCommand, @chScript , false); end; procedure free_uConsole; begin - FreeVariablesList(); + FreeVariablesList(); end; end. diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/uConsts.pas --- a/hedgewars/uConsts.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/uConsts.pas Sat Mar 06 10:59:20 2010 +0000 @@ -21,11 +21,11 @@ unit uConsts; interface -uses SDLh, uFloat, uLocale, +uses SDLh, uFloat, uLocale, {$IFDEF GLES11} - gles11; + gles11; {$ELSE} - GL; + GL; {$ENDIF} @@ -35,354 +35,354 @@ // in freepascal you may actually use var for the same purpose type - HwColor4f = record - r, g, b, a: byte - end; - - TGameState = (gsLandGen, gsStart, gsGame, gsChat, gsConfirm, gsExit); + HwColor4f = record + r, g, b, a: byte + end; + + TGameState = (gsLandGen, gsStart, gsGame, gsChat, gsConfirm, gsExit); - TGameType = (gmtLocal, gmtDemo, gmtNet, gmtSave, gmtLandPreview, gmtSyntax); + TGameType = (gmtLocal, gmtDemo, gmtNet, gmtSave, gmtLandPreview, gmtSyntax); - TPathType = (ptNone, ptData, ptGraphics, ptThemes, ptCurrTheme, ptTeams, ptMaps, - ptMapCurrent, ptDemos, ptSounds, ptGraves, ptFonts, ptForts, - ptLocale, ptAmmoMenu, ptHedgehog, ptVoices, ptHats, ptFlags); + TPathType = (ptNone, ptData, ptGraphics, ptThemes, ptCurrTheme, ptTeams, ptMaps, + ptMapCurrent, ptDemos, ptSounds, ptGraves, ptFonts, ptForts, + ptLocale, ptAmmoMenu, ptHedgehog, ptVoices, ptHats, ptFlags); - TSprite = (sprWater, sprCloud, sprBomb, sprBigDigit, sprFrame, - sprLag, sprArrow, sprGrenade, sprTargetP, sprUFO, - sprSmokeTrace, sprRopeHook, sprExplosion50, sprMineOff, - sprMineOn, sprMineDead, sprCase, sprFAid, sprDynamite, sprPower, - sprClusterBomb, sprClusterParticle, sprFlame, sprHorizont, - sprHorizontL, sprHorizontR, sprSky, sprSkyL, - sprSkyR, sprAMBorders, sprAMSlot, sprAMSlotName, sprAMAmmos, - sprAMSlotKeys, sprAMSelection, sprFinger, sprAirBomb, - sprAirplane, sprAmAirplane, sprAmGirder, sprHHTelepMask, - sprSwitch, sprParachute, sprTarget, sprRopeNode, - sprQuestion, sprPowerBar, sprWindBar, sprWindL, sprWindR, - sprFlake, sprHandRope, sprHandBazooka, sprHandShotgun, - sprHandDEagle, sprHandAirAttack, sprHandBaseball, sprPHammer, - sprHandBlowTorch, sprBlowTorch, sprTeleport, sprHHDeath, - sprShotgun, sprDEagle, sprHHIdle, sprMortar, sprTurnsLeft, - sprKamikaze, sprWhip, sprKowtow, sprSad, sprWave, - sprHurrah, sprLemonade, sprShrug, sprJuggle, sprExplPart, sprExplPart2, - sprCakeWalk, sprCakeDown, sprAMAmmosBW, sprWatermelon, - sprEvilTrace, sprHellishBomb, sprSeduction, sprDress, - sprCensored, sprDrill, sprHandDrill, sprHandBallgun, sprBalls, - sprPlane, sprHandPlane, sprUtility, sprInvulnerable, sprVampiric, sprGirder, - sprSpeechCorner, sprSpeechEdge, sprSpeechTail, - sprThoughtCorner, sprThoughtEdge, sprThoughtTail, - sprShoutCorner, sprShoutEdge, sprShoutTail, - sprSniperRifle, sprBubbles, sprJetpack, sprHealth, sprHandMolotov, sprMolotov, - sprSmoke, sprSmokeWhite, sprShell, sprDust, sprExplosives, sprExplosivesRoll, sprAmTeleport); + TSprite = (sprWater, sprCloud, sprBomb, sprBigDigit, sprFrame, + sprLag, sprArrow, sprGrenade, sprTargetP, sprUFO, + sprSmokeTrace, sprRopeHook, sprExplosion50, sprMineOff, + sprMineOn, sprMineDead, sprCase, sprFAid, sprDynamite, sprPower, + sprClusterBomb, sprClusterParticle, sprFlame, sprHorizont, + sprHorizontL, sprHorizontR, sprSky, sprSkyL, + sprSkyR, sprAMBorders, sprAMSlot, sprAMSlotName, sprAMAmmos, + sprAMSlotKeys, sprAMSelection, sprFinger, sprAirBomb, + sprAirplane, sprAmAirplane, sprAmGirder, sprHHTelepMask, + sprSwitch, sprParachute, sprTarget, sprRopeNode, + sprQuestion, sprPowerBar, sprWindBar, sprWindL, sprWindR, + sprFlake, sprHandRope, sprHandBazooka, sprHandShotgun, + sprHandDEagle, sprHandAirAttack, sprHandBaseball, sprPHammer, + sprHandBlowTorch, sprBlowTorch, sprTeleport, sprHHDeath, + sprShotgun, sprDEagle, sprHHIdle, sprMortar, sprTurnsLeft, + sprKamikaze, sprWhip, sprKowtow, sprSad, sprWave, + sprHurrah, sprLemonade, sprShrug, sprJuggle, sprExplPart, sprExplPart2, + sprCakeWalk, sprCakeDown, sprAMAmmosBW, sprWatermelon, + sprEvilTrace, sprHellishBomb, sprSeduction, sprDress, + sprCensored, sprDrill, sprHandDrill, sprHandBallgun, sprBalls, + sprPlane, sprHandPlane, sprUtility, sprInvulnerable, sprVampiric, sprGirder, + sprSpeechCorner, sprSpeechEdge, sprSpeechTail, + sprThoughtCorner, sprThoughtEdge, sprThoughtTail, + sprShoutCorner, sprShoutEdge, sprShoutTail, + sprSniperRifle, sprBubbles, sprJetpack, sprHealth, sprHandMolotov, sprMolotov, + sprSmoke, sprSmokeWhite, sprShell, sprDust, sprExplosives, sprExplosivesRoll, sprAmTeleport); - TGearType = (gtAmmo_Bomb, gtHedgehog, gtAmmo_Grenade, gtHealthTag, // 3 - gtGrave, gtUFO, gtShotgunShot, gtPickHammer, gtRope, // 8 - gtSmokeTrace, gtExplosion, gtMine, gtCase, gtDEagleShot, gtDynamite, // 14 - gtClusterBomb, gtCluster, gtShover, gtFlame, // 18 - gtFirePunch, gtATStartGame, gtATSmoothWindCh, gtATFinishGame, // 24 - gtParachute, gtAirAttack, gtAirBomb, gtBlowTorch, gtGirder, // 27 - gtTeleport, gtSwitcher, gtTarget, gtMortar, // 31 - gtWhip, gtKamikaze, gtCake, gtSeduction, gtWatermelon, gtMelonPiece, // 37 - gtHellishBomb, gtEvilTrace, gtWaterUp, gtDrill, gtBallGun, gtBall,gtRCPlane, - gtSniperRifleShot, gtJetpack, gtMolotov, gtExplosives); + TGearType = (gtAmmo_Bomb, gtHedgehog, gtAmmo_Grenade, gtHealthTag, // 3 + gtGrave, gtUFO, gtShotgunShot, gtPickHammer, gtRope, // 8 + gtSmokeTrace, gtExplosion, gtMine, gtCase, gtDEagleShot, gtDynamite, // 14 + gtClusterBomb, gtCluster, gtShover, gtFlame, // 18 + gtFirePunch, gtATStartGame, gtATSmoothWindCh, gtATFinishGame, // 24 + gtParachute, gtAirAttack, gtAirBomb, gtBlowTorch, gtGirder, // 27 + gtTeleport, gtSwitcher, gtTarget, gtMortar, // 31 + gtWhip, gtKamikaze, gtCake, gtSeduction, gtWatermelon, gtMelonPiece, // 37 + gtHellishBomb, gtEvilTrace, gtWaterUp, gtDrill, gtBallGun, gtBall,gtRCPlane, + gtSniperRifleShot, gtJetpack, gtMolotov, gtExplosives); - TVisualGearType = (vgtFlake, vgtCloud, vgtExplPart, vgtExplPart2, vgtFire, - vgtSmallDamageTag, vgtTeamHealthSorter, vgtSpeechBubble, vgtBubble, - vgtSteam, vgtSmoke, vgtSmokeWhite, vgtHealth, vgtShell, vgtDust); + TVisualGearType = (vgtFlake, vgtCloud, vgtExplPart, vgtExplPart2, vgtFire, + vgtSmallDamageTag, vgtTeamHealthSorter, vgtSpeechBubble, vgtBubble, + vgtSteam, vgtSmoke, vgtSmokeWhite, vgtHealth, vgtShell, vgtDust); - TGearsType = set of TGearType; + TGearsType = set of TGearType; - TSound = (sndNone, - sndGrenadeImpact, sndExplosion, sndThrowPowerUp, sndThrowRelease, - sndSplash, sndShotgunReload, sndShotgunFire, sndGraveImpact, - sndMineTick, sndPickhammer, sndGun, sndUFO, sndJump1, sndJump2, - sndJump3, sndYesSir, sndLaugh, sndIllGetYou, sndIncoming, - sndMissed, sndStupid, sndFirstBlood, sndBoring, sndByeBye, - sndSameTeam, sndNutter, sndReinforce, sndTraitor, sndRegret, - sndEnemyDown, sndCoward, sndHurry, sndWatchIt, sndKamikaze, - sndCake, sndOw1, sndOw4, sndFirePunch1, sndFirePunch2, - sndFirePunch3, sndFirePunch4, sndFirePunch5, sndFirePunch6, - sndMelon, sndHellish, sndYoohoo, sndRCPlane, sndWhipCrack, - sndRideOfTheValkyries, sndDenied, sndPlaced, sndBaseballBat, - sndVaporize, sndWarp, sndSuddenDeath, sndMortar, sndShutter, - sndHomerun, sndMolotov, sndCover, sndUhOh, sndOops, - sndNooo, sndHello, sndRopeShot, sndRopeAttach, sndRopeRelease, - sndSwitchHog, sndVictory, sndSniperReload, sndSteps, sndLowGravity); + TSound = (sndNone, + sndGrenadeImpact, sndExplosion, sndThrowPowerUp, sndThrowRelease, + sndSplash, sndShotgunReload, sndShotgunFire, sndGraveImpact, + sndMineTick, sndPickhammer, sndGun, sndUFO, sndJump1, sndJump2, + sndJump3, sndYesSir, sndLaugh, sndIllGetYou, sndIncoming, + sndMissed, sndStupid, sndFirstBlood, sndBoring, sndByeBye, + sndSameTeam, sndNutter, sndReinforce, sndTraitor, sndRegret, + sndEnemyDown, sndCoward, sndHurry, sndWatchIt, sndKamikaze, + sndCake, sndOw1, sndOw4, sndFirePunch1, sndFirePunch2, + sndFirePunch3, sndFirePunch4, sndFirePunch5, sndFirePunch6, + sndMelon, sndHellish, sndYoohoo, sndRCPlane, sndWhipCrack, + sndRideOfTheValkyries, sndDenied, sndPlaced, sndBaseballBat, + sndVaporize, sndWarp, sndSuddenDeath, sndMortar, sndShutter, + sndHomerun, sndMolotov, sndCover, sndUhOh, sndOops, + sndNooo, sndHello, sndRopeShot, sndRopeAttach, sndRopeRelease, + sndSwitchHog, sndVictory, sndSniperReload, sndSteps, sndLowGravity); - TAmmoType = (amNothing, amGrenade, amClusterBomb, amBazooka, amUFO, amShotgun, amPickHammer, - amSkip, amRope, amMine, amDEagle, amDynamite, amFirePunch, amWhip, - amBaseballBat, amParachute, amAirAttack, amMineStrike, amBlowTorch, - amGirder, amTeleport, amSwitch, amMortar, amKamikaze, amCake, - amSeduction, amWatermelon, amHellishBomb, amNapalm, amDrill, amBallgun, - amRCPlane, amLowGravity, amExtraDamage, amInvulnerable, amExtraTime, - amLaserSight, amVampiric, amSniperRifle, amJetpack, amMolotov); + TAmmoType = (amNothing, amGrenade, amClusterBomb, amBazooka, amUFO, amShotgun, amPickHammer, + amSkip, amRope, amMine, amDEagle, amDynamite, amFirePunch, amWhip, + amBaseballBat, amParachute, amAirAttack, amMineStrike, amBlowTorch, + amGirder, amTeleport, amSwitch, amMortar, amKamikaze, amCake, + amSeduction, amWatermelon, amHellishBomb, amNapalm, amDrill, amBallgun, + amRCPlane, amLowGravity, amExtraDamage, amInvulnerable, amExtraTime, + amLaserSight, amVampiric, amSniperRifle, amJetpack, amMolotov); - THWFont = (fnt16, fntBig, fntSmall, CJKfnt16, CJKfntBig, CJKfntSmall); + THWFont = (fnt16, fntBig, fntSmall, CJKfnt16, CJKfntBig, CJKfntSmall); - TCapGroup = (capgrpGameState, capgrpAmmoinfo, capgrpVolume, - capgrpMessage, capgrpAmmostate); + TCapGroup = (capgrpGameState, capgrpAmmoinfo, capgrpVolume, + capgrpMessage, capgrpAmmostate); - TStatInfoType = (siGameResult, siMaxStepDamage, siMaxStepKills, siKilledHHs, - siClanHealth); + TStatInfoType = (siGameResult, siMaxStepDamage, siMaxStepKills, siKilledHHs, + siClanHealth); - TWave = (waveRollup, waveSad, waveWave, waveHurrah, waveLemonade, waveShrug, waveJuggle); + TWave = (waveRollup, waveSad, waveWave, waveHurrah, waveLemonade, waveShrug, waveJuggle); - THHFont = record - Handle: PTTF_Font; - Height: LongInt; - style: LongInt; - Name: string[21]; - end; + THHFont = record + Handle: PTTF_Font; + Height: LongInt; + style: LongInt; + Name: string[21]; + end; - PAmmo = ^TAmmo; - TAmmo = record - Propz: LongWord; - Count: LongWord; + PAmmo = ^TAmmo; + TAmmo = record + Propz: LongWord; + Count: LongWord; (* Using for place hedgehogs mode, but for any other situation where the initial count would be needed I guess. For example, say, a mode where the weaponset is reset each turn, or on sudden death *) - InitialCount: LongWord; - NumPerTurn: LongWord; - Timer: LongWord; - Pos: LongWord; - AmmoType: TAmmoType; - AttackVoice: TSound; - end; + InitialCount: LongWord; + NumPerTurn: LongWord; + Timer: LongWord; + Pos: LongWord; + AmmoType: TAmmoType; + AttackVoice: TSound; + end; - TVertex2f = record - X, Y: GLfloat; - end; + TVertex2f = record + X, Y: GLfloat; + end; - TVertex2i = record - X, Y: GLint; - end; + TVertex2i = record + X, Y: GLint; + end; - PTexture = ^TTexture; - TTexture = record - id: GLuint; - w, h: LongInt; - rx, ry: GLfloat; - vb, tb: array [0..3] of TVertex2f; + PTexture = ^TTexture; + TTexture = record + id: GLuint; + w, h: LongInt; + rx, ry: GLfloat; + vb, tb: array [0..3] of TVertex2f; PrevTexture, NextTexture: PTexture; - end; + end; const - // message constants - errmsgCreateSurface = 'Error creating SDL surface'; - errmsgTransparentSet = 'Error setting transparent color'; - errmsgUnknownCommand = 'Unknown command'; - errmsgUnknownVariable = 'Unknown variable'; - errmsgIncorrectUse = 'Incorrect use'; - errmsgShouldntRun = 'This program shouldn''t be run manually'; - errmsgWrongNumber = 'Wrong parameters number'; - errmsgSlotsOverflow = 'CurSlot overflowed'; + // message constants + errmsgCreateSurface = 'Error creating SDL surface'; + errmsgTransparentSet = 'Error setting transparent color'; + errmsgUnknownCommand = 'Unknown command'; + errmsgUnknownVariable = 'Unknown variable'; + errmsgIncorrectUse = 'Incorrect use'; + errmsgShouldntRun = 'This program shouldn''t be run manually'; + errmsgWrongNumber = 'Wrong parameters number'; + errmsgSlotsOverflow = 'CurSlot overflowed'; - msgLoading = 'Loading '; - msgOK = 'ok'; - msgFailed = 'failed'; - msgFailedSize = 'failed due to size'; - msgGettingConfig = 'Getting game config...'; + msgLoading = 'Loading '; + msgOK = 'ok'; + msgFailed = 'failed'; + msgFailedSize = 'failed due to size'; + msgGettingConfig = 'Getting game config...'; - // color constants - cWhiteColorChannels : TSDL_Color = (r:$FF; g:$FF; b:$FF; unused:$FF); - cNearBlackColorChannels : TSDL_Color = (r:$00; g:$00; b:$10; unused:$FF); + // color constants + cWhiteColorChannels : TSDL_Color = (r:$FF; g:$FF; b:$FF; unused:$FF); + cNearBlackColorChannels : TSDL_Color = (r:$00; g:$00; b:$10; unused:$FF); - cWhiteColor : Longword = $FFFFFFFF; - cYellowColor : Longword = $FFFFFF00; - cNearBlackColor : Longword = $FF000010; - cExplosionBorderColor : LongWord = $FF808080; + cWhiteColor : Longword = $FFFFFFFF; + cYellowColor : Longword = $FFFFFF00; + cNearBlackColor : Longword = $FF000010; + cExplosionBorderColor : LongWord = $FF808080; {$WARNINGS OFF} - cAirPlaneSpeed: hwFloat = (isNegative: false; QWordValue: 3006477107); // 1.4 - cBombsSpeed : hwFloat = (isNegative: false; QWordValue: 429496729); + cAirPlaneSpeed: hwFloat = (isNegative: false; QWordValue: 3006477107); // 1.4 + cBombsSpeed : hwFloat = (isNegative: false; QWordValue: 429496729); {$WARNINGS ON} - // image flags (for LoadImage()) - ifNone = $00000000; // nothing special - ifAlpha = $00000001; // use alpha channel (unused right now?) - ifCritical = $00000002; // image is critical for gameplay (exit game if unable to load) - ifTransparent = $00000004; // image uses transparent pixels (color keying) - ifIgnoreCaps = $00000008; // ignore hardware capabilities when loading (i.e. image will not be drawn using OpenGL) - ifLowRes = $00000010; // try loading a low resolution image when it is critical + // image flags (for LoadImage()) + ifNone = $00000000; // nothing special + ifAlpha = $00000001; // use alpha channel (unused right now?) + ifCritical = $00000002; // image is critical for gameplay (exit game if unable to load) + ifTransparent = $00000004; // image uses transparent pixels (color keying) + ifIgnoreCaps = $00000008; // ignore hardware capabilities when loading (i.e. image will not be drawn using OpenGL) + ifLowRes = $00000010; // try loading a low resolution image when it is critical - {* REFERENCE + {* REFERENCE 4096 -> $FFFFF000 2048 -> $FFFFF800 1024 -> $FFFFFC00 512 -> $FFFFFE00 *} {$IFDEF LOWRES} - // default for iphone pre 3gs - LAND_WIDTH = 2048; - LAND_HEIGHT = 1024; - LAND_WIDTH_MASK = $FFFFF800; - LAND_HEIGHT_MASK = $FFFFFC00; + // default for iphone pre 3gs + LAND_WIDTH = 2048; + LAND_HEIGHT = 1024; + LAND_WIDTH_MASK = $FFFFF800; + LAND_HEIGHT_MASK = $FFFFFC00; {$ELSE} - LAND_WIDTH = 4096; - LAND_HEIGHT = 2048; - LAND_WIDTH_MASK = $FFFFF000; - LAND_HEIGHT_MASK = $FFFFF800; + LAND_WIDTH = 4096; + LAND_HEIGHT = 2048; + LAND_WIDTH_MASK = $FFFFF000; + LAND_HEIGHT_MASK = $FFFFF800; {$ENDIF} - COLOR_LAND = $FFFF; // white - COLOR_INDESTRUCTIBLE = $88FF; // red - COLOR_OBJECT = $44FF; // no idea + COLOR_LAND = $FFFF; // white + COLOR_INDESTRUCTIBLE = $88FF; // red + COLOR_OBJECT = $44FF; // no idea - cMaxPower = 1500; - cMaxAngle = 2048; - cPowerDivisor = 1500; + cMaxPower = 1500; + cMaxAngle = 2048; + cPowerDivisor = 1500; - MAXNAMELEN = 192; - - // some opengl headers do not have these macros - GL_BGR = $80E0; - GL_BGRA = $80E1; - GL_CLAMP_TO_EDGE = $812F; + MAXNAMELEN = 192; + + // some opengl headers do not have these macros + GL_BGR = $80E0; + GL_BGRA = $80E1; + GL_CLAMP_TO_EDGE = $812F; - cSendCursorPosTime : LongWord = 50; - cVisibleWater : LongInt = 128; - cCursorEdgesDist : LongInt = 100; - cTeamHealthWidth : LongInt = 128; - cWaterOpacity : byte = $80; + cSendCursorPosTime : LongWord = 50; + cVisibleWater : LongInt = 128; + cCursorEdgesDist : LongInt = 100; + cTeamHealthWidth : LongInt = 128; + cWaterOpacity : byte = $80; - cifRandomize = $00000001; - cifTheme = $00000002; - cifMap = $00000002; // either theme or map (or map+theme) - cifAllInited = cifRandomize or cifTheme or cifMap; + cifRandomize = $00000001; + cifTheme = $00000002; + cifMap = $00000002; // either theme or map (or map+theme) + cifAllInited = cifRandomize or cifTheme or cifMap; - cTransparentColor: Longword = $00000000; + cTransparentColor: Longword = $00000000; - cMaxTeams = 6; - cMaxHHIndex = 7; - cMaxHHs = 48; - cMaxSpawnPoints = 1024; + cMaxTeams = 6; + cMaxHHIndex = 7; + cMaxHHs = 48; + cMaxSpawnPoints = 1024; - cMaxEdgePoints = 16384; + cMaxEdgePoints = 16384; - cHHRadius = 9; - cHHStepTicks = 29; + cHHRadius = 9; + cHHStepTicks = 29; - cUsualZ = 500; - cSmokeZ = 499; - cHHZ = 1000; - cCurrHHZ = Succ(cHHZ); - cOnHHZ = 2000; + cUsualZ = 500; + cSmokeZ = 499; + cHHZ = 1000; + cCurrHHZ = Succ(cHHZ); + cOnHHZ = 2000; - cBarrelHealth = 60; - cShotgunRadius = 22; - cBlowTorchC = 6; + cBarrelHealth = 60; + cShotgunRadius = 22; + cBlowTorchC = 6; - cKeyMaxIndex = 1023; + cKeyMaxIndex = 1023; {$IFDEF IPHONEOS} - cMaxCaptions = 3; + cMaxCaptions = 3; {$ELSE} - cMaxCaptions = 4; + cMaxCaptions = 4; {$ENDIF} - cSendEmptyPacketTime = 1000; + cSendEmptyPacketTime = 1000; - // from uTriggers - trigTurns = $80000001; + // from uTriggers + trigTurns = $80000001; - // Training Flags - tfNone = $00000000; - tfTimeTrial = $00000001; - tfRCPlane = $00000002; - tfSpawnTargets = $00000004; - tfIgnoreDelays = $00000008; - tfTargetRespawn = $00000010; - - gfAny = $FFFFFFFF; - gfForts = $00000001; - gfMultiWeapon = $00000002; - gfSolidLand = $00000004; - gfBorder = $00000008; - gfDivideTeams = $00000010; - gfLowGravity = $00000020; - gfLaserSight = $00000040; - gfInvulnerable = $00000080; - gfMines = $00000100; - gfVampiric = $00000200; - gfKarma = $00000400; - gfArtillery = $00000800; - gfOneClanMode = $00001000; - gfRandomOrder = $00002000; - gfKing = $00004000; - gfPlaceHog = $00008000; - gfSharedAmmo = $00010000; - gfDisableGirders = $00020000; - gfExplosives = $00040000; - // NOTE: When adding new game flags, ask yourself - // if a "game start notice" would be useful. If so, - // add one in uWorld.pas - look for "AddGoal". + // Training Flags + tfNone = $00000000; + tfTimeTrial = $00000001; + tfRCPlane = $00000002; + tfSpawnTargets = $00000004; + tfIgnoreDelays = $00000008; + tfTargetRespawn = $00000010; + + gfAny = $FFFFFFFF; + gfForts = $00000001; + gfMultiWeapon = $00000002; + gfSolidLand = $00000004; + gfBorder = $00000008; + gfDivideTeams = $00000010; + gfLowGravity = $00000020; + gfLaserSight = $00000040; + gfInvulnerable = $00000080; + gfMines = $00000100; + gfVampiric = $00000200; + gfKarma = $00000400; + gfArtillery = $00000800; + gfOneClanMode = $00001000; + gfRandomOrder = $00002000; + gfKing = $00004000; + gfPlaceHog = $00008000; + gfSharedAmmo = $00010000; + gfDisableGirders = $00020000; + gfExplosives = $00040000; + // NOTE: When adding new game flags, ask yourself + // if a "game start notice" would be useful. If so, + // add one in uWorld.pas - look for "AddGoal". - gstDrowning = $00000001; - gstHHDriven = $00000002; - gstMoving = $00000004; - gstAttacked = $00000008; - gstAttacking = $00000010; - gstCollision = $00000020; - gstHHChooseTarget = $00000040; - gstHHJumping = $00000100; - gsttmpFlag = $00000200; - gstHHThinking = $00000800; - gstNoDamage = $00001000; - gstHHHJump = $00002000; - gstAnimation = $00004000; - gstHHDeath = $00008000; - gstWinner = $00010000; // this, along with gstLoser, is good for indicating hedgies know they screwed up - gstWait = $00020000; - gstNotKickable = $00040000; - gstLoser = $00080000; + gstDrowning = $00000001; + gstHHDriven = $00000002; + gstMoving = $00000004; + gstAttacked = $00000008; + gstAttacking = $00000010; + gstCollision = $00000020; + gstHHChooseTarget = $00000040; + gstHHJumping = $00000100; + gsttmpFlag = $00000200; + gstHHThinking = $00000800; + gstNoDamage = $00001000; + gstHHHJump = $00002000; + gstAnimation = $00004000; + gstHHDeath = $00008000; + gstWinner = $00010000; // this, along with gstLoser, is good for indicating hedgies know they screwed up + gstWait = $00020000; + gstNotKickable = $00040000; + gstLoser = $00080000; - gm_Left = $00000001; - gm_Right = $00000002; - gm_Up = $00000004; - gm_Down = $00000008; - gm_Switch = $00000010; - gm_Attack = $00000020; - gm_LJump = $00000040; - gm_HJump = $00000080; - gm_Destroy= $00000100; - gm_Slot = $00000200; // with param - gm_Weapon = $00000400; // with param - gm_Timer = $00000800; // with param - gm_Animate= $00001000; // with param - gm_Precise= $00002000; - gmAllStoppable = gm_Left or gm_Right or gm_Up or gm_Down or gm_Attack or gm_Precise; + gm_Left = $00000001; + gm_Right = $00000002; + gm_Up = $00000004; + gm_Down = $00000008; + gm_Switch = $00000010; + gm_Attack = $00000020; + gm_LJump = $00000040; + gm_HJump = $00000080; + gm_Destroy= $00000100; + gm_Slot = $00000200; // with param + gm_Weapon = $00000400; // with param + gm_Timer = $00000800; // with param + gm_Animate= $00001000; // with param + gm_Precise= $00002000; + gmAllStoppable = gm_Left or gm_Right or gm_Up or gm_Down or gm_Attack or gm_Precise; - cMaxSlotIndex = 8; - cMaxSlotAmmoIndex = 5; + cMaxSlotIndex = 8; + cMaxSlotAmmoIndex = 5; - ammoprop_Timerable = $00000001; - ammoprop_Power = $00000002; - ammoprop_NeedTarget = $00000004; - ammoprop_ForwMsgs = $00000008; - ammoprop_AttackInMove = $00000010; - ammoprop_NoCrosshair = $00000040; - ammoprop_AttackingPut = $00000080; - ammoprop_DontHold = $00000100; - ammoprop_AltAttack = $00000200; - ammoprop_AltUse = $00000400; - ammoprop_NotBorder = $00000800; - ammoprop_Utility = $00001000; - ammoprop_NoRoundEndHint=$10000000; - - AMMO_INFINITE = 100; + ammoprop_Timerable = $00000001; + ammoprop_Power = $00000002; + ammoprop_NeedTarget = $00000004; + ammoprop_ForwMsgs = $00000008; + ammoprop_AttackInMove = $00000010; + ammoprop_NoCrosshair = $00000040; + ammoprop_AttackingPut = $00000080; + ammoprop_DontHold = $00000100; + ammoprop_AltAttack = $00000200; + ammoprop_AltUse = $00000400; + ammoprop_NotBorder = $00000800; + ammoprop_Utility = $00001000; + ammoprop_NoRoundEndHint=$10000000; + + AMMO_INFINITE = 100; - EXPLAllDamageInRadius = $00000001; - EXPLAutoSound = $00000002; - EXPLNoDamage = $00000004; - EXPLDoNotTouchHH = $00000008; - EXPLDontDraw = $00000010; + EXPLAllDamageInRadius = $00000001; + EXPLAutoSound = $00000002; + EXPLNoDamage = $00000004; + EXPLDoNotTouchHH = $00000008; + EXPLDontDraw = $00000010; - posCaseAmmo = $00000001; - posCaseHealth = $00000002; - posCaseUtility = $00000004; + posCaseAmmo = $00000001; + posCaseHealth = $00000002; + posCaseUtility = $00000004; - NoPointX = Low(LongInt); - cTargetPointRef : TPoint = (X: NoPointX; Y: 0); + NoPointX = Low(LongInt); + cTargetPointRef : TPoint = (X: NoPointX; Y: 0); - // hog tag mask + // hog tag mask // hog tag mask htNone = $00; htTeamName = $01; @@ -403,1301 +403,1301 @@ cTagsMasks : array[0..15] of byte = (7, 0, 0, 0, 15, 6, 4, 5, 0, 0, 0, 0, 0, 14, 12, 13); cTagsMasksNoHealth: array[0..15] of byte = (3, 2, 11, 1, 0, 0, 0, 0, 0, 10, 0, 9, 0, 0, 0, 0); - Fontz: array[THWFont] of THHFont = ( - (Handle: nil; - Height: 12; - style: TTF_STYLE_NORMAL; - Name: 'DejaVuSans-Bold.ttf'), - (Handle: nil; - Height: 24; - style: TTF_STYLE_NORMAL; - Name: 'DejaVuSans-Bold.ttf'), - (Handle: nil; - Height: 10; - style: TTF_STYLE_NORMAL; - Name: 'DejaVuSans-Bold.ttf'), - (Handle: nil; - Height: 12; - style: TTF_STYLE_NORMAL; - Name: 'wqy-zenhei.ttc'), - (Handle: nil; - Height: 24; - style: TTF_STYLE_NORMAL; - Name: 'wqy-zenhei.ttc'), - (Handle: nil; - Height: 10; - style: TTF_STYLE_NORMAL; - Name: 'wqy-zenhei.ttc') - ); + Fontz: array[THWFont] of THHFont = ( + (Handle: nil; + Height: 12; + style: TTF_STYLE_NORMAL; + Name: 'DejaVuSans-Bold.ttf'), + (Handle: nil; + Height: 24; + style: TTF_STYLE_NORMAL; + Name: 'DejaVuSans-Bold.ttf'), + (Handle: nil; + Height: 10; + style: TTF_STYLE_NORMAL; + Name: 'DejaVuSans-Bold.ttf'), + (Handle: nil; + Height: 12; + style: TTF_STYLE_NORMAL; + Name: 'wqy-zenhei.ttc'), + (Handle: nil; + Height: 24; + style: TTF_STYLE_NORMAL; + Name: 'wqy-zenhei.ttc'), + (Handle: nil; + Height: 10; + style: TTF_STYLE_NORMAL; + Name: 'wqy-zenhei.ttc') + ); - SpritesData: array[TSprite] of record - FileName: String[14]; - Path, AltPath: TPathType; - Texture: PTexture; - Surface: PSDL_Surface; - Width, Height, imageWidth, imageHeight: LongInt; - saveSurf: boolean; - end = ( - (FileName: 'BlueWater'; Path: ptCurrTheme;AltPath: ptGraphics; Texture: nil; Surface: nil; - Width: 0; Height: 0; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprWater - (FileName: 'Clouds'; Path: ptCurrTheme;AltPath: ptGraphics; Texture: nil; Surface: nil; - Width: 256; Height:128; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprCloud - (FileName: 'Bomb'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 8; Height: 8; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprBomb - (FileName: 'BigDigits'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprBigDigit - (FileName: 'Frame'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 4; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprFrame - (FileName: 'Lag'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 65; Height: 65; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprLag - (FileName: 'Arrow'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprCursor - (FileName: 'Grenade'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprGrenade - (FileName: 'Targetp'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprTargetP - (FileName: 'UFO'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprUFO - (FileName: 'SmokeTrace'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprSmokeTrace - (FileName: 'RopeHook'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprRopeHook - (FileName: 'Expl50'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprExplosion50 - (FileName: 'MineOff'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 8; Height: 8; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprMineOff - (FileName: 'MineOn'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 8; Height: 8; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprMineOn - (FileName: 'MineDead'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 8; Height: 8; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprMineDead - (FileName: 'Case'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 48; Height: 48; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprCase - (FileName: 'FirstAid'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 48; Height: 48; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprFAid - (FileName: 'dynamite'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprDynamite - (FileName: 'Power'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprPower - (FileName: 'ClBomb'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprClusterBomb - (FileName: 'ClParticle'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprClusterParticle - (FileName: 'Flame'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprFlame - (FileName: 'horizont'; Path: ptCurrTheme;AltPath: ptNone; Texture: nil; Surface: nil; - Width: 0; Height: 0; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHorizont - (FileName: 'horizontL'; Path: ptCurrTheme;AltPath: ptNone; Texture: nil; Surface: nil; - Width: 0; Height: 0; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHorizont - (FileName: 'horizontR'; Path: ptCurrTheme;AltPath: ptNone; Texture: nil; Surface: nil; - Width: 0; Height: 0; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHorizont - (FileName: 'Sky'; Path: ptCurrTheme;AltPath: ptNone; Texture: nil; Surface: nil; - Width: 0; Height: 0; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprSky - (FileName: 'SkyL'; Path: ptCurrTheme;AltPath: ptNone; Texture: nil; Surface: nil; - Width: 0; Height: 0; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprSky - (FileName: 'SkyR'; Path: ptCurrTheme;AltPath: ptNone; Texture: nil; Surface: nil; - Width: 0; Height: 0; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprSky - (FileName: 'BrdrLines'; Path: ptAmmoMenu; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 202; Height: 1; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprAMBorders - (FileName: 'Slot'; Path: ptAmmoMenu; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 202; Height: 33; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprAMSlot - (FileName: 'AmmoName'; Path: ptAmmoMenu; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 202; Height: 33; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprAMSlotName - (FileName: 'Ammos'; Path: ptAmmoMenu; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: true),// sprAMAmmos - (FileName: 'SlotKeys'; Path: ptAmmoMenu; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprAMSlotKeys - (FileName: 'Selection'; Path: ptAmmoMenu; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprAMSelection - (FileName: 'Finger'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 48; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprFinger - (FileName: 'AirBomb'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprAirBomb - (FileName: 'Airplane'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 254; Height: 101; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprAirplane - (FileName: 'amAirplane'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 64; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprAmAirplane - (FileName: 'amGirder'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 160; Height:160; imageWidth: 0; imageHeight: 0; saveSurf: true),// sprAmGirder - (FileName: 'hhMask'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: true),// sprHHTelepMask - (FileName: 'Switch'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprSwitch - (FileName: 'Parachute'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 48; Height: 48; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprParachute - (FileName: 'Target'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprTarget - (FileName: 'RopeNode'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 6; Height: 6; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprRopeNode - (FileName: 'thinking'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprQuestion - (FileName: 'PowerBar'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 256; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprPowerBar - (FileName: 'WindBar'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 151; Height: 17; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprWindBar - (FileName: 'WindL'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 80; Height: 13; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprWindL - (FileName: 'WindR'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 80; Height: 13; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprWindR - (FileName: 'Flake'; Path:ptCurrTheme; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprFlake - (FileName: 'amRope'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHandRope - (FileName: 'amBazooka'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHandBazooka - (FileName: 'amShotgun'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHandShotgun - (FileName: 'amDEagle'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHandDEagle - (FileName:'amAirAttack'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHandAirAttack - (FileName: 'amBaseball'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHandBaseball - (FileName: 'Hammer'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprPHammer - (FileName: 'amBTorch_i'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHandBlowTorch - (FileName: 'amBTorch_w'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprBlowTorch - (FileName: 'Teleport'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 64; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprTeleport - (FileName: 'HHDeath'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHHDeath - (FileName:'amShotgun_w'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprShotgun - (FileName: 'amDEagle_w'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprDEagle - (FileName: 'Idle'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHHIdle - (FileName: 'Mortar'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprMortar - (FileName: 'TurnsLeft'; Path: ptAmmoMenu; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprTurnsLeft - (FileName: 'amKamikaze'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 256; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprKamikaze - (FileName: 'amWhip'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 128; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprWhip - (FileName: 'Kowtow'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprKowtow - (FileName: 'Sad'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprSad - (FileName: 'Wave'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 64; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprWave - (FileName: 'Hurrah'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHurrah - (FileName:'ILoveLemonade';Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 128; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprLemonade - (FileName: 'Shrug'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprShrug - (FileName: 'Juggle'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprJuggle - (FileName: 'ExplPart'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprExplPart - (FileName: 'ExplPart2'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprExplPart2 - (FileName: 'Cake_walk'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprCakeWalk - (FileName: 'Cake_down'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprCakeDown - (FileName: 'Ammos_bw'; Path: ptAmmoMenu; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprAMAmmosBW - (FileName: 'Watermelon'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprWatermelon - (FileName: 'EvilTrace'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprEvilTrace - (FileName:'HellishBomb'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHellishBomb - (FileName: 'Seduction'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprSeduction - (FileName: 'HHDress'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprDress - (FileName: 'Censored'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 64; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprCensored - (FileName: 'Drill'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprDrill - (FileName: 'amDrill'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHandDrill - (FileName: 'amBallgun'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHandBallgun - (FileName: 'Balls'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 20; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprBalls - (FileName: 'RCPlane'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprPlane - (FileName: 'amRCPlane'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false), // sprHandPlane - (FileName: 'Utility'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 48; Height: 48; imageWidth: 0; imageHeight: 0; saveSurf: false), // sprUtility - (FileName:'Invulnerable';Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 48; Height: 48; imageWidth: 0; imageHeight: 0; saveSurf: false), // sprInvulnerable - (FileName: 'Vampiric'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 48; Height: 48; imageWidth: 0; imageHeight: 0; saveSurf: false), // sprVampiric - (FileName: 'amGirder'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 512; Height:512; imageWidth: 0; imageHeight: 0; saveSurf: false), // sprGirder - (FileName:'SpeechCorner';Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 12; Height: 9; imageWidth: 0; imageHeight: 0; saveSurf: true), // sprSpeechCorner - (FileName: 'SpeechEdge'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 25; Height: 9; imageWidth: 0; imageHeight: 0; saveSurf: true), // sprSpeechEdge - (FileName: 'SpeechTail'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 25; Height: 26; imageWidth: 0; imageHeight: 0; saveSurf: true), // sprSpeechTail - (FileName:'ThoughtCorner';Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 49; Height: 37; imageWidth: 0; imageHeight: 0; saveSurf: true), // sprThoughtCorner - (FileName:'ThoughtEdge'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 23; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: true), // sprThoughtEdge - (FileName:'ThoughtTail'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 45; Height: 65; imageWidth: 0; imageHeight: 0; saveSurf: true), // sprThoughtTail - (FileName:'ShoutCorner'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 34; Height: 23; imageWidth: 0; imageHeight: 0; saveSurf: true), // sprShoutCorner - (FileName: 'ShoutEdge'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 30; Height: 20; imageWidth: 0; imageHeight: 0; saveSurf: true), // sprShoutEdge - (FileName: 'ShoutTail'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 30; Height: 37; imageWidth: 0; imageHeight: 0; saveSurf: true), // sprShoutTail - (FileName:'amSniperRifle';Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 128; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false), // sprSniperRifle - (FileName: 'Bubbles'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false), // sprBubbles - (FileName: 'amJetpack'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false), // sprJetpack - (FileName: 'Health'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false), // sprHealth - (FileName: 'amMolotov'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false), //sprHandMolotov - (FileName: 'Molotov'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false), // sprMolotov - (FileName: 'Smoke'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 22; Height: 22; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprSmoke - (FileName: 'SmokeWhite'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 22; Height: 22; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprSmokeWhite - (FileName: 'Shells'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 8; Height: 8; imageWidth: 0; imageHeight: 0; saveSurf: false), // sprShell - (FileName: 'Dust'; Path: ptCurrTheme; AltPath: ptGraphics; Texture: nil; Surface: nil; - Width: 22; Height: 22; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprDust - (FileName: 'Explosives'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 48; Height: 48; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprExplosives - (FileName: 'ExplosivesRoll'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 48; Height: 48; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprExplosivesRoll - (FileName: 'amTeleport'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; - Width: 64; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false) // sprAmTeleport - ); + SpritesData: array[TSprite] of record + FileName: String[14]; + Path, AltPath: TPathType; + Texture: PTexture; + Surface: PSDL_Surface; + Width, Height, imageWidth, imageHeight: LongInt; + saveSurf: boolean; + end = ( + (FileName: 'BlueWater'; Path: ptCurrTheme;AltPath: ptGraphics; Texture: nil; Surface: nil; + Width: 0; Height: 0; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprWater + (FileName: 'Clouds'; Path: ptCurrTheme;AltPath: ptGraphics; Texture: nil; Surface: nil; + Width: 256; Height:128; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprCloud + (FileName: 'Bomb'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 8; Height: 8; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprBomb + (FileName: 'BigDigits'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprBigDigit + (FileName: 'Frame'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 4; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprFrame + (FileName: 'Lag'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 65; Height: 65; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprLag + (FileName: 'Arrow'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprCursor + (FileName: 'Grenade'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprGrenade + (FileName: 'Targetp'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprTargetP + (FileName: 'UFO'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprUFO + (FileName: 'SmokeTrace'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprSmokeTrace + (FileName: 'RopeHook'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprRopeHook + (FileName: 'Expl50'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprExplosion50 + (FileName: 'MineOff'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 8; Height: 8; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprMineOff + (FileName: 'MineOn'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 8; Height: 8; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprMineOn + (FileName: 'MineDead'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 8; Height: 8; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprMineDead + (FileName: 'Case'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 48; Height: 48; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprCase + (FileName: 'FirstAid'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 48; Height: 48; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprFAid + (FileName: 'dynamite'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprDynamite + (FileName: 'Power'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprPower + (FileName: 'ClBomb'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprClusterBomb + (FileName: 'ClParticle'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprClusterParticle + (FileName: 'Flame'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprFlame + (FileName: 'horizont'; Path: ptCurrTheme;AltPath: ptNone; Texture: nil; Surface: nil; + Width: 0; Height: 0; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHorizont + (FileName: 'horizontL'; Path: ptCurrTheme;AltPath: ptNone; Texture: nil; Surface: nil; + Width: 0; Height: 0; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHorizont + (FileName: 'horizontR'; Path: ptCurrTheme;AltPath: ptNone; Texture: nil; Surface: nil; + Width: 0; Height: 0; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHorizont + (FileName: 'Sky'; Path: ptCurrTheme;AltPath: ptNone; Texture: nil; Surface: nil; + Width: 0; Height: 0; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprSky + (FileName: 'SkyL'; Path: ptCurrTheme;AltPath: ptNone; Texture: nil; Surface: nil; + Width: 0; Height: 0; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprSky + (FileName: 'SkyR'; Path: ptCurrTheme;AltPath: ptNone; Texture: nil; Surface: nil; + Width: 0; Height: 0; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprSky + (FileName: 'BrdrLines'; Path: ptAmmoMenu; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 202; Height: 1; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprAMBorders + (FileName: 'Slot'; Path: ptAmmoMenu; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 202; Height: 33; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprAMSlot + (FileName: 'AmmoName'; Path: ptAmmoMenu; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 202; Height: 33; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprAMSlotName + (FileName: 'Ammos'; Path: ptAmmoMenu; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: true),// sprAMAmmos + (FileName: 'SlotKeys'; Path: ptAmmoMenu; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprAMSlotKeys + (FileName: 'Selection'; Path: ptAmmoMenu; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprAMSelection + (FileName: 'Finger'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 48; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprFinger + (FileName: 'AirBomb'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprAirBomb + (FileName: 'Airplane'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 254; Height: 101; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprAirplane + (FileName: 'amAirplane'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 64; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprAmAirplane + (FileName: 'amGirder'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 160; Height:160; imageWidth: 0; imageHeight: 0; saveSurf: true),// sprAmGirder + (FileName: 'hhMask'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: true),// sprHHTelepMask + (FileName: 'Switch'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprSwitch + (FileName: 'Parachute'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 48; Height: 48; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprParachute + (FileName: 'Target'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprTarget + (FileName: 'RopeNode'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 6; Height: 6; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprRopeNode + (FileName: 'thinking'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprQuestion + (FileName: 'PowerBar'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 256; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprPowerBar + (FileName: 'WindBar'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 151; Height: 17; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprWindBar + (FileName: 'WindL'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 80; Height: 13; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprWindL + (FileName: 'WindR'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 80; Height: 13; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprWindR + (FileName: 'Flake'; Path:ptCurrTheme; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprFlake + (FileName: 'amRope'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHandRope + (FileName: 'amBazooka'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHandBazooka + (FileName: 'amShotgun'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHandShotgun + (FileName: 'amDEagle'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHandDEagle + (FileName:'amAirAttack'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHandAirAttack + (FileName: 'amBaseball'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHandBaseball + (FileName: 'Hammer'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprPHammer + (FileName: 'amBTorch_i'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHandBlowTorch + (FileName: 'amBTorch_w'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprBlowTorch + (FileName: 'Teleport'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 64; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprTeleport + (FileName: 'HHDeath'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHHDeath + (FileName:'amShotgun_w'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprShotgun + (FileName: 'amDEagle_w'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprDEagle + (FileName: 'Idle'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHHIdle + (FileName: 'Mortar'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprMortar + (FileName: 'TurnsLeft'; Path: ptAmmoMenu; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprTurnsLeft + (FileName: 'amKamikaze'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 256; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprKamikaze + (FileName: 'amWhip'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 128; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprWhip + (FileName: 'Kowtow'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprKowtow + (FileName: 'Sad'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprSad + (FileName: 'Wave'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 64; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprWave + (FileName: 'Hurrah'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHurrah + (FileName:'ILoveLemonade';Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 128; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprLemonade + (FileName: 'Shrug'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprShrug + (FileName: 'Juggle'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprJuggle + (FileName: 'ExplPart'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprExplPart + (FileName: 'ExplPart2'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprExplPart2 + (FileName: 'Cake_walk'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprCakeWalk + (FileName: 'Cake_down'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprCakeDown + (FileName: 'Ammos_bw'; Path: ptAmmoMenu; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprAMAmmosBW + (FileName: 'Watermelon'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprWatermelon + (FileName: 'EvilTrace'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprEvilTrace + (FileName:'HellishBomb'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHellishBomb + (FileName: 'Seduction'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprSeduction + (FileName: 'HHDress'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprDress + (FileName: 'Censored'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 64; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprCensored + (FileName: 'Drill'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprDrill + (FileName: 'amDrill'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHandDrill + (FileName: 'amBallgun'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprHandBallgun + (FileName: 'Balls'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 20; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprBalls + (FileName: 'RCPlane'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprPlane + (FileName: 'amRCPlane'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false), // sprHandPlane + (FileName: 'Utility'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 48; Height: 48; imageWidth: 0; imageHeight: 0; saveSurf: false), // sprUtility + (FileName:'Invulnerable';Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 48; Height: 48; imageWidth: 0; imageHeight: 0; saveSurf: false), // sprInvulnerable + (FileName: 'Vampiric'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 48; Height: 48; imageWidth: 0; imageHeight: 0; saveSurf: false), // sprVampiric + (FileName: 'amGirder'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 512; Height:512; imageWidth: 0; imageHeight: 0; saveSurf: false), // sprGirder + (FileName:'SpeechCorner';Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 12; Height: 9; imageWidth: 0; imageHeight: 0; saveSurf: true), // sprSpeechCorner + (FileName: 'SpeechEdge'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 25; Height: 9; imageWidth: 0; imageHeight: 0; saveSurf: true), // sprSpeechEdge + (FileName: 'SpeechTail'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 25; Height: 26; imageWidth: 0; imageHeight: 0; saveSurf: true), // sprSpeechTail + (FileName:'ThoughtCorner';Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 49; Height: 37; imageWidth: 0; imageHeight: 0; saveSurf: true), // sprThoughtCorner + (FileName:'ThoughtEdge'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 23; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: true), // sprThoughtEdge + (FileName:'ThoughtTail'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 45; Height: 65; imageWidth: 0; imageHeight: 0; saveSurf: true), // sprThoughtTail + (FileName:'ShoutCorner'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 34; Height: 23; imageWidth: 0; imageHeight: 0; saveSurf: true), // sprShoutCorner + (FileName: 'ShoutEdge'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 30; Height: 20; imageWidth: 0; imageHeight: 0; saveSurf: true), // sprShoutEdge + (FileName: 'ShoutTail'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 30; Height: 37; imageWidth: 0; imageHeight: 0; saveSurf: true), // sprShoutTail + (FileName:'amSniperRifle';Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 128; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false), // sprSniperRifle + (FileName: 'Bubbles'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false), // sprBubbles + (FileName: 'amJetpack'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false), // sprJetpack + (FileName: 'Health'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false), // sprHealth + (FileName: 'amMolotov'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false), //sprHandMolotov + (FileName: 'Molotov'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false), // sprMolotov + (FileName: 'Smoke'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 22; Height: 22; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprSmoke + (FileName: 'SmokeWhite'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 22; Height: 22; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprSmokeWhite + (FileName: 'Shells'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 8; Height: 8; imageWidth: 0; imageHeight: 0; saveSurf: false), // sprShell + (FileName: 'Dust'; Path: ptCurrTheme; AltPath: ptGraphics; Texture: nil; Surface: nil; + Width: 22; Height: 22; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprDust + (FileName: 'Explosives'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 48; Height: 48; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprExplosives + (FileName: 'ExplosivesRoll'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 48; Height: 48; imageWidth: 0; imageHeight: 0; saveSurf: false),// sprExplosivesRoll + (FileName: 'amTeleport'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; + Width: 64; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false) // sprAmTeleport + ); - Wavez: array [TWave] of record - Sprite: TSprite; - FramesCount: Longword; - Interval: Longword; - cmd: String[20]; - Voice: TSound; - VoiceDelay: LongWord; - end = ( - (Sprite: sprKowtow; FramesCount: 12; Interval: 125; cmd: '/rollup'; Voice: sndNone; VoiceDelay: 0), - (Sprite: sprSad; FramesCount: 14; Interval: 125; cmd: '/sad'; Voice: sndNone; VoiceDelay: 0), - (Sprite: sprWave; FramesCount: 16; Interval: 125; cmd: '/wave'; Voice: sndHello; VoiceDelay: 5), - (Sprite: sprHurrah; FramesCount: 14; Interval: 125; cmd: '/hurrah'; Voice: sndNone; VoiceDelay: 0), - (Sprite: sprLemonade; FramesCount: 24; Interval: 125; cmd: '/ilovelotsoflemonade'; Voice: sndNone; VoiceDelay: 0), - (Sprite: sprShrug; FramesCount: 24; Interval: 125; cmd: '/shrug'; Voice: sndNone; VoiceDelay: 0), - (Sprite: sprJuggle; FramesCount: 49; Interval: 38; cmd: '/juggle'; Voice: sndNone; VoiceDelay: 0) - ); + Wavez: array [TWave] of record + Sprite: TSprite; + FramesCount: Longword; + Interval: Longword; + cmd: String[20]; + Voice: TSound; + VoiceDelay: LongWord; + end = ( + (Sprite: sprKowtow; FramesCount: 12; Interval: 125; cmd: '/rollup'; Voice: sndNone; VoiceDelay: 0), + (Sprite: sprSad; FramesCount: 14; Interval: 125; cmd: '/sad'; Voice: sndNone; VoiceDelay: 0), + (Sprite: sprWave; FramesCount: 16; Interval: 125; cmd: '/wave'; Voice: sndHello; VoiceDelay: 5), + (Sprite: sprHurrah; FramesCount: 14; Interval: 125; cmd: '/hurrah'; Voice: sndNone; VoiceDelay: 0), + (Sprite: sprLemonade; FramesCount: 24; Interval: 125; cmd: '/ilovelotsoflemonade'; Voice: sndNone; VoiceDelay: 0), + (Sprite: sprShrug; FramesCount: 24; Interval: 125; cmd: '/shrug'; Voice: sndNone; VoiceDelay: 0), + (Sprite: sprJuggle; FramesCount: 49; Interval: 38; cmd: '/juggle'; Voice: sndNone; VoiceDelay: 0) + ); - Soundz: array[TSound] of record - FileName: String[25]; - Path : TPathType; - end = ( - (FileName: ''; Path: ptNone ),// sndNone - (FileName: 'grenadeimpact.ogg'; Path: ptSounds),// sndGrenadeImpact - (FileName: 'explosion.ogg'; Path: ptSounds),// sndExplosion - (FileName: 'throwpowerup.ogg'; Path: ptSounds),// sndThrowPowerUp - (FileName: 'throwrelease.ogg'; Path: ptSounds),// sndThrowRelease - (FileName: 'splash.ogg'; Path: ptSounds),// sndSplash - (FileName: 'shotgunreload.ogg'; Path: ptSounds),// sndShotgunReload - (FileName: 'shotgunfire.ogg'; Path: ptSounds),// sndShotgunFire - (FileName: 'graveimpact.ogg'; Path: ptSounds),// sndGraveImpact - (FileName: 'minetick.ogg'; Path: ptSounds),// sndMineTicks - (FileName: 'pickhammer.ogg'; Path: ptSounds),// sndPickhammer - (FileName: 'gun.ogg'; Path: ptSounds),// sndGun - (FileName: 'ufo.ogg'; Path: ptSounds),// sndUFO - (FileName: 'Jump1.ogg'; Path: ptVoices),// sndJump1 - (FileName: 'Jump2.ogg'; Path: ptVoices),// sndJump2 - (FileName: 'Jump3.ogg'; Path: ptVoices),// sndJump3 - (FileName: 'Yessir.ogg'; Path: ptVoices),// sndYesSir - (FileName: 'Laugh.ogg'; Path: ptVoices),// sndLaugh - (FileName: 'Illgetyou.ogg'; Path: ptVoices),// sndIllGetYou - (FileName: 'Incoming.ogg'; Path: ptVoices),// sndIncoming - (FileName: 'Missed.ogg'; Path: ptVoices),// sndMissed - (FileName: 'Stupid.ogg'; Path: ptVoices),// sndStupid - (FileName: 'Firstblood.ogg'; Path: ptVoices),// sndFirstBlood - (FileName: 'Boring.ogg'; Path: ptVoices),// sndBoring - (FileName: 'Byebye.ogg'; Path: ptVoices),// sndByeBye - (FileName: 'Sameteam.ogg'; Path: ptVoices),// sndSameTeam - (FileName: 'Nutter.ogg'; Path: ptVoices),// sndNutter - (FileName: 'Reinforcements.ogg'; Path: ptVoices),// sndReinforce - (FileName: 'Traitor.ogg'; Path: ptVoices),// sndTraitor - (FileName: 'Youllregretthat.ogg'; Path: ptVoices),// sndRegret - (FileName: 'Enemydown.ogg'; Path: ptVoices),// sndEnemyDown - (FileName: 'Coward.ogg'; Path: ptVoices),// sndCoward - (FileName: 'Hurry.ogg'; Path: ptVoices),// sndHurry - (FileName: 'Watchit.ogg'; Path: ptVoices),// sndWatchIt - (FileName: 'Kamikaze.ogg'; Path: ptVoices),// sndKamikaze - (FileName: 'cake2.ogg'; Path: ptSounds),// sndCake - (FileName: 'Ow1.ogg'; Path: ptVoices),// sndOw1 - (FileName: 'Ow4.ogg'; Path: ptVoices),// sndOw4 - (FileName: 'Firepunch1.ogg'; Path: ptVoices),// sndFirepunch1 - (FileName: 'Firepunch2.ogg'; Path: ptVoices),// sndFirepunch2 - (FileName: 'Firepunch3.ogg'; Path: ptVoices),// sndFirepunch3 - (FileName: 'Firepunch4.ogg'; Path: ptVoices),// sndFirepunch4 - (FileName: 'Firepunch5.ogg'; Path: ptVoices),// sndFirepunch5 - (FileName: 'Firepunch6.ogg'; Path: ptVoices),// sndFirepunch6 - (FileName: 'Melon.ogg'; Path: ptSounds),// sndMelon - (FileName: 'Hellish.ogg'; Path: ptSounds),// sndHellish - (FileName: 'Yoohoo.ogg'; Path: ptSounds),// sndYoohoo - (FileName: 'rcplane.ogg'; Path: ptSounds),// sndRCPlane - (FileName: 'whipcrack.ogg'; Path: ptSounds),// sndWhipCrack - (FileName:'ride_of_the_valkyries.ogg'; Path: ptSounds),// sndRideOfTheValkyries - (FileName: 'denied.ogg'; Path: ptSounds),// sndDenied - (FileName: 'placed.ogg'; Path: ptSounds),// sndPlaced - (FileName: 'baseballbat.ogg'; Path: ptSounds),// sndBaseballBat - (FileName: 'steam.ogg'; Path: ptSounds),// sndVaporize - (FileName: 'warp.ogg'; Path: ptSounds),// sndWarp - (FileName: 'suddendeath.ogg'; Path: ptSounds),// sndSuddenDeath - (FileName: 'mortar.ogg'; Path: ptSounds),// sndMortar - (FileName: 'shutterclick.ogg'; Path: ptSounds),// sndShutter - (FileName: 'homerun.ogg'; Path: ptSounds),// sndHomerun - (FileName: 'molotov.ogg'; Path: ptSounds),// sndMolotov - (FileName: 'Takecover.ogg'; Path: ptVoices),// sndCover - (FileName: 'Uh-oh.ogg'; Path: ptVoices),// sndUhOh - (FileName: 'Oops.ogg'; Path: ptVoices),// sndOops - (FileName: 'Nooo.ogg'; Path: ptVoices),// sndNooo - (FileName: 'Hello.ogg'; Path: ptVoices),// sndHello - (FileName: ''; Path: ptSounds),// sndRopeShot - (FileName: ''; Path: ptSounds),// sndRopeAttach - (FileName: ''; Path: ptSounds),// sndRopeRelease - (FileName: 'switchhog.ogg'; Path: ptSounds),// sndSwitchHog - (FileName: 'victory.ogg'; Path: ptVoices),// sndVictory - (FileName: 'sniperreload.ogg'; Path: ptSounds),// sndSniperReload - (FileName: 'steps.ogg'; Path: ptSounds),// sndSteps - (FileName: 'lowgravity.ogg'; Path: ptSounds) // sndLowGravity - ); + Soundz: array[TSound] of record + FileName: String[25]; + Path : TPathType; + end = ( + (FileName: ''; Path: ptNone ),// sndNone + (FileName: 'grenadeimpact.ogg'; Path: ptSounds),// sndGrenadeImpact + (FileName: 'explosion.ogg'; Path: ptSounds),// sndExplosion + (FileName: 'throwpowerup.ogg'; Path: ptSounds),// sndThrowPowerUp + (FileName: 'throwrelease.ogg'; Path: ptSounds),// sndThrowRelease + (FileName: 'splash.ogg'; Path: ptSounds),// sndSplash + (FileName: 'shotgunreload.ogg'; Path: ptSounds),// sndShotgunReload + (FileName: 'shotgunfire.ogg'; Path: ptSounds),// sndShotgunFire + (FileName: 'graveimpact.ogg'; Path: ptSounds),// sndGraveImpact + (FileName: 'minetick.ogg'; Path: ptSounds),// sndMineTicks + (FileName: 'pickhammer.ogg'; Path: ptSounds),// sndPickhammer + (FileName: 'gun.ogg'; Path: ptSounds),// sndGun + (FileName: 'ufo.ogg'; Path: ptSounds),// sndUFO + (FileName: 'Jump1.ogg'; Path: ptVoices),// sndJump1 + (FileName: 'Jump2.ogg'; Path: ptVoices),// sndJump2 + (FileName: 'Jump3.ogg'; Path: ptVoices),// sndJump3 + (FileName: 'Yessir.ogg'; Path: ptVoices),// sndYesSir + (FileName: 'Laugh.ogg'; Path: ptVoices),// sndLaugh + (FileName: 'Illgetyou.ogg'; Path: ptVoices),// sndIllGetYou + (FileName: 'Incoming.ogg'; Path: ptVoices),// sndIncoming + (FileName: 'Missed.ogg'; Path: ptVoices),// sndMissed + (FileName: 'Stupid.ogg'; Path: ptVoices),// sndStupid + (FileName: 'Firstblood.ogg'; Path: ptVoices),// sndFirstBlood + (FileName: 'Boring.ogg'; Path: ptVoices),// sndBoring + (FileName: 'Byebye.ogg'; Path: ptVoices),// sndByeBye + (FileName: 'Sameteam.ogg'; Path: ptVoices),// sndSameTeam + (FileName: 'Nutter.ogg'; Path: ptVoices),// sndNutter + (FileName: 'Reinforcements.ogg'; Path: ptVoices),// sndReinforce + (FileName: 'Traitor.ogg'; Path: ptVoices),// sndTraitor + (FileName: 'Youllregretthat.ogg'; Path: ptVoices),// sndRegret + (FileName: 'Enemydown.ogg'; Path: ptVoices),// sndEnemyDown + (FileName: 'Coward.ogg'; Path: ptVoices),// sndCoward + (FileName: 'Hurry.ogg'; Path: ptVoices),// sndHurry + (FileName: 'Watchit.ogg'; Path: ptVoices),// sndWatchIt + (FileName: 'Kamikaze.ogg'; Path: ptVoices),// sndKamikaze + (FileName: 'cake2.ogg'; Path: ptSounds),// sndCake + (FileName: 'Ow1.ogg'; Path: ptVoices),// sndOw1 + (FileName: 'Ow4.ogg'; Path: ptVoices),// sndOw4 + (FileName: 'Firepunch1.ogg'; Path: ptVoices),// sndFirepunch1 + (FileName: 'Firepunch2.ogg'; Path: ptVoices),// sndFirepunch2 + (FileName: 'Firepunch3.ogg'; Path: ptVoices),// sndFirepunch3 + (FileName: 'Firepunch4.ogg'; Path: ptVoices),// sndFirepunch4 + (FileName: 'Firepunch5.ogg'; Path: ptVoices),// sndFirepunch5 + (FileName: 'Firepunch6.ogg'; Path: ptVoices),// sndFirepunch6 + (FileName: 'Melon.ogg'; Path: ptSounds),// sndMelon + (FileName: 'Hellish.ogg'; Path: ptSounds),// sndHellish + (FileName: 'Yoohoo.ogg'; Path: ptSounds),// sndYoohoo + (FileName: 'rcplane.ogg'; Path: ptSounds),// sndRCPlane + (FileName: 'whipcrack.ogg'; Path: ptSounds),// sndWhipCrack + (FileName:'ride_of_the_valkyries.ogg'; Path: ptSounds),// sndRideOfTheValkyries + (FileName: 'denied.ogg'; Path: ptSounds),// sndDenied + (FileName: 'placed.ogg'; Path: ptSounds),// sndPlaced + (FileName: 'baseballbat.ogg'; Path: ptSounds),// sndBaseballBat + (FileName: 'steam.ogg'; Path: ptSounds),// sndVaporize + (FileName: 'warp.ogg'; Path: ptSounds),// sndWarp + (FileName: 'suddendeath.ogg'; Path: ptSounds),// sndSuddenDeath + (FileName: 'mortar.ogg'; Path: ptSounds),// sndMortar + (FileName: 'shutterclick.ogg'; Path: ptSounds),// sndShutter + (FileName: 'homerun.ogg'; Path: ptSounds),// sndHomerun + (FileName: 'molotov.ogg'; Path: ptSounds),// sndMolotov + (FileName: 'Takecover.ogg'; Path: ptVoices),// sndCover + (FileName: 'Uh-oh.ogg'; Path: ptVoices),// sndUhOh + (FileName: 'Oops.ogg'; Path: ptVoices),// sndOops + (FileName: 'Nooo.ogg'; Path: ptVoices),// sndNooo + (FileName: 'Hello.ogg'; Path: ptVoices),// sndHello + (FileName: ''; Path: ptSounds),// sndRopeShot + (FileName: ''; Path: ptSounds),// sndRopeAttach + (FileName: ''; Path: ptSounds),// sndRopeRelease + (FileName: 'switchhog.ogg'; Path: ptSounds),// sndSwitchHog + (FileName: 'victory.ogg'; Path: ptVoices),// sndVictory + (FileName: 'sniperreload.ogg'; Path: ptSounds),// sndSniperReload + (FileName: 'steps.ogg'; Path: ptSounds),// sndSteps + (FileName: 'lowgravity.ogg'; Path: ptSounds) // sndLowGravity + ); - Ammoz: array [TAmmoType] of record - NameId: TAmmoStrId; - NameTex: PTexture; - Probability, NumberInCase: Longword; - Ammo: TAmmo; - Slot: 0..cMaxSlotIndex; - TimeAfterTurn: Longword; - minAngle, maxAngle: Longword; - isDamaging: boolean; - SkipTurns: Longword; - PosCount: Longword; - PosSprite: TSprite; - end = ( - (NameId: sidNothing; - NameTex: nil; - Probability: 0; - NumberInCase: 0; - Ammo: (Propz: ammoprop_NoCrosshair or ammoprop_DontHold or ammoprop_Utility; - Count: AMMO_INFINITE; - InitialCount: AMMO_INFINITE; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amNothing; - AttackVoice: sndNone); - Slot: 0; - TimeAfterTurn: 0; - minAngle: 0; - maxAngle: 0; - isDamaging: false; - SkipTurns: 9999; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidGrenade; - NameTex: nil; - Probability: 0; - NumberInCase: 1; - Ammo: (Propz: ammoprop_Timerable or ammoprop_Power or ammoprop_AltUse; - Count: AMMO_INFINITE; - InitialCount: AMMO_INFINITE; - NumPerTurn: 0; - Timer: 3000; - Pos: 0; - AmmoType: amGrenade; - AttackVoice: sndCover); - Slot: 1; - TimeAfterTurn: 3000; - minAngle: 0; - maxAngle: 0; - isDamaging: true; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidClusterBomb; - NameTex: nil; - Probability: 100; - NumberInCase: 3; - Ammo: (Propz: ammoprop_Timerable or ammoprop_Power or ammoprop_AltUse; - Count: 5; - InitialCount: 5; - NumPerTurn: 0; - Timer: 3000; - Pos: 0; - AmmoType: amClusterBomb; - AttackVoice: sndCover); - Slot: 1; - TimeAfterTurn: 3000; - minAngle: 0; - maxAngle: 0; - isDamaging: true; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidBazooka; - NameTex: nil; - Probability: 0; - NumberInCase: 1; - Ammo: (Propz: ammoprop_Power or ammoprop_AltUse; - Count: AMMO_INFINITE; - InitialCount: AMMO_INFINITE; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amBazooka; - AttackVoice: sndNone); - Slot: 0; - TimeAfterTurn: 3000; - minAngle: 0; - maxAngle: 0; - isDamaging: true; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidUFO; - NameTex: nil; - Probability: 100; - NumberInCase: 1; - Ammo: (Propz: ammoprop_Power or ammoprop_NeedTarget or ammoprop_DontHold; - Count: 2; - InitialCount: 2; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amUFO; - AttackVoice: sndNone); - Slot: 0; - TimeAfterTurn: 3000; - minAngle: 0; - maxAngle: 0; - isDamaging: true; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidShotgun; - NameTex: nil; - Probability: 0; - NumberInCase: 1; - Ammo: (Propz: ammoprop_ForwMsgs; - Count: AMMO_INFINITE; - InitialCount: AMMO_INFINITE; - NumPerTurn: 1; - Timer: 0; - Pos: 0; - AmmoType: amShotgun; - AttackVoice: sndNone); - Slot: 2; - TimeAfterTurn: 3000; - minAngle: 0; - maxAngle: 0; - isDamaging: true; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidPickHammer; - NameTex: nil; - Probability: 0; - NumberInCase: 1; - Ammo: (Propz: ammoprop_ForwMsgs or ammoprop_AttackInMove or ammoprop_NoCrosshair or ammoprop_DontHold; - Count: 2; - InitialCount: 2; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amPickHammer; - AttackVoice: sndNone); - Slot: 6; - TimeAfterTurn: 0; - minAngle: 0; - maxAngle: 0; - isDamaging: false; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidSkip; - NameTex: nil; - Probability: 0; - NumberInCase: 1; - Ammo: (Propz: ammoprop_NoCrosshair or ammoprop_DontHold; - Count: AMMO_INFINITE; - InitialCount: AMMO_INFINITE; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amSkip; - AttackVoice: sndNone); - Slot: 8; - TimeAfterTurn: 0; - minAngle: 0; - maxAngle: 0; - isDamaging: false; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidRope; - NameTex: nil; - Probability: 100; - NumberInCase: 3; - Ammo: (Propz: ammoprop_NoRoundEndHint or - ammoprop_ForwMsgs or - ammoprop_AttackInMove or - ammoprop_AltAttack; - Count: 5; - InitialCount: 5; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amRope; - AttackVoice: sndNone); - Slot: 7; - TimeAfterTurn: 0; - minAngle: 0; - maxAngle: cMaxAngle div 2; - isDamaging: false; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidMine; - NameTex: nil; - Probability: 100; - NumberInCase: 1; - Ammo: (Propz: ammoprop_NoCrosshair or ammoprop_AttackInMove or ammoprop_DontHold or ammoprop_AltUse; - Count: 2; - InitialCount: 2; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amMine; - AttackVoice: sndLaugh); - Slot: 4; - TimeAfterTurn: 5000; - minAngle: 0; - maxAngle: 0; - isDamaging: true; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidDEagle; - NameTex: nil; - Probability: 20; - NumberInCase: 2; - Ammo: (Propz: 0; - Count: 3; - InitialCount: 3; - NumPerTurn: 3; - Timer: 0; - Pos: 0; - AmmoType: amDEagle; - AttackVoice: sndNone); - Slot: 2; - TimeAfterTurn: 3000; - minAngle: 0; - maxAngle: 0; - isDamaging: true; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidDynamite; - NameTex: nil; - Probability: 100; - NumberInCase: 1; - Ammo: (Propz: ammoprop_NoCrosshair or ammoprop_AttackInMove or ammoprop_DontHold or ammoprop_AltUse; - Count: 1; - InitialCount: 1; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amDynamite; - AttackVoice: sndLaugh); - Slot: 4; - TimeAfterTurn: 5000; - minAngle: 0; - maxAngle: 0; - isDamaging: true; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidFirePunch; - NameTex: nil; - Probability: 0; - NumberInCase: 1; - Ammo: (Propz: ammoprop_NoCrosshair or ammoprop_ForwMsgs or ammoprop_AttackInMove; - Count: AMMO_INFINITE; - InitialCount: AMMO_INFINITE; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amFirePunch; - AttackVoice: sndNone); - Slot: 3; - TimeAfterTurn: 3000; - MinAngle: 0; - maxAngle: 0; - isDamaging: true; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidWhip; - NameTex: nil; - Probability: 0; - NumberInCase: 1; - Ammo: (Propz: ammoprop_NoCrosshair; - Count: AMMO_INFINITE; - InitialCount: AMMO_INFINITE; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amWhip; - AttackVoice: sndNone); - Slot: 3; - TimeAfterTurn: 3000; - MinAngle: 0; - maxAngle: 0; - isDamaging: true; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidBaseballBat; - NameTex: nil; - Probability: 100; - NumberInCase: 1; - Ammo: (Propz: ammoprop_DontHold; - Count: 1; - InitialCount: 1; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amBaseballBat; - AttackVoice: sndNone); - Slot: 3; - TimeAfterTurn: 5000; - minAngle: 0; - maxAngle: cMaxAngle div 2; - isDamaging: true; - SkipTurns: 2; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidParachute; - NameTex: nil; - Probability: 100; - NumberInCase: 1; - Ammo: (Propz: ammoprop_NoRoundEndHint or - ammoprop_ForwMsgs or - ammoprop_AttackInMove or - ammoprop_NoCrosshair or - ammoprop_DontHold or - ammoprop_AltAttack; - Count: 2; - InitialCount: 2; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amParachute; - AttackVoice: sndNone); - Slot: 7; - TimeAfterTurn: 0; - minAngle: 0; - maxAngle: 0; - isDamaging: false; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidAirAttack; - NameTex: nil; - Probability: 100; - NumberInCase: 1; - Ammo: (Propz: ammoprop_NoCrosshair or - ammoprop_NeedTarget or - ammoprop_AttackingPut or - ammoprop_DontHold or - ammoprop_NotBorder; - Count: 1; - InitialCount: 1; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amAirAttack; - AttackVoice: sndIncoming); - Slot: 5; - TimeAfterTurn: 0; - minAngle: 0; - maxAngle: 0; - isDamaging: true; - SkipTurns: 5; - PosCount: 2; - PosSprite: sprAmAirplane), - (NameId: sidMineStrike; - NameTex: nil; - Probability: 200; - NumberInCase: 1; - Ammo: (Propz: ammoprop_NoCrosshair or - ammoprop_NeedTarget or - ammoprop_AttackingPut or - ammoprop_DontHold or - ammoprop_NotBorder; - Count: 1; - InitialCount: 1; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amMineStrike; - AttackVoice: sndNone); - Slot: 5; - TimeAfterTurn: 0; - minAngle: 0; - maxAngle: 0; - isDamaging: true; - SkipTurns: 5; - PosCount: 2; - PosSprite: sprAmAirplane), - (NameId: sidBlowTorch; - NameTex: nil; - Probability: 100; - NumberInCase: 2; - Ammo: (Propz: ammoprop_ForwMsgs; - Count: 1; - InitialCount: 1; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amBlowTorch; - AttackVoice: sndNone); - Slot: 6; - TimeAfterTurn: 3000; - minAngle: 768; - maxAngle: 1280; - isDamaging: false; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidGirder; - NameTex: nil; - Probability: 150; - NumberInCase: 3; - Ammo: (Propz: ammoprop_NoRoundEndHint or - ammoprop_NoCrosshair or - ammoprop_NeedTarget or - ammoprop_AttackingPut; - Count: 1; - InitialCount: 1; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amGirder; - AttackVoice: sndNone); - Slot: 6; - TimeAfterTurn: 3000; - minAngle: 0; - maxAngle: 0; - isDamaging: false; - SkipTurns: 0; - PosCount: 8; - PosSprite: sprAmGirder), - (NameId: sidTeleport; - NameTex: nil; - Probability: 200; - NumberInCase: 1; - Ammo: (Propz: ammoprop_ForwMsgs or - ammoprop_NoCrosshair or - ammoprop_NeedTarget or - ammoprop_AttackingPut or - ammoprop_DontHold; - Count: 2; - InitialCount: 2; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amTeleport; - AttackVoice: sndNone); - Slot: 7; - TimeAfterTurn: 0; - minAngle: 0; - maxAngle: 0; - isDamaging: false; - SkipTurns: 0; - PosCount: 2; - PosSprite: sprAmTeleport), - (NameId: sidSwitch; - NameTex: nil; - Probability: 100; - NumberInCase: 1; - Ammo: (Propz: ammoprop_NoRoundEndHint or - ammoprop_ForwMsgs or - ammoprop_NoCrosshair or - ammoprop_DontHold; - Count: 3; - InitialCount: 3; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amSwitch; - AttackVoice: sndNone); - Slot: 8; - TimeAfterTurn: 0; - minAngle: 0; - maxAngle: 0; - isDamaging: false; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidMortar; - NameTex: nil; - Probability: 100; - NumberInCase: 4; - Ammo: (Propz: 0; - Count: 4; - InitialCount: 4; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amMortar; - AttackVoice: sndNone); - Slot: 1; - TimeAfterTurn: 3000; - minAngle: 0; - maxAngle: 0; - isDamaging: true; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidKamikaze; - NameTex: nil; - Probability: 100; - NumberInCase: 1; - Ammo: (Propz: ammoprop_ForwMsgs or ammoprop_DontHold or ammoprop_AttackInMove; - Count: 1; - InitialCount: 1; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amKamikaze; - AttackVoice: sndNone); - Slot: 3; - TimeAfterTurn: 0; - minAngle: 0; - maxAngle: 0; - isDamaging: true; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidCake; - NameTex: nil; - Probability: 100; - NumberInCase: 1; - Ammo: (Propz: ammoprop_ForwMsgs or ammoprop_NoCrosshair or ammoprop_DontHold; - Count: 1; - InitialCount: 1; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amCake; - AttackVoice: sndLaugh); - Slot: 4; - TimeAfterTurn: 0; - minAngle: 0; - maxAngle: 0; - isDamaging: true; - SkipTurns: 4; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidSeduction; - NameTex: nil; - Probability: 100; - NumberInCase: 1; - Ammo: (Propz: ammoprop_ForwMsgs or ammoprop_DontHold; - Count: 1; + Ammoz: array [TAmmoType] of record + NameId: TAmmoStrId; + NameTex: PTexture; + Probability, NumberInCase: Longword; + Ammo: TAmmo; + Slot: 0..cMaxSlotIndex; + TimeAfterTurn: Longword; + minAngle, maxAngle: Longword; + isDamaging: boolean; + SkipTurns: Longword; + PosCount: Longword; + PosSprite: TSprite; + end = ( + (NameId: sidNothing; + NameTex: nil; + Probability: 0; + NumberInCase: 0; + Ammo: (Propz: ammoprop_NoCrosshair or ammoprop_DontHold or ammoprop_Utility; + Count: AMMO_INFINITE; + InitialCount: AMMO_INFINITE; + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amNothing; + AttackVoice: sndNone); + Slot: 0; + TimeAfterTurn: 0; + minAngle: 0; + maxAngle: 0; + isDamaging: false; + SkipTurns: 9999; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidGrenade; + NameTex: nil; + Probability: 0; + NumberInCase: 1; + Ammo: (Propz: ammoprop_Timerable or ammoprop_Power or ammoprop_AltUse; + Count: AMMO_INFINITE; + InitialCount: AMMO_INFINITE; + NumPerTurn: 0; + Timer: 3000; + Pos: 0; + AmmoType: amGrenade; + AttackVoice: sndCover); + Slot: 1; + TimeAfterTurn: 3000; + minAngle: 0; + maxAngle: 0; + isDamaging: true; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidClusterBomb; + NameTex: nil; + Probability: 100; + NumberInCase: 3; + Ammo: (Propz: ammoprop_Timerable or ammoprop_Power or ammoprop_AltUse; + Count: 5; + InitialCount: 5; + NumPerTurn: 0; + Timer: 3000; + Pos: 0; + AmmoType: amClusterBomb; + AttackVoice: sndCover); + Slot: 1; + TimeAfterTurn: 3000; + minAngle: 0; + maxAngle: 0; + isDamaging: true; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidBazooka; + NameTex: nil; + Probability: 0; + NumberInCase: 1; + Ammo: (Propz: ammoprop_Power or ammoprop_AltUse; + Count: AMMO_INFINITE; + InitialCount: AMMO_INFINITE; + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amBazooka; + AttackVoice: sndNone); + Slot: 0; + TimeAfterTurn: 3000; + minAngle: 0; + maxAngle: 0; + isDamaging: true; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidUFO; + NameTex: nil; + Probability: 100; + NumberInCase: 1; + Ammo: (Propz: ammoprop_Power or ammoprop_NeedTarget or ammoprop_DontHold; + Count: 2; + InitialCount: 2; + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amUFO; + AttackVoice: sndNone); + Slot: 0; + TimeAfterTurn: 3000; + minAngle: 0; + maxAngle: 0; + isDamaging: true; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidShotgun; + NameTex: nil; + Probability: 0; + NumberInCase: 1; + Ammo: (Propz: ammoprop_ForwMsgs; + Count: AMMO_INFINITE; + InitialCount: AMMO_INFINITE; + NumPerTurn: 1; + Timer: 0; + Pos: 0; + AmmoType: amShotgun; + AttackVoice: sndNone); + Slot: 2; + TimeAfterTurn: 3000; + minAngle: 0; + maxAngle: 0; + isDamaging: true; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidPickHammer; + NameTex: nil; + Probability: 0; + NumberInCase: 1; + Ammo: (Propz: ammoprop_ForwMsgs or ammoprop_AttackInMove or ammoprop_NoCrosshair or ammoprop_DontHold; + Count: 2; + InitialCount: 2; + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amPickHammer; + AttackVoice: sndNone); + Slot: 6; + TimeAfterTurn: 0; + minAngle: 0; + maxAngle: 0; + isDamaging: false; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidSkip; + NameTex: nil; + Probability: 0; + NumberInCase: 1; + Ammo: (Propz: ammoprop_NoCrosshair or ammoprop_DontHold; + Count: AMMO_INFINITE; + InitialCount: AMMO_INFINITE; + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amSkip; + AttackVoice: sndNone); + Slot: 8; + TimeAfterTurn: 0; + minAngle: 0; + maxAngle: 0; + isDamaging: false; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidRope; + NameTex: nil; + Probability: 100; + NumberInCase: 3; + Ammo: (Propz: ammoprop_NoRoundEndHint or + ammoprop_ForwMsgs or + ammoprop_AttackInMove or + ammoprop_AltAttack; + Count: 5; + InitialCount: 5; + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amRope; + AttackVoice: sndNone); + Slot: 7; + TimeAfterTurn: 0; + minAngle: 0; + maxAngle: cMaxAngle div 2; + isDamaging: false; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidMine; + NameTex: nil; + Probability: 100; + NumberInCase: 1; + Ammo: (Propz: ammoprop_NoCrosshair or ammoprop_AttackInMove or ammoprop_DontHold or ammoprop_AltUse; + Count: 2; + InitialCount: 2; + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amMine; + AttackVoice: sndLaugh); + Slot: 4; + TimeAfterTurn: 5000; + minAngle: 0; + maxAngle: 0; + isDamaging: true; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidDEagle; + NameTex: nil; + Probability: 20; + NumberInCase: 2; + Ammo: (Propz: 0; + Count: 3; + InitialCount: 3; + NumPerTurn: 3; + Timer: 0; + Pos: 0; + AmmoType: amDEagle; + AttackVoice: sndNone); + Slot: 2; + TimeAfterTurn: 3000; + minAngle: 0; + maxAngle: 0; + isDamaging: true; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidDynamite; + NameTex: nil; + Probability: 100; + NumberInCase: 1; + Ammo: (Propz: ammoprop_NoCrosshair or ammoprop_AttackInMove or ammoprop_DontHold or ammoprop_AltUse; + Count: 1; + InitialCount: 1; + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amDynamite; + AttackVoice: sndLaugh); + Slot: 4; + TimeAfterTurn: 5000; + minAngle: 0; + maxAngle: 0; + isDamaging: true; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidFirePunch; + NameTex: nil; + Probability: 0; + NumberInCase: 1; + Ammo: (Propz: ammoprop_NoCrosshair or ammoprop_ForwMsgs or ammoprop_AttackInMove; + Count: AMMO_INFINITE; + InitialCount: AMMO_INFINITE; + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amFirePunch; + AttackVoice: sndNone); + Slot: 3; + TimeAfterTurn: 3000; + MinAngle: 0; + maxAngle: 0; + isDamaging: true; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidWhip; + NameTex: nil; + Probability: 0; + NumberInCase: 1; + Ammo: (Propz: ammoprop_NoCrosshair; + Count: AMMO_INFINITE; + InitialCount: AMMO_INFINITE; + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amWhip; + AttackVoice: sndNone); + Slot: 3; + TimeAfterTurn: 3000; + MinAngle: 0; + maxAngle: 0; + isDamaging: true; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidBaseballBat; + NameTex: nil; + Probability: 100; + NumberInCase: 1; + Ammo: (Propz: ammoprop_DontHold; + Count: 1; + InitialCount: 1; + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amBaseballBat; + AttackVoice: sndNone); + Slot: 3; + TimeAfterTurn: 5000; + minAngle: 0; + maxAngle: cMaxAngle div 2; + isDamaging: true; + SkipTurns: 2; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidParachute; + NameTex: nil; + Probability: 100; + NumberInCase: 1; + Ammo: (Propz: ammoprop_NoRoundEndHint or + ammoprop_ForwMsgs or + ammoprop_AttackInMove or + ammoprop_NoCrosshair or + ammoprop_DontHold or + ammoprop_AltAttack; + Count: 2; + InitialCount: 2; + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amParachute; + AttackVoice: sndNone); + Slot: 7; + TimeAfterTurn: 0; + minAngle: 0; + maxAngle: 0; + isDamaging: false; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidAirAttack; + NameTex: nil; + Probability: 100; + NumberInCase: 1; + Ammo: (Propz: ammoprop_NoCrosshair or + ammoprop_NeedTarget or + ammoprop_AttackingPut or + ammoprop_DontHold or + ammoprop_NotBorder; + Count: 1; + InitialCount: 1; + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amAirAttack; + AttackVoice: sndIncoming); + Slot: 5; + TimeAfterTurn: 0; + minAngle: 0; + maxAngle: 0; + isDamaging: true; + SkipTurns: 5; + PosCount: 2; + PosSprite: sprAmAirplane), + (NameId: sidMineStrike; + NameTex: nil; + Probability: 200; + NumberInCase: 1; + Ammo: (Propz: ammoprop_NoCrosshair or + ammoprop_NeedTarget or + ammoprop_AttackingPut or + ammoprop_DontHold or + ammoprop_NotBorder; + Count: 1; + InitialCount: 1; + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amMineStrike; + AttackVoice: sndNone); + Slot: 5; + TimeAfterTurn: 0; + minAngle: 0; + maxAngle: 0; + isDamaging: true; + SkipTurns: 5; + PosCount: 2; + PosSprite: sprAmAirplane), + (NameId: sidBlowTorch; + NameTex: nil; + Probability: 100; + NumberInCase: 2; + Ammo: (Propz: ammoprop_ForwMsgs; + Count: 1; InitialCount: 1; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amSeduction; - AttackVoice: sndNone); - Slot: 2; - TimeAfterTurn: 0; - minAngle: 0; - maxAngle: 0; - isDamaging: false; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidWatermelon; - NameTex: nil; - Probability: 400; - NumberInCase: 1; - Ammo: (Propz: ammoprop_Timerable or ammoprop_Power or ammoprop_AltUse; - Count: 0; - InitialCount: 0; - NumPerTurn: 0; - Timer: 3000; - Pos: 0; - AmmoType: amWatermelon; - AttackVoice: sndMelon); - Slot: 1; - TimeAfterTurn: 3000; - minAngle: 0; - maxAngle: 0; - isDamaging: true; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidHellishBomb; - NameTex: nil; - Probability: 400; - NumberInCase: 1; - Ammo: (Propz: ammoprop_Power or ammoprop_AltUse; - Count: 0; - InitialCount: 0; - NumPerTurn: 0; - Timer: 5000; - Pos: 0; - AmmoType: amHellishBomb; - AttackVoice: sndNone); - Slot: 4; - TimeAfterTurn: 3000; - minAngle: 0; - maxAngle: 0; - isDamaging: true; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidNapalm; - NameTex: nil; - Probability: 100; - NumberInCase: 1; - Ammo: (Propz: ammoprop_NoCrosshair or - ammoprop_NeedTarget or - ammoprop_AttackingPut or - ammoprop_DontHold or - ammoprop_NotBorder; - Count: 1; - InitialCount: 1; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amNapalm; - AttackVoice: sndNone); - Slot: 5; - TimeAfterTurn: 0; - minAngle: 0; - maxAngle: 0; - isDamaging: true; - SkipTurns: 7; - PosCount: 2; - PosSprite: sprAmAirplane), - (NameId: sidDrill; - NameTex: nil; - Probability: 300; - NumberInCase: 1; - Ammo: (Propz: ammoprop_Power or ammoprop_AltUse; - Count: AMMO_INFINITE; - InitialCount: AMMO_INFINITE; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amDrill; - AttackVoice: sndNone); - Slot: 0; - TimeAfterTurn: 3000; - minAngle: 0; - maxAngle: 0; - isDamaging: true; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprDrill), - (NameId: sidBallgun; - NameTex: nil; - Probability: 400; - NumberInCase: 1; - Ammo: (Propz: ammoprop_ForwMsgs or ammoprop_DontHold; - Count: AMMO_INFINITE; - InitialCount: AMMO_INFINITE; - NumPerTurn: 0; - Timer: 5001; - Pos: 0; - AmmoType: amBallgun; - AttackVoice: sndNone); - Slot: 2; - TimeAfterTurn: 0; - minAngle: 0; - maxAngle: 0; - isDamaging: true; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidRCPlane; - NameTex: nil; - Probability: 200; - NumberInCase: 1; - Ammo: (Propz: ammoprop_ForwMsgs{ or - ammoprop_DontHold or - ammoprop_AltAttack}; - Count: 1; - InitialCount: 1; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amRCPlane; - AttackVoice: sndNone); - Slot: 6; - TimeAfterTurn: 0; - minAngle: 0; - maxAngle: 0; - isDamaging: true; - SkipTurns: 4; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidLowGravity; - NameTex: nil; - Probability: 20; - NumberInCase: 1; - Ammo: (Propz: ammoprop_NoRoundEndHint or - ammoprop_NoCrosshair or - ammoprop_DontHold or - ammoprop_AltUse or - ammoprop_Utility; - Count: 1; - InitialCount: 1; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amLowGravity; - AttackVoice: sndNone); - Slot: 8; - TimeAfterTurn: 0; - minAngle: 0; - maxAngle: 0; - isDamaging: false; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidExtraDamage; - NameTex: nil; - Probability: 15; - NumberInCase: 1; - Ammo: (Propz: ammoprop_NoRoundEndHint or - ammoprop_NoCrosshair or - ammoprop_DontHold or - ammoprop_AltUse or - ammoprop_Utility; - Count: 1; + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amBlowTorch; + AttackVoice: sndNone); + Slot: 6; + TimeAfterTurn: 3000; + minAngle: 768; + maxAngle: 1280; + isDamaging: false; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidGirder; + NameTex: nil; + Probability: 150; + NumberInCase: 3; + Ammo: (Propz: ammoprop_NoRoundEndHint or + ammoprop_NoCrosshair or + ammoprop_NeedTarget or + ammoprop_AttackingPut; + Count: 1; InitialCount: 1; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amExtraDamage; - AttackVoice: sndNone); - Slot: 8; - TimeAfterTurn: 0; - minAngle: 0; - maxAngle: 0; - isDamaging: false; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidInvulnerable; - NameTex: nil; - Probability: 20; - NumberInCase: 1; - Ammo: (Propz: ammoprop_NoRoundEndHint or - ammoprop_NoCrosshair or - ammoprop_DontHold or - ammoprop_AltUse or + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amGirder; + AttackVoice: sndNone); + Slot: 6; + TimeAfterTurn: 3000; + minAngle: 0; + maxAngle: 0; + isDamaging: false; + SkipTurns: 0; + PosCount: 8; + PosSprite: sprAmGirder), + (NameId: sidTeleport; + NameTex: nil; + Probability: 200; + NumberInCase: 1; + Ammo: (Propz: ammoprop_ForwMsgs or + ammoprop_NoCrosshair or + ammoprop_NeedTarget or + ammoprop_AttackingPut or + ammoprop_DontHold; + Count: 2; + InitialCount: 2; + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amTeleport; + AttackVoice: sndNone); + Slot: 7; + TimeAfterTurn: 0; + minAngle: 0; + maxAngle: 0; + isDamaging: false; + SkipTurns: 0; + PosCount: 2; + PosSprite: sprAmTeleport), + (NameId: sidSwitch; + NameTex: nil; + Probability: 100; + NumberInCase: 1; + Ammo: (Propz: ammoprop_NoRoundEndHint or + ammoprop_ForwMsgs or + ammoprop_NoCrosshair or + ammoprop_DontHold; + Count: 3; + InitialCount: 3; + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amSwitch; + AttackVoice: sndNone); + Slot: 8; + TimeAfterTurn: 0; + minAngle: 0; + maxAngle: 0; + isDamaging: false; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidMortar; + NameTex: nil; + Probability: 100; + NumberInCase: 4; + Ammo: (Propz: 0; + Count: 4; + InitialCount: 4; + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amMortar; + AttackVoice: sndNone); + Slot: 1; + TimeAfterTurn: 3000; + minAngle: 0; + maxAngle: 0; + isDamaging: true; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidKamikaze; + NameTex: nil; + Probability: 100; + NumberInCase: 1; + Ammo: (Propz: ammoprop_ForwMsgs or ammoprop_DontHold or ammoprop_AttackInMove; + Count: 1; + InitialCount: 1; + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amKamikaze; + AttackVoice: sndNone); + Slot: 3; + TimeAfterTurn: 0; + minAngle: 0; + maxAngle: 0; + isDamaging: true; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidCake; + NameTex: nil; + Probability: 100; + NumberInCase: 1; + Ammo: (Propz: ammoprop_ForwMsgs or ammoprop_NoCrosshair or ammoprop_DontHold; + Count: 1; + InitialCount: 1; + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amCake; + AttackVoice: sndLaugh); + Slot: 4; + TimeAfterTurn: 0; + minAngle: 0; + maxAngle: 0; + isDamaging: true; + SkipTurns: 4; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidSeduction; + NameTex: nil; + Probability: 100; + NumberInCase: 1; + Ammo: (Propz: ammoprop_ForwMsgs or ammoprop_DontHold; + Count: 1; + InitialCount: 1; + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amSeduction; + AttackVoice: sndNone); + Slot: 2; + TimeAfterTurn: 0; + minAngle: 0; + maxAngle: 0; + isDamaging: false; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidWatermelon; + NameTex: nil; + Probability: 400; + NumberInCase: 1; + Ammo: (Propz: ammoprop_Timerable or ammoprop_Power or ammoprop_AltUse; + Count: 0; + InitialCount: 0; + NumPerTurn: 0; + Timer: 3000; + Pos: 0; + AmmoType: amWatermelon; + AttackVoice: sndMelon); + Slot: 1; + TimeAfterTurn: 3000; + minAngle: 0; + maxAngle: 0; + isDamaging: true; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidHellishBomb; + NameTex: nil; + Probability: 400; + NumberInCase: 1; + Ammo: (Propz: ammoprop_Power or ammoprop_AltUse; + Count: 0; + InitialCount: 0; + NumPerTurn: 0; + Timer: 5000; + Pos: 0; + AmmoType: amHellishBomb; + AttackVoice: sndNone); + Slot: 4; + TimeAfterTurn: 3000; + minAngle: 0; + maxAngle: 0; + isDamaging: true; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidNapalm; + NameTex: nil; + Probability: 100; + NumberInCase: 1; + Ammo: (Propz: ammoprop_NoCrosshair or + ammoprop_NeedTarget or + ammoprop_AttackingPut or + ammoprop_DontHold or + ammoprop_NotBorder; + Count: 1; + InitialCount: 1; + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amNapalm; + AttackVoice: sndNone); + Slot: 5; + TimeAfterTurn: 0; + minAngle: 0; + maxAngle: 0; + isDamaging: true; + SkipTurns: 7; + PosCount: 2; + PosSprite: sprAmAirplane), + (NameId: sidDrill; + NameTex: nil; + Probability: 300; + NumberInCase: 1; + Ammo: (Propz: ammoprop_Power or ammoprop_AltUse; + Count: AMMO_INFINITE; + InitialCount: AMMO_INFINITE; + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amDrill; + AttackVoice: sndNone); + Slot: 0; + TimeAfterTurn: 3000; + minAngle: 0; + maxAngle: 0; + isDamaging: true; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprDrill), + (NameId: sidBallgun; + NameTex: nil; + Probability: 400; + NumberInCase: 1; + Ammo: (Propz: ammoprop_ForwMsgs or ammoprop_DontHold; + Count: AMMO_INFINITE; + InitialCount: AMMO_INFINITE; + NumPerTurn: 0; + Timer: 5001; + Pos: 0; + AmmoType: amBallgun; + AttackVoice: sndNone); + Slot: 2; + TimeAfterTurn: 0; + minAngle: 0; + maxAngle: 0; + isDamaging: true; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidRCPlane; + NameTex: nil; + Probability: 200; + NumberInCase: 1; + Ammo: (Propz: ammoprop_ForwMsgs{ or + ammoprop_DontHold or + ammoprop_AltAttack}; + Count: 1; + InitialCount: 1; + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amRCPlane; + AttackVoice: sndNone); + Slot: 6; + TimeAfterTurn: 0; + minAngle: 0; + maxAngle: 0; + isDamaging: true; + SkipTurns: 4; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidLowGravity; + NameTex: nil; + Probability: 20; + NumberInCase: 1; + Ammo: (Propz: ammoprop_NoRoundEndHint or + ammoprop_NoCrosshair or + ammoprop_DontHold or + ammoprop_AltUse or ammoprop_Utility; - Count: 1; - InitialCount: 1; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amInvulnerable; - AttackVoice: sndNone); - Slot: 8; - TimeAfterTurn: 0; - minAngle: 0; - maxAngle: 0; - isDamaging: false; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidExtraTime; - NameTex: nil; - Probability: 30; - NumberInCase: 1; - Ammo: (Propz: ammoprop_NoRoundEndHint or - ammoprop_NoCrosshair or - ammoprop_DontHold or - ammoprop_AltUse or - ammoprop_Utility; - Count: 1; - InitialCount: 1; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amExtraTime; - AttackVoice: sndNone); - Slot: 7; - TimeAfterTurn: 0; - minAngle: 0; - maxAngle: 0; - isDamaging: false; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidLaserSight; - NameTex: nil; - Probability: 15; - NumberInCase: 1; - Ammo: (Propz: ammoprop_NoRoundEndHint or - ammoprop_NoCrosshair or - ammoprop_DontHold or - ammoprop_AltUse or - ammoprop_Utility; - Count: 1; + Count: 1; InitialCount: 1; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amLaserSight; - AttackVoice: sndNone); - Slot: 7; - TimeAfterTurn: 0; - minAngle: 0; - maxAngle: 0; - isDamaging: false; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidVampiric; - NameTex: nil; - Probability: 15; - NumberInCase: 1; - Ammo: (Propz: ammoprop_NoRoundEndHint or - ammoprop_NoCrosshair or - ammoprop_DontHold or - ammoprop_AltUse or + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amLowGravity; + AttackVoice: sndNone); + Slot: 8; + TimeAfterTurn: 0; + minAngle: 0; + maxAngle: 0; + isDamaging: false; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidExtraDamage; + NameTex: nil; + Probability: 15; + NumberInCase: 1; + Ammo: (Propz: ammoprop_NoRoundEndHint or + ammoprop_NoCrosshair or + ammoprop_DontHold or + ammoprop_AltUse or + ammoprop_Utility; + Count: 1; + InitialCount: 1; + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amExtraDamage; + AttackVoice: sndNone); + Slot: 8; + TimeAfterTurn: 0; + minAngle: 0; + maxAngle: 0; + isDamaging: false; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidInvulnerable; + NameTex: nil; + Probability: 20; + NumberInCase: 1; + Ammo: (Propz: ammoprop_NoRoundEndHint or + ammoprop_NoCrosshair or + ammoprop_DontHold or + ammoprop_AltUse or + ammoprop_Utility; + Count: 1; + InitialCount: 1; + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amInvulnerable; + AttackVoice: sndNone); + Slot: 8; + TimeAfterTurn: 0; + minAngle: 0; + maxAngle: 0; + isDamaging: false; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidExtraTime; + NameTex: nil; + Probability: 30; + NumberInCase: 1; + Ammo: (Propz: ammoprop_NoRoundEndHint or + ammoprop_NoCrosshair or + ammoprop_DontHold or + ammoprop_AltUse or ammoprop_Utility; - Count: 1; + Count: 1; + InitialCount: 1; + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amExtraTime; + AttackVoice: sndNone); + Slot: 7; + TimeAfterTurn: 0; + minAngle: 0; + maxAngle: 0; + isDamaging: false; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidLaserSight; + NameTex: nil; + Probability: 15; + NumberInCase: 1; + Ammo: (Propz: ammoprop_NoRoundEndHint or + ammoprop_NoCrosshair or + ammoprop_DontHold or + ammoprop_AltUse or + ammoprop_Utility; + Count: 1; InitialCount: 1; - NumPerTurn: 0; - Timer: 0; - Pos: 0; - AmmoType: amVampiric; - AttackVoice: sndNone); - Slot: 6; - TimeAfterTurn: 0; - minAngle: 0; - maxAngle: 0; - isDamaging: false; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidSniperRifle; - NameTex: nil; - Probability: 20; - NumberInCase: 2; - Ammo: (Propz: 0; - Count: 2; + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amLaserSight; + AttackVoice: sndNone); + Slot: 7; + TimeAfterTurn: 0; + minAngle: 0; + maxAngle: 0; + isDamaging: false; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidVampiric; + NameTex: nil; + Probability: 15; + NumberInCase: 1; + Ammo: (Propz: ammoprop_NoRoundEndHint or + ammoprop_NoCrosshair or + ammoprop_DontHold or + ammoprop_AltUse or + ammoprop_Utility; + Count: 1; + InitialCount: 1; + NumPerTurn: 0; + Timer: 0; + Pos: 0; + AmmoType: amVampiric; + AttackVoice: sndNone); + Slot: 6; + TimeAfterTurn: 0; + minAngle: 0; + maxAngle: 0; + isDamaging: false; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidSniperRifle; + NameTex: nil; + Probability: 20; + NumberInCase: 2; + Ammo: (Propz: 0; + Count: 2; InitialCount: 2; - NumPerTurn: 1; - Timer: 0; - Pos: 0; - AmmoType: amSniperRifle; - AttackVoice: sndNone); - Slot: 2; - TimeAfterTurn: 3000; - minAngle: 0; - maxAngle: 0; - isDamaging: true; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidJetpack; - NameTex: nil; - Probability: 20; - NumberInCase: 1; - Ammo: (Propz: ammoprop_NoRoundEndHint or - ammoprop_ForwMsgs or - ammoprop_AttackInMove or - ammoprop_NoCrosshair or - ammoprop_DontHold or - ammoprop_AltAttack; - Count: 1; + NumPerTurn: 1; + Timer: 0; + Pos: 0; + AmmoType: amSniperRifle; + AttackVoice: sndNone); + Slot: 2; + TimeAfterTurn: 3000; + minAngle: 0; + maxAngle: 0; + isDamaging: true; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidJetpack; + NameTex: nil; + Probability: 20; + NumberInCase: 1; + Ammo: (Propz: ammoprop_NoRoundEndHint or + ammoprop_ForwMsgs or + ammoprop_AttackInMove or + ammoprop_NoCrosshair or + ammoprop_DontHold or + ammoprop_AltAttack; + Count: 1; InitialCount: 1; - NumPerTurn: 1; - Timer: 0; - Pos: 0; - AmmoType: amJetpack; - AttackVoice: sndNone); - Slot: 3; - TimeAfterTurn: 3000; - minAngle: 0; - maxAngle: 0; - isDamaging: false; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater), - (NameId: sidMolotov; - NameTex: nil; - Probability: 0; - NumberInCase: 1; - Ammo: (Propz: ammoprop_Power or ammoprop_AltUse; - Count: AMMO_INFINITE; + NumPerTurn: 1; + Timer: 0; + Pos: 0; + AmmoType: amJetpack; + AttackVoice: sndNone); + Slot: 3; + TimeAfterTurn: 3000; + minAngle: 0; + maxAngle: 0; + isDamaging: false; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater), + (NameId: sidMolotov; + NameTex: nil; + Probability: 0; + NumberInCase: 1; + Ammo: (Propz: ammoprop_Power or ammoprop_AltUse; + Count: AMMO_INFINITE; InitialCount: AMMO_INFINITE; - NumPerTurn: 0; - Timer: 3000; - Pos: 0; - AmmoType: amMolotov; - AttackVoice: sndNone); - Slot: 1; - TimeAfterTurn: 3000; - minAngle: 0; - maxAngle: 0; - isDamaging: true; - SkipTurns: 0; - PosCount: 1; - PosSprite: sprWater) - ); + NumPerTurn: 0; + Timer: 3000; + Pos: 0; + AmmoType: amMolotov; + AttackVoice: sndNone); + Slot: 1; + TimeAfterTurn: 3000; + minAngle: 0; + maxAngle: 0; + isDamaging: true; + SkipTurns: 0; + PosCount: 1; + PosSprite: sprWater) + ); - conversionFormat: TSDL_PixelFormat = ( - palette: nil; - BitsPerPixel : 32; - BytesPerPixel: 4; - Rloss : 0; - Gloss : 0; - Bloss : 0; - Aloss : 0; + conversionFormat: TSDL_PixelFormat = ( + palette: nil; + BitsPerPixel : 32; + BytesPerPixel: 4; + Rloss : 0; + Gloss : 0; + Bloss : 0; + Aloss : 0; {$IFDEF ENDIAN_LITTLE} - Rshift: 0; - Gshift: 8; - Bshift: 16; - Ashift: 24; + Rshift: 0; + Gshift: 8; + Bshift: 16; + Ashift: 24; {$ELSE} - Rshift: 24; - Gshift: 16; - Bshift: 8; - Ashift: 0; + Rshift: 24; + Gshift: 16; + Bshift: 8; + Ashift: 0; {$ENDIF} - RMask : RMask; - GMask : GMask; - BMask : BMask; - AMask : AMask; - colorkey: 0; - alpha : 255 - ); - + RMask : RMask; + GMask : GMask; + BMask : BMask; + AMask : AMask; + colorkey: 0; + alpha : 255 + ); + procedure init_uConsts; procedure free_uConsts; @@ -1706,29 +1706,29 @@ procedure init_uConsts; var cPathz: array[TPathType] of shortstring = ( - '', // ptNone - '', // ptData - 'Graphics', // ptGraphics - 'Themes', // ptThemes - 'Themes/avematan', // ptCurrTheme - 'Teams', // ptTeams - 'Maps', // ptMaps - '', // ptMapCurrent - 'Demos', // ptDemos - 'Sounds', // ptSounds - 'Graphics/Graves', // ptGraves - 'Fonts', // ptFonts - 'Forts', // ptForts - 'Locale', // ptLocale - 'Graphics/AmmoMenu', // ptAmmoMenu - 'Graphics/Hedgehog', // ptHedgehog - 'Sounds/voices', // ptVoices - 'Graphics/Hats', // ptHats - 'Graphics/Flags' // ptFlags - ); + '', // ptNone + '', // ptData + 'Graphics', // ptGraphics + 'Themes', // ptThemes + 'Themes/avematan', // ptCurrTheme + 'Teams', // ptTeams + 'Maps', // ptMaps + '', // ptMapCurrent + 'Demos', // ptDemos + 'Sounds', // ptSounds + 'Graphics/Graves', // ptGraves + 'Fonts', // ptFonts + 'Forts', // ptForts + 'Locale', // ptLocale + 'Graphics/AmmoMenu', // ptAmmoMenu + 'Graphics/Hedgehog', // ptHedgehog + 'Sounds/voices', // ptVoices + 'Graphics/Hats', // ptHats + 'Graphics/Flags' // ptFlags + ); begin - PathPrefix := './'; - Pathz:= cPathz; + PathPrefix := './'; + Pathz:= cPathz; end; procedure free_uConsts; diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/uFloat.pas --- a/hedgewars/uFloat.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/uFloat.pas Sat Mar 06 10:59:20 2010 +0000 @@ -291,9 +291,9 @@ begin hwSqr.isNegative:= false; hwSqr.QWordValue:= - ((QWord(t.Round) * t.Round) shl 32) - + QWord(t.Round) * t.Frac * 2 - + ((QWord(t.Frac) * t.Frac) shr 32); + ((QWord(t.Round) * t.Round) shl 32) + + QWord(t.Round) * t.Frac * 2 + + ((QWord(t.Frac) * t.Frac) shr 32); end; function hwSqrt(const t: hwFloat): hwFloat; diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/uGame.pas --- a/hedgewars/uGame.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/uGame.pas Sat Mar 06 10:59:20 2010 +0000 @@ -34,11 +34,11 @@ begin if isPaused then exit; if (not CurrentTeam^.ExtDriven) then - begin - NetGetNextCmd; // its for the case of receiving "/say" message - isInLag:= false; - SendKeepAliveMessage(Lag) - end; + begin + NetGetNextCmd; // its for the case of receiving "/say" message + isInLag:= false; + SendKeepAliveMessage(Lag) + end; if Lag > 100 then Lag:= 100 else if (GameType = gmtSave) or (fastUntilLag and (GameType = gmtNet)) then Lag:= 2500; if (GameType = gmtDemo) and isSpeed then Lag:= Lag * 10; diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/uGears.pas --- a/hedgewars/uGears.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/uGears.pas Sat Mar 06 10:59:20 2010 +0000 @@ -24,41 +24,41 @@ type - PGear = ^TGear; - TGearStepProcedure = procedure (Gear: PGear); - TGear = record - NextGear, PrevGear: PGear; - Active: Boolean; - Invulnerable: Boolean; - RenderTimer: Boolean; - Ammo : PAmmo; - State : Longword; - X : hwFloat; - Y : hwFloat; - dX: hwFloat; - dY: hwFloat; - Kind: TGearType; - Pos: Longword; - doStep: TGearStepProcedure; - Radius: LongInt; - Angle, Power : Longword; - DirAngle: real; - Timer : LongWord; - Elasticity: hwFloat; - Friction : hwFloat; - Message, MsgParam : Longword; - Hedgehog: pointer; - Health, Damage, Karma: LongInt; - CollisionIndex: LongInt; - Tag: LongInt; - Tex: PTexture; - Z: Longword; - IntersectGear: PGear; - TriggerId: Longword; - FlightTime: Longword; - uid: Longword; - SoundChannel: LongInt - end; + PGear = ^TGear; + TGearStepProcedure = procedure (Gear: PGear); + TGear = record + NextGear, PrevGear: PGear; + Active: Boolean; + Invulnerable: Boolean; + RenderTimer: Boolean; + Ammo : PAmmo; + State : Longword; + X : hwFloat; + Y : hwFloat; + dX: hwFloat; + dY: hwFloat; + Kind: TGearType; + Pos: Longword; + doStep: TGearStepProcedure; + Radius: LongInt; + Angle, Power : Longword; + DirAngle: real; + Timer : LongWord; + Elasticity: hwFloat; + Friction : hwFloat; + Message, MsgParam : Longword; + Hedgehog: pointer; + Health, Damage, Karma: LongInt; + CollisionIndex: LongInt; + Tag: LongInt; + Tex: PTexture; + Z: Longword; + IntersectGear: PGear; + TriggerId: Longword; + FlightTime: Longword; + uid: Longword; + SoundChannel: LongInt + end; var AllInactive: boolean; PrvInactive: boolean; @@ -94,11 +94,11 @@ implementation uses uWorld, uMisc, uStore, uConsole, uSound, uTeams, uRandom, uCollisions, uLand, uIO, uLandGraphics, - uAIMisc, uLocale, uAI, uAmmos, uTriggers, uStats, uVisualGears, uScript, + uAIMisc, uLocale, uAI, uAmmos, uTriggers, uStats, uVisualGears, uScript, {$IFDEF GLES11} - gles11; + gles11; {$ELSE} - GL; + GL; {$ENDIF} const MAXROPEPOINTS = 384; @@ -133,89 +133,89 @@ {$INCLUDE "HHHandlers.inc"} const doStepHandlers: array[TGearType] of TGearStepProcedure = ( - @doStepBomb, - @doStepHedgehog, - @doStepGrenade, - @doStepHealthTag, - @doStepGrave, - @doStepUFO, - @doStepShotgunShot, - @doStepPickHammer, - @doStepRope, - @doStepSmokeTrace, - @doStepExplosion, - @doStepMine, - @doStepCase, - @doStepDEagleShot, - @doStepDynamite, - @doStepBomb, - @doStepCluster, - @doStepShover, - @doStepFlame, - @doStepFirePunch, - @doStepActionTimer, - @doStepActionTimer, - @doStepActionTimer, - @doStepParachute, - @doStepAirAttack, - @doStepAirBomb, - @doStepBlowTorch, - @doStepGirder, - @doStepTeleport, - @doStepSwitcher, - @doStepTarget, - @doStepMortar, - @doStepWhip, - @doStepKamikaze, - @doStepCake, - @doStepSeduction, - @doStepWatermelon, - @doStepCluster, - @doStepBomb, - @doStepSmokeTrace, - @doStepWaterUp, - @doStepDrill, - @doStepBallgun, - @doStepBomb, - @doStepRCPlane, - @doStepSniperRifleShot, - @doStepJetpack, - @doStepMolotov, - @doStepCase - ); + @doStepBomb, + @doStepHedgehog, + @doStepGrenade, + @doStepHealthTag, + @doStepGrave, + @doStepUFO, + @doStepShotgunShot, + @doStepPickHammer, + @doStepRope, + @doStepSmokeTrace, + @doStepExplosion, + @doStepMine, + @doStepCase, + @doStepDEagleShot, + @doStepDynamite, + @doStepBomb, + @doStepCluster, + @doStepShover, + @doStepFlame, + @doStepFirePunch, + @doStepActionTimer, + @doStepActionTimer, + @doStepActionTimer, + @doStepParachute, + @doStepAirAttack, + @doStepAirBomb, + @doStepBlowTorch, + @doStepGirder, + @doStepTeleport, + @doStepSwitcher, + @doStepTarget, + @doStepMortar, + @doStepWhip, + @doStepKamikaze, + @doStepCake, + @doStepSeduction, + @doStepWatermelon, + @doStepCluster, + @doStepBomb, + @doStepSmokeTrace, + @doStepWaterUp, + @doStepDrill, + @doStepBallgun, + @doStepBomb, + @doStepRCPlane, + @doStepSniperRifleShot, + @doStepJetpack, + @doStepMolotov, + @doStepCase + ); procedure InsertGearToList(Gear: PGear); var tmp, ptmp: PGear; begin if GearsList = nil then - GearsList:= Gear - else begin - tmp:= GearsList; - ptmp:= GearsList; - while (tmp <> nil) and (tmp^.Z <= Gear^.Z) do - begin - ptmp:= tmp; - tmp:= tmp^.NextGear - end; + GearsList:= Gear + else begin + tmp:= GearsList; + ptmp:= GearsList; + while (tmp <> nil) and (tmp^.Z <= Gear^.Z) do + begin + ptmp:= tmp; + tmp:= tmp^.NextGear + end; - if ptmp <> nil then - begin - Gear^.NextGear:= ptmp^.NextGear; - Gear^.PrevGear:= ptmp; - if ptmp^.NextGear <> nil then ptmp^.NextGear^.PrevGear:= Gear; - ptmp^.NextGear:= Gear - end - else GearsList:= Gear - end + if ptmp <> nil then + begin + Gear^.NextGear:= ptmp^.NextGear; + Gear^.PrevGear:= ptmp; + if ptmp^.NextGear <> nil then ptmp^.NextGear^.PrevGear:= Gear; + ptmp^.NextGear:= Gear + end + else GearsList:= Gear + end end; procedure RemoveGearFromList(Gear: PGear); begin if Gear^.NextGear <> nil then Gear^.NextGear^.PrevGear:= Gear^.PrevGear; if Gear^.PrevGear <> nil then - Gear^.PrevGear^.NextGear:= Gear^.NextGear + Gear^.PrevGear^.NextGear:= Gear^.NextGear else - GearsList:= Gear^.NextGear + GearsList:= Gear^.NextGear end; function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear; @@ -245,10 +245,10 @@ gear^.SoundChannel:= -1; if CurrentTeam <> nil then - begin - gear^.Hedgehog:= CurrentHedgehog; - gear^.IntersectGear:= CurrentHedgehog^.Gear - end; + begin + gear^.Hedgehog:= CurrentHedgehog; + gear^.IntersectGear:= CurrentHedgehog^.Gear + end; case Kind of gtAmmo_Bomb, @@ -359,10 +359,10 @@ gear^.Radius:= 1; gear^.Health:= 5; if (gear^.dY.QWordValue = 0) and (gear^.dX.QWordValue = 0) then - begin - gear^.dY:= (getrandom - _0_8) * _0_03; - gear^.dX:= (getrandom - _0_5) * _0_4 - end + begin + gear^.dY:= (getrandom - _0_8) * _0_03; + gear^.dX:= (getrandom - _0_5) * _0_4 + end end; gtFirePunch: begin gear^.Radius:= 15; @@ -381,7 +381,7 @@ gtTarget: begin gear^.Radius:= 10; gear^.Elasticity:= _0_3; - gear^.Timer:= 0 + gear^.Timer:= 0 end; gtMortar: begin gear^.Radius:= 4; @@ -441,7 +441,7 @@ procedure DeleteGear(Gear: PGear); var team: PTeam; - t,i: Longword; + t,i: Longword; k: boolean; begin @@ -450,34 +450,34 @@ DeleteCI(Gear); if Gear^.Tex <> nil then - begin - FreeTexture(Gear^.Tex); - Gear^.Tex:= nil - end; + begin + FreeTexture(Gear^.Tex); + Gear^.Tex:= nil + end; if Gear^.Kind = gtHedgehog then - if (CurAmmoGear <> nil) and (CurrentHedgehog^.Gear = Gear) then - begin - Gear^.Message:= gm_Destroy; - CurAmmoGear^.Message:= gm_Destroy; - exit - end - else - begin - if (hwRound(Gear^.Y) >= cWaterLine) then - begin - t:= max(Gear^.Damage, Gear^.Health); - Gear^.Damage:= t; + if (CurAmmoGear <> nil) and (CurrentHedgehog^.Gear = Gear) then + begin + Gear^.Message:= gm_Destroy; + CurAmmoGear^.Message:= gm_Destroy; + exit + end + else + begin + if (hwRound(Gear^.Y) >= cWaterLine) then + begin + t:= max(Gear^.Damage, Gear^.Health); + Gear^.Damage:= t; if cWaterOpacity < $FF then - AddGear(hwRound(Gear^.X), min(hwRound(Gear^.Y),cWaterLine+cVisibleWater+32), gtHealthTag, t, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; - uStats.HedgehogDamaged(Gear) - end; + AddGear(hwRound(Gear^.X), min(hwRound(Gear^.Y),cWaterLine+cVisibleWater+32), gtHealthTag, t, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; + uStats.HedgehogDamaged(Gear) + end; - team:= PHedgehog(Gear^.Hedgehog)^.Team; - if CurrentHedgehog^.Gear = Gear then - FreeActionsList; // to avoid ThinkThread on drawned gear + team:= PHedgehog(Gear^.Hedgehog)^.Team; + if CurrentHedgehog^.Gear = Gear then + FreeActionsList; // to avoid ThinkThread on drawned gear - PHedgehog(Gear^.Hedgehog)^.Gear:= nil; + PHedgehog(Gear^.Hedgehog)^.Gear:= nil; if PHedgehog(Gear^.Hedgehog)^.King then begin // are there any other kings left? Just doing nil check. Presumably a mortally wounded king will get reaped soon enough @@ -488,9 +488,9 @@ for i:= 0 to Pred(team^.Clan^.TeamsNumber) do TeamGoneEffect(team^.Clan^.Teams[i]^) end; - inc(KilledHHs); - RecountTeamHealth(team) - end; + inc(KilledHHs); + RecountTeamHealth(team) + end; {$IFDEF DEBUGFILE} with Gear^ do AddFileLog('Delete: #' + inttostr(uid) + ' (' + inttostr(hwRound(x)) + ',' + inttostr(hwRound(y)) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + inttostr(ord(Kind))); {$ENDIF} @@ -509,20 +509,20 @@ CheckNoDamage:= true; Gear:= GearsList; while Gear <> nil do - begin - if Gear^.Kind = gtHedgehog then - begin - if (not isInMultiShoot) then inc(Gear^.Damage, Gear^.Karma); - if (Gear^.Damage <> 0) and - (not Gear^.Invulnerable) then - begin - CheckNoDamage:= false; - uStats.HedgehogDamaged(Gear); - dmg:= Gear^.Damage; - if Gear^.Health < dmg then - Gear^.Health:= 0 - else - dec(Gear^.Health, dmg); + begin + if Gear^.Kind = gtHedgehog then + begin + if (not isInMultiShoot) then inc(Gear^.Damage, Gear^.Karma); + if (Gear^.Damage <> 0) and + (not Gear^.Invulnerable) then + begin + CheckNoDamage:= false; + uStats.HedgehogDamaged(Gear); + dmg:= Gear^.Damage; + if Gear^.Health < dmg then + Gear^.Health:= 0 + else + dec(Gear^.Health, dmg); if (PHedgehog(Gear^.Hedgehog)^.Team = CurrentTeam) and (Gear^.Damage <> Gear^.Karma) and @@ -530,18 +530,18 @@ not SuddenDeathDmg then Gear^.State:= Gear^.State or gstLoser; - AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) - cHHRadius - 12, - gtHealthTag, dmg, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; + AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) - cHHRadius - 12, + gtHealthTag, dmg, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog; - RenderHealth(PHedgehog(Gear^.Hedgehog)^); - RecountTeamHealth(PHedgehog(Gear^.Hedgehog)^.Team); + RenderHealth(PHedgehog(Gear^.Hedgehog)^); + RecountTeamHealth(PHedgehog(Gear^.Hedgehog)^.Team); - end; - if (not isInMultiShoot) then Gear^.Karma:= 0; - Gear^.Damage:= 0 - end; - Gear:= Gear^.NextGear - end; + end; + if (not isInMultiShoot) then Gear^.Karma:= 0; + Gear^.Damage:= 0 + end; + Gear:= Gear^.NextGear + end; SuddenDeathDmg:= false; end; @@ -554,14 +554,14 @@ Gear:= GearsList; while Gear <> nil do - begin - if Gear^.Kind = gtHedgehog then + begin + if Gear^.Kind = gtHedgehog then begin - inc(Gear^.Damage, min(cHealthDecrease, max(0,Gear^.Health - 1 - Gear^.Damage))); + inc(Gear^.Damage, min(cHealthDecrease, max(0,Gear^.Health - 1 - Gear^.Damage))); if PHedgehog(Gear^.Hedgehog)^.King then begin flag:= false; - team:= PHedgehog(Gear^.Hedgehog)^.Team; + team:= PHedgehog(Gear^.Hedgehog)^.Team; for i:= 0 to Pred(team^.HedgehogsNumber) do if (team^.Hedgehogs[i].Gear <> nil) and (not team^.Hedgehogs[i].King) and @@ -570,15 +570,15 @@ end end; - Gear:= Gear^.NextGear - end; + Gear:= Gear^.NextGear + end; end; procedure ProcessGears; const delay: LongWord = 0; - step: (stDelay, stChDmg, stSweep, stTurnReact, - stAfterDelay, stChWin, stWater, stChWin2, stHealth, - stSpawn, stNTurn) = stDelay; + step: (stDelay, stChDmg, stSweep, stTurnReact, + stAfterDelay, stChWin, stWater, stChWin2, stHealth, + stSpawn, stNTurn) = stDelay; var Gear, t: PGear; begin @@ -586,26 +586,26 @@ AllInactive:= true; if (StepSoundTimer > 0) and (StepSoundChannel < 0) then - begin - WriteLnToConsole('playsteps ...'); - StepSoundChannel:= LoopSound(sndSteps) - end + begin + WriteLnToConsole('playsteps ...'); + StepSoundChannel:= LoopSound(sndSteps) + end else if (StepSoundTimer = 0) and (StepSoundChannel > -1) then - begin - WriteLnToConsole('stopsteps ...'); - StopSound(StepSoundChannel); - StepSoundChannel:= -1; - end; + begin + WriteLnToConsole('stopsteps ...'); + StopSound(StepSoundChannel); + StepSoundChannel:= -1; + end; if StepSoundTimer > 0 then - dec(StepSoundTimer, 1); + dec(StepSoundTimer, 1); t:= GearsList; while t <> nil do - begin - Gear:= t; - t:= Gear^.NextGear; - if Gear^.Active then + begin + Gear:= t; + t:= Gear^.NextGear; + if Gear^.Active then begin if Gear^.RenderTimer and (Gear^.Timer > 500) and ((Gear^.Timer mod 1000) = 0) then begin @@ -614,134 +614,134 @@ end; Gear^.doStep(Gear); end - end; + end; if AllInactive then case step of - stDelay: begin - if delay = 0 then - delay:= cInactDelay - else - dec(delay); + stDelay: begin + if delay = 0 then + delay:= cInactDelay + else + dec(delay); - if delay = 0 then - inc(step) - end; - stChDmg: if CheckNoDamage then inc(step) else step:= stDelay; - stSweep: if SweepDirty then - begin - SetAllToActive; - step:= stChDmg - end else inc(step); - stTurnReact: begin - if (not bBetweenTurns) and (not isInMultiShoot) then - begin - uStats.TurnReaction; - inc(step) - end else - inc(step, 2); - end; - stAfterDelay: begin - if delay = 0 then - delay:= cInactDelay - else - dec(delay); + if delay = 0 then + inc(step) + end; + stChDmg: if CheckNoDamage then inc(step) else step:= stDelay; + stSweep: if SweepDirty then + begin + SetAllToActive; + step:= stChDmg + end else inc(step); + stTurnReact: begin + if (not bBetweenTurns) and (not isInMultiShoot) then + begin + uStats.TurnReaction; + inc(step) + end else + inc(step, 2); + end; + stAfterDelay: begin + if delay = 0 then + delay:= cInactDelay + else + dec(delay); - if delay = 0 then - inc(step) - end; - stChWin: begin - CheckForWin; - inc(step) - end; - stWater: if (not bBetweenTurns) and (not isInMultiShoot) then - begin - if TotalRounds = cSuddenDTurns + 2 then bWaterRising:= true; + if delay = 0 then + inc(step) + end; + stChWin: begin + CheckForWin; + inc(step) + end; + stWater: if (not bBetweenTurns) and (not isInMultiShoot) then + begin + if TotalRounds = cSuddenDTurns + 2 then bWaterRising:= true; - if bWaterRising then - AddGear(0, 0, gtWaterUp, 0, _0, _0, 0); + if bWaterRising then + AddGear(0, 0, gtWaterUp, 0, _0, _0, 0); - inc(step) - end else inc(step); - stChWin2: begin - CheckForWin; - inc(step) - end; - stHealth: begin - if (TotalRounds = cSuddenDTurns) and (cHealthDecrease = 0) then - begin - cHealthDecrease:= 5; - AddCaption(trmsg[sidSuddenDeath], cWhiteColor, capgrpGameState); - playSound(sndSuddenDeath) - end; + inc(step) + end else inc(step); + stChWin2: begin + CheckForWin; + inc(step) + end; + stHealth: begin + if (TotalRounds = cSuddenDTurns) and (cHealthDecrease = 0) then + begin + cHealthDecrease:= 5; + AddCaption(trmsg[sidSuddenDeath], cWhiteColor, capgrpGameState); + playSound(sndSuddenDeath) + end; - if bBetweenTurns - or isInMultiShoot - or (TotalRounds = 0) then inc(step) - else begin - bBetweenTurns:= true; - HealthMachine; + if bBetweenTurns + or isInMultiShoot + or (TotalRounds = 0) then inc(step) + else begin + bBetweenTurns:= true; + HealthMachine; if cHealthDecrease > 0 then SuddenDeathDmg:= true; - step:= stChDmg - end - end; - stSpawn: begin - if not isInMultiShoot then SpawnBoxOfSmth; - inc(step) - end; - stNTurn: begin - if isInMultiShoot then - isInMultiShoot:= false - else begin - // delayed till after 0.9.12 - // reset to default zoom - //ZoomValue:= ZoomDefault; - with CurrentHedgehog^ do - if (Gear <> nil) + step:= stChDmg + end + end; + stSpawn: begin + if not isInMultiShoot then SpawnBoxOfSmth; + inc(step) + end; + stNTurn: begin + if isInMultiShoot then + isInMultiShoot:= false + else begin + // delayed till after 0.9.12 + // reset to default zoom + //ZoomValue:= ZoomDefault; + with CurrentHedgehog^ do + if (Gear <> nil) and ((Gear^.State and gstAttacked) = 0) - and (MultiShootAttacks > 0) then OnUsedAmmo(CurrentHedgehog^); - - ResetUtilities; + and (MultiShootAttacks > 0) then OnUsedAmmo(CurrentHedgehog^); + + ResetUtilities; - FreeActionsList; // could send -left, -right and similar commands, so should be called before /nextturn + FreeActionsList; // could send -left, -right and similar commands, so should be called before /nextturn - ParseCommand('/nextturn', true); - SwitchHedgehog; + ParseCommand('/nextturn', true); + SwitchHedgehog; - AfterSwitchHedgehog; - bBetweenTurns:= false - end; - step:= Low(step) - end; - end; + AfterSwitchHedgehog; + bBetweenTurns:= false + end; + step:= Low(step) + end; + end; if TurnTimeLeft > 0 then - if CurrentHedgehog^.Gear <> nil then - if ((CurrentHedgehog^.Gear^.State and gstAttacking) = 0) - and not isInMultiShoot then - begin - if (TurnTimeLeft = 5000) + if CurrentHedgehog^.Gear <> nil then + if ((CurrentHedgehog^.Gear^.State and gstAttacking) = 0) + and not isInMultiShoot then + begin + if (TurnTimeLeft = 5000) and (not PlacingHogs) - and (CurrentHedgehog^.Gear <> nil) - and ((CurrentHedgehog^.Gear^.State and gstAttacked) = 0) then - PlaySound(sndHurry, CurrentTeam^.voicepack); - dec(TurnTimeLeft) - end; + and (CurrentHedgehog^.Gear <> nil) + and ((CurrentHedgehog^.Gear^.State and gstAttacked) = 0) then + PlaySound(sndHurry, CurrentTeam^.voicepack); + dec(TurnTimeLeft) + end; if skipFlag then - begin - TurnTimeLeft:= 0; - skipFlag:= false - end; + begin + TurnTimeLeft:= 0; + skipFlag:= false + end; if ((GameTicks and $FFFF) = $FFFF) then - begin - if (not CurrentTeam^.ExtDriven) then - SendIPCTimeInc; + begin + if (not CurrentTeam^.ExtDriven) then + SendIPCTimeInc; - if (not CurrentTeam^.ExtDriven) or CurrentTeam^.hasGone then - inc(hiTicks) // we do not recieve a message for this - end; + if (not CurrentTeam^.ExtDriven) or CurrentTeam^.hasGone then + inc(hiTicks) // we do not recieve a message for this + end; inc(GameTicks) end; @@ -788,11 +788,11 @@ procedure ApplyDamage(Gear: PGear; Damage: Longword); var s: shortstring; vampDmg, tmpDmg, i: Longword; - vg: PVisualGear; + vg: PVisualGear; begin - if (Gear^.Kind = gtHedgehog) and (Damage>=1) then + if (Gear^.Kind = gtHedgehog) and (Damage>=1) then begin - AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), Damage, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color); + AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), Damage, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color); tmpDmg:= min(Damage, max(0,Gear^.Health-Gear^.Damage)); if (Gear <> CurrentHedgehog^.Gear) and (CurrentHedgehog^.Gear <> nil) and (tmpDmg >= 1) then begin @@ -809,13 +809,13 @@ AddCaption(s, CurrentHedgehog^.Team^.Clan^.Color, capgrpAmmoinfo); RenderHealth(CurrentHedgehog^); RecountTeamHealth(CurrentHedgehog^.Team); - i:= 0; - while i < vampDmg do - begin - vg:= AddVisualGear(hwRound(CurrentHedgehog^.Gear^.X), hwRound(CurrentHedgehog^.Gear^.Y), vgtHealth); - if vg <> nil then vg^.Frame:= 10; - inc(i, 5); - end; + i:= 0; + while i < vampDmg do + begin + vg:= AddVisualGear(hwRound(CurrentHedgehog^.Gear^.X), hwRound(CurrentHedgehog^.Gear^.Y), vgtHealth); + if vg <> nil then vg^.Frame:= 10; + inc(i, 5); + end; end end; if ((GameFlags and gfKarma) <> 0) and @@ -829,7 +829,7 @@ end; end; end; - inc(Gear^.Damage, Damage); + inc(Gear^.Damage, Damage); end; procedure SetAllToActive; @@ -838,10 +838,10 @@ AllInactive:= false; t:= GearsList; while t <> nil do - begin - t^.Active:= true; - t:= t^.NextGear - end + begin + t^.Active:= true; + t:= t^.NextGear + end end; procedure SetAllHHToActive; @@ -850,40 +850,40 @@ AllInactive:= false; t:= GearsList; while t <> nil do - begin - if t^.Kind = gtHedgehog then t^.Active:= true; - t:= t^.NextGear - end + begin + if t^.Kind = gtHedgehog then t^.Active:= true; + t:= t^.NextGear + end end; procedure DrawAltWeapon(Gear: PGear; sx, sy: LongInt); begin with PHedgehog(Gear^.Hedgehog)^ do - begin - if not (((Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) and ((Gear^.State and gstAttacked) = 0)) then - exit; - DrawTexture(round(sx + 16), round(sy + 16), ropeIconTex); - DrawTextureF(SpritesData[sprAMAmmos].Texture, 0.75, round(sx + 30), round(sy + 30), ord(Ammo^[CurSlot, CurAmmo].AmmoType) - 1, 1, 32, 32); - end; + begin + if not (((Ammoz[Ammo^[CurSlot, CurAmmo].AmmoType].Ammo.Propz and ammoprop_AltUse) <> 0) and ((Gear^.State and gstAttacked) = 0)) then + exit; + DrawTexture(round(sx + 16), round(sy + 16), ropeIconTex); + DrawTextureF(SpritesData[sprAMAmmos].Texture, 0.75, round(sx + 30), round(sy + 30), ord(Ammo^[CurSlot, CurAmmo].AmmoType) - 1, 1, 32, 32); + end; end; procedure DrawHH(Gear: PGear); var i, t: LongInt; - amt: TAmmoType; - hx, hy, cx, cy, tx, ty, sx, sy, m: LongInt; // hedgehog, crosshair, temp, sprite, direction - lx, ly, dx, dy, ax, ay, aAngle, dAngle, hAngle: real; // laser, change - defaultPos, HatVisible: boolean; - VertexBuffer: array [0..1] of TVertex2f; + amt: TAmmoType; + hx, hy, cx, cy, tx, ty, sx, sy, m: LongInt; // hedgehog, crosshair, temp, sprite, direction + lx, ly, dx, dy, ax, ay, aAngle, dAngle, hAngle: real; // laser, change + defaultPos, HatVisible: boolean; + VertexBuffer: array [0..1] of TVertex2f; begin if PHedgehog(Gear^.Hedgehog)^.Unplaced then exit; m:= 1; if ((Gear^.State and gstHHHJump) <> 0) and not cArtillery then m:= -1; if (Gear^.State and gstHHDeath) <> 0 then - begin - DrawSprite(sprHHDeath, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 26 + WorldDy, Gear^.Pos); - exit - end; + begin + DrawSprite(sprHHDeath, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 26 + WorldDy, Gear^.Pos); + exit + end; defaultPos:= true; HatVisible:= false; @@ -892,142 +892,142 @@ sy:= hwRound(Gear^.Y) - 3 + WorldDy; if ((Gear^.State and gstWinner) <> 0) and ((CurAmmoGear = nil) or (CurAmmoGear^.Kind <> gtPickHammer)) then - begin - DrawHedgehog(sx, sy, - hwSign(Gear^.dX), - 2, - 0, - 0); - defaultPos:= false - end; + begin + DrawHedgehog(sx, sy, + hwSign(Gear^.dX), + 2, + 0, + 0); + defaultPos:= false + end; if (Gear^.State and gstDrowning) <> 0 then - begin - DrawHedgehog(sx, sy, - hwSign(Gear^.dX), - 1, - 7, - 0); - defaultPos:= false - end else + begin + DrawHedgehog(sx, sy, + hwSign(Gear^.dX), + 1, + 7, + 0); + defaultPos:= false + end else if (Gear^.State and gstLoser) <> 0 then // for now using the jackhammer for its kind of bemused "oops" look - begin - DrawHedgehog(sx, sy, - hwSign(Gear^.dX), - 2, - 3, - 0); - defaultPos:= false - end else + begin + DrawHedgehog(sx, sy, + hwSign(Gear^.dX), + 2, + 3, + 0); + defaultPos:= false + end else if (Gear^.State and gstHHDriven) <> 0 then - begin - if ((Gear^.State and gstHHThinking) = 0) and + begin + if ((Gear^.State and gstHHThinking) = 0) and ShowCrosshair and ((Gear^.State and (gstAttacked or gstAnimation)) = 0) then - begin + begin (* These calculations are a little complex for a few reasons: 1: I need to draw the laser from weapon origin to nearest land 2: I need to start the beam outside the hedgie for attractiveness. 3: I need to extend the beam beyond land. This routine perhaps should be pushed into uStore or somesuch instead of continuuing the increase in size of this function. *) - dx:= hwSign(Gear^.dX) * m * Sin(Gear^.Angle * pi / cMaxAngle); - dy:= - Cos(Gear^.Angle * pi / cMaxAngle); - if cLaserSighting then - begin - lx:= hwRound(Gear^.X); - ly:= hwRound(Gear^.Y); - lx:= lx + dx * 16; - ly:= ly + dy * 16; + dx:= hwSign(Gear^.dX) * m * Sin(Gear^.Angle * pi / cMaxAngle); + dy:= - Cos(Gear^.Angle * pi / cMaxAngle); + if cLaserSighting then + begin + lx:= hwRound(Gear^.X); + ly:= hwRound(Gear^.Y); + lx:= lx + dx * 16; + ly:= ly + dy * 16; - ax:= dx * 4; - ay:= dy * 4; + ax:= dx * 4; + ay:= dy * 4; - tx:= round(lx); - ty:= round(ly); - hx:= tx; - hy:= ty; - while ((ty and LAND_HEIGHT_MASK) = 0) and - ((tx and LAND_WIDTH_MASK) = 0) and - (Land[ty, tx] = 0) do - begin - lx:= lx + ax; - ly:= ly + ay; - tx:= round(lx); - ty:= round(ly) - end; - // reached edge of land. assume infinite beam. Extend it way out past camera - if ((ty and LAND_HEIGHT_MASK) <> 0) or ((tx and LAND_WIDTH_MASK) <> 0) then - begin - tx:= round(lx + ax * (LAND_WIDTH div 4)); - ty:= round(ly + ay * (LAND_WIDTH div 4)); - end; + tx:= round(lx); + ty:= round(ly); + hx:= tx; + hy:= ty; + while ((ty and LAND_HEIGHT_MASK) = 0) and + ((tx and LAND_WIDTH_MASK) = 0) and + (Land[ty, tx] = 0) do + begin + lx:= lx + ax; + ly:= ly + ay; + tx:= round(lx); + ty:= round(ly) + end; + // reached edge of land. assume infinite beam. Extend it way out past camera + if ((ty and LAND_HEIGHT_MASK) <> 0) or ((tx and LAND_WIDTH_MASK) <> 0) then + begin + tx:= round(lx + ax * (LAND_WIDTH div 4)); + ty:= round(ly + ay * (LAND_WIDTH div 4)); + end; - //if (abs(lx-tx)>8) or (abs(ly-ty)>8) then - begin - glDisable(GL_TEXTURE_2D); - glEnable(GL_LINE_SMOOTH); + //if (abs(lx-tx)>8) or (abs(ly-ty)>8) then + begin + glDisable(GL_TEXTURE_2D); + glEnable(GL_LINE_SMOOTH); - glLineWidth(1.0); + glLineWidth(1.0); - glColor4ub($FF, $00, $00, $C0); - VertexBuffer[0].X:= hx + WorldDx; - VertexBuffer[0].Y:= hy + WorldDy; - VertexBuffer[1].X:= tx + WorldDx; - VertexBuffer[1].Y:= ty + WorldDy; + glColor4ub($FF, $00, $00, $C0); + VertexBuffer[0].X:= hx + WorldDx; + VertexBuffer[0].Y:= hy + WorldDy; + VertexBuffer[1].X:= tx + WorldDx; + VertexBuffer[1].Y:= ty + WorldDy; - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); - glDrawArrays(GL_LINES, 0, Length(VertexBuffer)); - glColor4f(1, 1, 1, 1); - glEnable(GL_TEXTURE_2D); - glDisable(GL_LINE_SMOOTH); - end; - end; - // draw crosshair - cx:= Round(hwRound(Gear^.X) + dx * 80); - cy:= Round(hwRound(Gear^.Y) + dy * 80); - DrawRotatedTex(PHedgehog(Gear^.Hedgehog)^.Team^.CrosshairTex, - 12, 12, cx + WorldDx, cy + WorldDy, 0, - hwSign(Gear^.dX) * (Gear^.Angle * 180.0) / cMaxAngle); - end; - hx:= hwRound(Gear^.X) + 1 + 8 * hwSign(Gear^.dX) + WorldDx; - hy:= hwRound(Gear^.Y) - 2 + WorldDy; - aangle:= Gear^.Angle * 180 / cMaxAngle - 90; + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); + glDrawArrays(GL_LINES, 0, Length(VertexBuffer)); + glColor4f(1, 1, 1, 1); + glEnable(GL_TEXTURE_2D); + glDisable(GL_LINE_SMOOTH); + end; + end; + // draw crosshair + cx:= Round(hwRound(Gear^.X) + dx * 80); + cy:= Round(hwRound(Gear^.Y) + dy * 80); + DrawRotatedTex(PHedgehog(Gear^.Hedgehog)^.Team^.CrosshairTex, + 12, 12, cx + WorldDx, cy + WorldDy, 0, + hwSign(Gear^.dX) * (Gear^.Angle * 180.0) / cMaxAngle); + end; + hx:= hwRound(Gear^.X) + 1 + 8 * hwSign(Gear^.dX) + WorldDx; + hy:= hwRound(Gear^.Y) - 2 + WorldDy; + aangle:= Gear^.Angle * 180 / cMaxAngle - 90; - if CurAmmoGear <> nil then - begin - case CurAmmoGear^.Kind of - gtShotgunShot: begin - if (CurAmmoGear^.State and gstAnimation <> 0) then - DrawRotated(sprShotgun, hx, hy, hwSign(Gear^.dX), aangle) - else - DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle); - end; - gtDEagleShot: DrawRotated(sprDEagle, hx, hy, hwSign(Gear^.dX), aangle); - gtSniperRifleShot: begin - if (CurAmmoGear^.State and gstAnimation <> 0) then - DrawRotatedF(sprSniperRifle, hx, hy, 1, hwSign(Gear^.dX), aangle) - else - DrawRotatedF(sprSniperRifle, hx, hy, 0, hwSign(Gear^.dX), aangle) - end; - gtBallgun: DrawRotated(sprHandBallgun, hx, hy, hwSign(Gear^.dX), aangle); - gtRCPlane: begin - DrawRotated(sprHandPlane, hx, hy, hwSign(Gear^.dX), 0); - defaultPos:= false - end; - gtRope: begin - if Gear^.X < CurAmmoGear^.X then - begin - dAngle:= 0; - hAngle:= 180; - i:= 1 - end else - begin - dAngle:= 180; - hAngle:= 0; - i:= -1 - end; + if CurAmmoGear <> nil then + begin + case CurAmmoGear^.Kind of + gtShotgunShot: begin + if (CurAmmoGear^.State and gstAnimation <> 0) then + DrawRotated(sprShotgun, hx, hy, hwSign(Gear^.dX), aangle) + else + DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle); + end; + gtDEagleShot: DrawRotated(sprDEagle, hx, hy, hwSign(Gear^.dX), aangle); + gtSniperRifleShot: begin + if (CurAmmoGear^.State and gstAnimation <> 0) then + DrawRotatedF(sprSniperRifle, hx, hy, 1, hwSign(Gear^.dX), aangle) + else + DrawRotatedF(sprSniperRifle, hx, hy, 0, hwSign(Gear^.dX), aangle) + end; + gtBallgun: DrawRotated(sprHandBallgun, hx, hy, hwSign(Gear^.dX), aangle); + gtRCPlane: begin + DrawRotated(sprHandPlane, hx, hy, hwSign(Gear^.dX), 0); + defaultPos:= false + end; + gtRope: begin + if Gear^.X < CurAmmoGear^.X then + begin + dAngle:= 0; + hAngle:= 180; + i:= 1 + end else + begin + dAngle:= 180; + hAngle:= 0; + i:= -1 + end; sx:= hwRound(Gear^.X) + WorldDx; sy:= hwRound(Gear^.Y) + WorldDy; if ((Gear^.State and gstWinner) = 0) then @@ -1042,16 +1042,16 @@ DrawRotatedTextureF(HatTex, 1.0, -1.0, -6.0, sx, sy, 0, i, 32, 32, i*DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + hAngle); end; - DrawAltWeapon(Gear, sx, sy); - defaultPos:= false - end; - gtBlowTorch: begin - DrawRotated(sprBlowTorch, hx, hy, hwSign(Gear^.dX), aangle); - DrawHedgehog(sx, sy, - hwSign(Gear^.dX), - 3, - PHedgehog(Gear^.Hedgehog)^.visStepPos div 2, - 0); + DrawAltWeapon(Gear, sx, sy); + defaultPos:= false + end; + gtBlowTorch: begin + DrawRotated(sprBlowTorch, hx, hy, hwSign(Gear^.dX), aangle); + DrawHedgehog(sx, sy, + hwSign(Gear^.dX), + 3, + PHedgehog(Gear^.Hedgehog)^.visStepPos div 2, + 0); with PHedgehog(Gear^.Hedgehog)^ do if (HatTex <> nil) then DrawTextureF(HatTex, @@ -1062,137 +1062,137 @@ hwSign(Gear^.dX), 32, 32); - defaultPos:= false - end; - gtShover: DrawRotated(sprHandBaseball, hx, hy, hwSign(Gear^.dX), aangle + 180); - gtFirePunch: begin - DrawHedgehog(sx, sy, - hwSign(Gear^.dX), - 1, - 4, - 0); - defaultPos:= false - end; - gtPickHammer: begin + defaultPos:= false + end; + gtShover: DrawRotated(sprHandBaseball, hx, hy, hwSign(Gear^.dX), aangle + 180); + gtFirePunch: begin + DrawHedgehog(sx, sy, + hwSign(Gear^.dX), + 1, + 4, + 0); + defaultPos:= false + end; + gtPickHammer: begin defaultPos:= false; dec(sy,20); end; - gtTeleport: defaultPos:= false; - gtWhip: begin - DrawRotatedF(sprWhip, - sx, - sy, - 1, - hwSign(Gear^.dX), - 0); - defaultPos:= false - end; - gtKamikaze: begin - if CurAmmoGear^.Pos = 0 then - DrawHedgehog(sx, sy, - hwSign(Gear^.dX), - 1, - 6, - 0) - else - DrawRotatedF(sprKamikaze, - hwRound(Gear^.X) + WorldDx, - hwRound(Gear^.Y) + WorldDy, - CurAmmoGear^.Pos - 1, - hwSign(Gear^.dX), - aangle); - defaultPos:= false - end; - gtSeduction: begin - if CurAmmoGear^.Pos >= 6 then - DrawHedgehog(sx, sy, - hwSign(Gear^.dX), - 2, - 2, - 0) - else - begin - DrawRotatedF(sprDress, - hwRound(Gear^.X) + WorldDx, - hwRound(Gear^.Y) + WorldDy, - CurAmmoGear^.Pos, - hwSign(Gear^.dX), - 0); - DrawSprite(sprCensored, hwRound(Gear^.X) - 32 + WorldDx, hwRound(Gear^.Y) - 20 + WorldDy, 0) - end; - defaultPos:= false - end; - end; + gtTeleport: defaultPos:= false; + gtWhip: begin + DrawRotatedF(sprWhip, + sx, + sy, + 1, + hwSign(Gear^.dX), + 0); + defaultPos:= false + end; + gtKamikaze: begin + if CurAmmoGear^.Pos = 0 then + DrawHedgehog(sx, sy, + hwSign(Gear^.dX), + 1, + 6, + 0) + else + DrawRotatedF(sprKamikaze, + hwRound(Gear^.X) + WorldDx, + hwRound(Gear^.Y) + WorldDy, + CurAmmoGear^.Pos - 1, + hwSign(Gear^.dX), + aangle); + defaultPos:= false + end; + gtSeduction: begin + if CurAmmoGear^.Pos >= 6 then + DrawHedgehog(sx, sy, + hwSign(Gear^.dX), + 2, + 2, + 0) + else + begin + DrawRotatedF(sprDress, + hwRound(Gear^.X) + WorldDx, + hwRound(Gear^.Y) + WorldDy, + CurAmmoGear^.Pos, + hwSign(Gear^.dX), + 0); + DrawSprite(sprCensored, hwRound(Gear^.X) - 32 + WorldDx, hwRound(Gear^.Y) - 20 + WorldDy, 0) + end; + defaultPos:= false + end; + end; - case CurAmmoGear^.Kind of - gtShotgunShot, - gtDEagleShot, - gtSniperRifleShot, - gtShover: begin - DrawHedgehog(sx, sy, - hwSign(Gear^.dX), - 0, - 4, - 0); - defaultPos:= false; - HatVisible:= true - end - end - end else + case CurAmmoGear^.Kind of + gtShotgunShot, + gtDEagleShot, + gtSniperRifleShot, + gtShover: begin + DrawHedgehog(sx, sy, + hwSign(Gear^.dX), + 0, + 4, + 0); + defaultPos:= false; + HatVisible:= true + end + end + end else - if ((Gear^.State and gstHHJumping) <> 0) then - begin + if ((Gear^.State and gstHHJumping) <> 0) then + begin DrawHedgehog(sx, sy, hwSign(Gear^.dX)*m, 1, 1, 0); - HatVisible:= true; - defaultPos:= false - end else + HatVisible:= true; + defaultPos:= false + end else - if (Gear^.Message and (gm_Left or gm_Right) <> 0) and (not isCursorVisible) then - begin - DrawHedgehog(sx, sy, - hwSign(Gear^.dX), - 0, - PHedgehog(Gear^.Hedgehog)^.visStepPos div 2, - 0); - defaultPos:= false; - HatVisible:= true - end - else + if (Gear^.Message and (gm_Left or gm_Right) <> 0) and (not isCursorVisible) then + begin + DrawHedgehog(sx, sy, + hwSign(Gear^.dX), + 0, + PHedgehog(Gear^.Hedgehog)^.visStepPos div 2, + 0); + defaultPos:= false; + HatVisible:= true + end + else - if ((Gear^.State and gstAnimation) <> 0) then - begin - DrawRotatedF(Wavez[TWave(Gear^.Tag)].Sprite, - sx, - sy, - Gear^.Pos, - hwSign(Gear^.dX), - 0.0); - defaultPos:= false - end - else - if ((Gear^.State and gstAttacked) = 0) then - begin - amt:= CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].AmmoType; - case amt of - amBazooka, - amMortar: DrawRotated(sprHandBazooka, hx, hy, hwSign(Gear^.dX), aangle); - amMolotov: DrawRotated(sprHandMolotov, hx, hy, hwSign(Gear^.dX), aangle); - amBallgun: DrawRotated(sprHandBallgun, hx, hy, hwSign(Gear^.dX), aangle); - amDrill: DrawRotated(sprHandDrill, hx, hy, hwSign(Gear^.dX), aangle); - amRope: DrawRotated(sprHandRope, hx, hy, hwSign(Gear^.dX), aangle); - amShotgun: DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle); - amDEagle: DrawRotated(sprHandDEagle, hx, hy, hwSign(Gear^.dX), aangle); - amSniperRifle: DrawRotatedF(sprSniperRifle, hx, hy, 0, hwSign(Gear^.dX), aangle); - amBlowTorch: DrawRotated(sprHandBlowTorch, hx, hy, hwSign(Gear^.dX), aangle); - amRCPlane: begin - DrawRotated(sprHandPlane, hx, hy, hwSign(Gear^.dX), 0); - defaultPos:= false - end; - amGirder: begin + if ((Gear^.State and gstAnimation) <> 0) then + begin + DrawRotatedF(Wavez[TWave(Gear^.Tag)].Sprite, + sx, + sy, + Gear^.Pos, + hwSign(Gear^.dX), + 0.0); + defaultPos:= false + end + else + if ((Gear^.State and gstAttacked) = 0) then + begin + amt:= CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].AmmoType; + case amt of + amBazooka, + amMortar: DrawRotated(sprHandBazooka, hx, hy, hwSign(Gear^.dX), aangle); + amMolotov: DrawRotated(sprHandMolotov, hx, hy, hwSign(Gear^.dX), aangle); + amBallgun: DrawRotated(sprHandBallgun, hx, hy, hwSign(Gear^.dX), aangle); + amDrill: DrawRotated(sprHandDrill, hx, hy, hwSign(Gear^.dX), aangle); + amRope: DrawRotated(sprHandRope, hx, hy, hwSign(Gear^.dX), aangle); + amShotgun: DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle); + amDEagle: DrawRotated(sprHandDEagle, hx, hy, hwSign(Gear^.dX), aangle); + amSniperRifle: DrawRotatedF(sprSniperRifle, hx, hy, 0, hwSign(Gear^.dX), aangle); + amBlowTorch: DrawRotated(sprHandBlowTorch, hx, hy, hwSign(Gear^.dX), aangle); + amRCPlane: begin + DrawRotated(sprHandPlane, hx, hy, hwSign(Gear^.dX), 0); + defaultPos:= false + end; + amGirder: begin DrawSpriteClipped(sprGirder, sx-256, sy-256, @@ -1201,124 +1201,124 @@ cWaterLine+WorldDy, LongInt(leftX)+WorldDx); end; - end; + end; - case amt of - amAirAttack, - amMineStrike: DrawRotated(sprHandAirAttack, sx, hwRound(Gear^.Y) + WorldDy, hwSign(Gear^.dX), 0); - amPickHammer: DrawHedgehog(sx, sy, - hwSign(Gear^.dX), - 1, - 2, - 0); - amTeleport: DrawRotatedF(sprTeleport, sx, sy, 0, hwSign(Gear^.dX), 0); - amKamikaze: DrawHedgehog(sx, sy, - hwSign(Gear^.dX), - 1, - 5, - 0); - amWhip: DrawRotatedF(sprWhip, - sx, - sy, - 0, - hwSign(Gear^.dX), - 0); - else - DrawHedgehog(sx, sy, - hwSign(Gear^.dX), - 0, - 4, - 0); + case amt of + amAirAttack, + amMineStrike: DrawRotated(sprHandAirAttack, sx, hwRound(Gear^.Y) + WorldDy, hwSign(Gear^.dX), 0); + amPickHammer: DrawHedgehog(sx, sy, + hwSign(Gear^.dX), + 1, + 2, + 0); + amTeleport: DrawRotatedF(sprTeleport, sx, sy, 0, hwSign(Gear^.dX), 0); + amKamikaze: DrawHedgehog(sx, sy, + hwSign(Gear^.dX), + 1, + 5, + 0); + amWhip: DrawRotatedF(sprWhip, + sx, + sy, + 0, + hwSign(Gear^.dX), + 0); + else + DrawHedgehog(sx, sy, + hwSign(Gear^.dX), + 0, + 4, + 0); - HatVisible:= true; - with PHedgehog(Gear^.Hedgehog)^ do - if (HatTex <> nil) - and (HatVisibility > 0) then - DrawTextureF(HatTex, - HatVisibility, - sx, - hwRound(Gear^.Y) - 8 + WorldDy, - 0, - hwSign(Gear^.dX), - 32, - 32); - end; + HatVisible:= true; + with PHedgehog(Gear^.Hedgehog)^ do + if (HatTex <> nil) + and (HatVisibility > 0) then + DrawTextureF(HatTex, + HatVisibility, + sx, + hwRound(Gear^.Y) - 8 + WorldDy, + 0, + hwSign(Gear^.dX), + 32, + 32); + end; - case amt of - amBaseballBat: DrawRotated(sprHandBaseball, - hwRound(Gear^.X) + 1 - 4 * hwSign(Gear^.dX) + WorldDx, - hwRound(Gear^.Y) + 6 + WorldDy, hwSign(Gear^.dX), aangle); - end; + case amt of + amBaseballBat: DrawRotated(sprHandBaseball, + hwRound(Gear^.X) + 1 - 4 * hwSign(Gear^.dX) + WorldDx, + hwRound(Gear^.Y) + 6 + WorldDy, hwSign(Gear^.dX), aangle); + end; - defaultPos:= false - end; + defaultPos:= false + end; end else // not gstHHDriven - begin - if (Gear^.Damage > 0) - and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then - begin - DrawHedgehog(sx, sy, - hwSign(Gear^.dX), - 2, - 1, - Gear^.DirAngle); - defaultPos:= false - end else + begin + if (Gear^.Damage > 0) + and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then + begin + DrawHedgehog(sx, sy, + hwSign(Gear^.dX), + 2, + 1, + Gear^.DirAngle); + defaultPos:= false + end else - if ((Gear^.State and gstHHJumping) <> 0) then - begin - DrawHedgehog(sx, sy, - hwSign(Gear^.dX)*m, - 1, - 1, - 0); - defaultPos:= false - end; - end; + if ((Gear^.State and gstHHJumping) <> 0) then + begin + DrawHedgehog(sx, sy, + hwSign(Gear^.dX)*m, + 1, + 1, + 0); + defaultPos:= false + end; + end; with PHedgehog(Gear^.Hedgehog)^ do - begin - if defaultPos then - begin - DrawRotatedF(sprHHIdle, - sx, - sy, - (RealTicks div 128 + Gear^.Pos) mod 19, - hwSign(Gear^.dX), - 0); - HatVisible:= true; - end; + begin + if defaultPos then + begin + DrawRotatedF(sprHHIdle, + sx, + sy, + (RealTicks div 128 + Gear^.Pos) mod 19, + hwSign(Gear^.dX), + 0); + HatVisible:= true; + end; - if HatVisible then - if HatVisibility < 1.0 then - HatVisibility:= HatVisibility + 0.2 - else - else - if HatVisibility > 0.0 then - HatVisibility:= HatVisibility - 0.2; + if HatVisible then + if HatVisibility < 1.0 then + HatVisibility:= HatVisibility + 0.2 + else + else + if HatVisibility > 0.0 then + HatVisibility:= HatVisibility - 0.2; - if (HatTex <> nil) - and (HatVisibility > 0) then - if DefaultPos then - DrawTextureF(HatTex, - HatVisibility, - sx, - hwRound(Gear^.Y) - 8 + WorldDy, - (RealTicks div 128 + Gear^.Pos) mod 19, - hwSign(Gear^.dX), - 32, - 32) - else - DrawTextureF(HatTex, - HatVisibility, - sx, - hwRound(Gear^.Y) - 8 + WorldDy, - 0, - hwSign(Gear^.dX)*m, - 32, - 32); - end; + if (HatTex <> nil) + and (HatVisibility > 0) then + if DefaultPos then + DrawTextureF(HatTex, + HatVisibility, + sx, + hwRound(Gear^.Y) - 8 + WorldDy, + (RealTicks div 128 + Gear^.Pos) mod 19, + hwSign(Gear^.dX), + 32, + 32) + else + DrawTextureF(HatTex, + HatVisibility, + sx, + hwRound(Gear^.Y) - 8 + WorldDy, + 0, + hwSign(Gear^.dX)*m, + 32, + 32); + end; if (Gear^.State and gstHHDriven) <> 0 then begin (* if (CurAmmoGear = nil) then @@ -1332,60 +1332,60 @@ begin case CurAmmoGear^.Kind of gtJetpack: begin - DrawSprite(sprJetpack, sx-32, sy-32, 0); - if (CurAmmoGear^.MsgParam and gm_Up) <> 0 then DrawSprite(sprJetpack, sx-32, sy-32, 1); - if (CurAmmoGear^.MsgParam and gm_Left) <> 0 then DrawSprite(sprJetpack, sx-32, sy-32, 2); - if (CurAmmoGear^.MsgParam and gm_Right) <> 0 then DrawSprite(sprJetpack, sx-32, sy-32, 3); + DrawSprite(sprJetpack, sx-32, sy-32, 0); + if (CurAmmoGear^.MsgParam and gm_Up) <> 0 then DrawSprite(sprJetpack, sx-32, sy-32, 1); + if (CurAmmoGear^.MsgParam and gm_Left) <> 0 then DrawSprite(sprJetpack, sx-32, sy-32, 2); + if (CurAmmoGear^.MsgParam and gm_Right) <> 0 then DrawSprite(sprJetpack, sx-32, sy-32, 3); if CurAmmoGear^.Tex <> nil then DrawCentered(sx, sy - 40, CurAmmoGear^.Tex); - DrawAltWeapon(Gear, sx, sy) + DrawAltWeapon(Gear, sx, sy) end; end; end end; with PHedgehog(Gear^.Hedgehog)^ do - begin - if ((Gear^.State and not gstWinner) = 0) - or (bShowFinger and ((Gear^.State and gstHHDriven) <> 0)) then - begin - t:= hwRound(Gear^.Y) - cHHRadius - 12 + WorldDy; - if (cTagsMask and htTransparent) <> 0 then - glColor4f(1, 1, 1, 0.5); - if ((cTagsMask and htHealth) <> 0) then - begin - dec(t, HealthTagTex^.h + 2); - DrawCentered(hwRound(Gear^.X) + WorldDx, t, HealthTagTex) - end; - if (cTagsMask and htName) <> 0 then - begin - dec(t, NameTagTex^.h + 2); - DrawCentered(hwRound(Gear^.X) + WorldDx, t, NameTagTex) - end; - if (cTagsMask and htTeamName) <> 0 then - begin - dec(t, Team^.NameTagTex^.h + 2); - DrawCentered(hwRound(Gear^.X) + WorldDx, t, Team^.NameTagTex) - end; - if (cTagsMask and htTransparent) <> 0 then - glColor4f(1, 1, 1, 1) - end; - if (Gear^.State and gstHHDriven) <> 0 then // Current hedgehog - begin - if bShowFinger and ((Gear^.State and gstHHDriven) <> 0) then - DrawSprite(sprFinger, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 64 + WorldDy, - GameTicks div 32 mod 16); + begin + if ((Gear^.State and not gstWinner) = 0) + or (bShowFinger and ((Gear^.State and gstHHDriven) <> 0)) then + begin + t:= hwRound(Gear^.Y) - cHHRadius - 12 + WorldDy; + if (cTagsMask and htTransparent) <> 0 then + glColor4f(1, 1, 1, 0.5); + if ((cTagsMask and htHealth) <> 0) then + begin + dec(t, HealthTagTex^.h + 2); + DrawCentered(hwRound(Gear^.X) + WorldDx, t, HealthTagTex) + end; + if (cTagsMask and htName) <> 0 then + begin + dec(t, NameTagTex^.h + 2); + DrawCentered(hwRound(Gear^.X) + WorldDx, t, NameTagTex) + end; + if (cTagsMask and htTeamName) <> 0 then + begin + dec(t, Team^.NameTagTex^.h + 2); + DrawCentered(hwRound(Gear^.X) + WorldDx, t, Team^.NameTagTex) + end; + if (cTagsMask and htTransparent) <> 0 then + glColor4f(1, 1, 1, 1) + end; + if (Gear^.State and gstHHDriven) <> 0 then // Current hedgehog + begin + if bShowFinger and ((Gear^.State and gstHHDriven) <> 0) then + DrawSprite(sprFinger, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 64 + WorldDy, + GameTicks div 32 mod 16); - if (Gear^.State and gstDrowning) = 0 then - if (Gear^.State and gstHHThinking) <> 0 then - DrawSprite(sprQuestion, hwRound(Gear^.X) - 10 + WorldDx, hwRound(Gear^.Y) - cHHRadius - 34 + WorldDy, 0) - end - end; + if (Gear^.State and gstDrowning) = 0 then + if (Gear^.State and gstHHThinking) <> 0 then + DrawSprite(sprQuestion, hwRound(Gear^.X) - 10 + WorldDx, hwRound(Gear^.Y) - cHHRadius - 34 + WorldDy, 0) + end + end; if Gear^.Invulnerable then begin glColor4f(1, 1, 1, 0.25 + abs(1 - ((RealTicks div 2) mod 1500) / 750)); - DrawSprite(sprInvulnerable, sx - 24, sy - 24, 0); - glColor4f(1, 1, 1, 1); + DrawSprite(sprInvulnerable, sx - 24, sy - 24, 0); + glColor4f(1, 1, 1, 1); end; if cVampiric and (CurrentHedgehog^.Gear <> nil) and @@ -1393,141 +1393,141 @@ begin glColor4f(1, 1, 1, 0.25 + abs(1 - (RealTicks mod 1500) / 750)); DrawSprite(sprVampiric, sx - 24, sy - 24, 0); - glColor4f(1, 1, 1, 1); + glColor4f(1, 1, 1, 1); end; end; procedure DrawRopeLinesRQ(Gear: PGear); begin with RopePoints do - begin - rounded[Count].X:= hwRound(Gear^.X); - rounded[Count].Y:= hwRound(Gear^.Y); - rounded[Count + 1].X:= hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X); - rounded[Count + 1].Y:= hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y); - end; + begin + rounded[Count].X:= hwRound(Gear^.X); + rounded[Count].Y:= hwRound(Gear^.Y); + rounded[Count + 1].X:= hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X); + rounded[Count + 1].Y:= hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y); + end; if (RopePoints.Count > 0) or (Gear^.Elasticity.QWordValue > 0) then - begin - glDisable(GL_TEXTURE_2D); - //glEnable(GL_LINE_SMOOTH); + begin + glDisable(GL_TEXTURE_2D); + //glEnable(GL_LINE_SMOOTH); - glPushMatrix; + glPushMatrix; - glTranslatef(WorldDx, WorldDy, 0); + glTranslatef(WorldDx, WorldDy, 0); - glLineWidth(4.0); + glLineWidth(4.0); - glColor4f(0.8, 0.8, 0.8, 1); + glColor4f(0.8, 0.8, 0.8, 1); - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(2, GL_FLOAT, 0, @RopePoints.rounded[0]); - glDrawArrays(GL_LINE_STRIP, 0, RopePoints.Count + 2); - glColor4f(1, 1, 1, 1); + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, @RopePoints.rounded[0]); + glDrawArrays(GL_LINE_STRIP, 0, RopePoints.Count + 2); + glColor4f(1, 1, 1, 1); - glPopMatrix; + glPopMatrix; - glEnable(GL_TEXTURE_2D); - //glDisable(GL_LINE_SMOOTH) - end + glEnable(GL_TEXTURE_2D); + //glDisable(GL_LINE_SMOOTH) + end end; procedure DrawRope(Gear: PGear); var roplen: LongInt; - i: Longword; + i: Longword; - procedure DrawRopeLine(X1, Y1, X2, Y2: LongInt); - var eX, eY, dX, dY: LongInt; - i, sX, sY, x, y, d: LongInt; - b: boolean; - begin - if (X1 = X2) and (Y1 = Y2) then - begin - //OutError('WARNING: zero length rope line!', false); - exit - end; - eX:= 0; - eY:= 0; - dX:= X2 - X1; - dY:= Y2 - Y1; + procedure DrawRopeLine(X1, Y1, X2, Y2: LongInt); + var eX, eY, dX, dY: LongInt; + i, sX, sY, x, y, d: LongInt; + b: boolean; + begin + if (X1 = X2) and (Y1 = Y2) then + begin + //OutError('WARNING: zero length rope line!', false); + exit + end; + eX:= 0; + eY:= 0; + dX:= X2 - X1; + dY:= Y2 - Y1; - if (dX > 0) then sX:= 1 - else - if (dX < 0) then - begin - sX:= -1; - dX:= -dX - end else sX:= dX; + if (dX > 0) then sX:= 1 + else + if (dX < 0) then + begin + sX:= -1; + dX:= -dX + end else sX:= dX; - if (dY > 0) then sY:= 1 - else - if (dY < 0) then - begin - sY:= -1; - dY:= -dY - end else sY:= dY; + if (dY > 0) then sY:= 1 + else + if (dY < 0) then + begin + sY:= -1; + dY:= -dY + end else sY:= dY; - if (dX > dY) then d:= dX - else d:= dY; + if (dX > dY) then d:= dX + else d:= dY; - x:= X1; - y:= Y1; + x:= X1; + y:= Y1; - for i:= 0 to d do - begin - inc(eX, dX); - inc(eY, dY); - b:= false; - if (eX > d) then - begin - dec(eX, d); - inc(x, sX); - b:= true - end; - if (eY > d) then - begin - dec(eY, d); - inc(y, sY); - b:= true - end; - if b then - begin - inc(roplen); - if (roplen mod 4) = 0 then DrawSprite(sprRopeNode, x - 2, y - 2, 0) - end - end - end; + for i:= 0 to d do + begin + inc(eX, dX); + inc(eY, dY); + b:= false; + if (eX > d) then + begin + dec(eX, d); + inc(x, sX); + b:= true + end; + if (eY > d) then + begin + dec(eY, d); + inc(y, sY); + b:= true + end; + if b then + begin + inc(roplen); + if (roplen mod 4) = 0 then DrawSprite(sprRopeNode, x - 2, y - 2, 0) + end + end + end; begin - if cReducedQuality then - DrawRopeLinesRQ(Gear) - else - begin - roplen:= 0; - if RopePoints.Count > 0 then - begin - i:= 0; - while i < Pred(RopePoints.Count) do - begin - DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy, - hwRound(RopePoints.ar[Succ(i)].X) + WorldDx, hwRound(RopePoints.ar[Succ(i)].Y) + WorldDy); - inc(i) - end; - DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy, - hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy); - DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, - hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X) + WorldDx, hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y) + WorldDy); - end else - if Gear^.Elasticity.QWordValue > 0 then - DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, - hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X) + WorldDx, hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y) + WorldDy); - end; + if cReducedQuality then + DrawRopeLinesRQ(Gear) + else + begin + roplen:= 0; + if RopePoints.Count > 0 then + begin + i:= 0; + while i < Pred(RopePoints.Count) do + begin + DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy, + hwRound(RopePoints.ar[Succ(i)].X) + WorldDx, hwRound(RopePoints.ar[Succ(i)].Y) + WorldDy); + inc(i) + end; + DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy, + hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy); + DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, + hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X) + WorldDx, hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y) + WorldDy); + end else + if Gear^.Elasticity.QWordValue > 0 then + DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, + hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.X) + WorldDx, hwRound(PHedgehog(Gear^.Hedgehog)^.Gear^.Y) + WorldDy); + end; if RopePoints.Count > 0 then - DrawRotated(sprRopeHook, hwRound(RopePoints.ar[0].X) + WorldDx, hwRound(RopePoints.ar[0].Y) + WorldDy, 1, RopePoints.HookAngle) - else - if Gear^.Elasticity.QWordValue > 0 then - DrawRotated(sprRopeHook, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); + DrawRotated(sprRopeHook, hwRound(RopePoints.ar[0].X) + WorldDx, hwRound(RopePoints.ar[0].Y) + WorldDy, 1, RopePoints.HookAngle) + else + if Gear^.Elasticity.QWordValue > 0 then + DrawRotated(sprRopeHook, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); end; procedure DrawGears; @@ -1536,10 +1536,10 @@ begin Gear:= GearsList; while Gear<>nil do - begin - case Gear^.Kind of + begin + case Gear^.Kind of gtAmmo_Bomb: DrawRotated(sprBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle); - gtMolotov: DrawRotated(sprMolotov, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle); + gtMolotov: DrawRotated(sprMolotov, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle); gtRCPlane: begin if (Gear^.Tag = -1) then @@ -1547,7 +1547,7 @@ else DrawRotated(sprPlane, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,0,DxDy2Angle(Gear^.dY, Gear^.dX)); if ((TrainingFlags and tfRCPlane) <> 0) and (TrainingTargetGear <> nil) and ((Gear^.State and gstDrowning) = 0) then - DrawRotatedf(sprFinger, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, GameTicks div 32 mod 16, 0, DxDy2Angle(Gear^.X - TrainingTargetGear^.X, TrainingTargetGear^.Y - Gear^.Y)); + DrawRotatedf(sprFinger, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, GameTicks div 32 mod 16, 0, DxDy2Angle(Gear^.X - TrainingTargetGear^.X, TrainingTargetGear^.Y - Gear^.Y)); end; gtBall: DrawRotatedf(sprBalls, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tag,0, DxDy2Angle(Gear^.dY, Gear^.dX)); @@ -1602,9 +1602,9 @@ gtCluster: DrawSprite(sprClusterParticle, hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy, 0); gtFlame: DrawTextureF(SpritesData[sprFlame].Texture, 2 / (Gear^.Tag mod 3 + 2), hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, (GameTicks div 128 + LongWord(Gear^.Tag)) mod 8, 1, 16, 16); gtParachute: begin - DrawSprite(sprParachute, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 48 + WorldDy, 0); - DrawAltWeapon(Gear, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy) - end; + DrawSprite(sprParachute, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 48 + WorldDy, 0); + DrawAltWeapon(Gear, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy) + end; gtAirAttack: if Gear^.Tag > 0 then DrawSprite(sprAirplane, hwRound(Gear^.X) - SpritesData[sprAirplane].Width div 2 + WorldDx, hwRound(Gear^.Y) - SpritesData[sprAirplane].Height div 2 + WorldDy, 0) else DrawSprite(sprAirplane, hwRound(Gear^.X) - SpritesData[sprAirplane].Width div 2 + WorldDx, hwRound(Gear^.Y) - SpritesData[sprAirplane].Height div 2 + WorldDy, 1); gtAirBomb: DrawRotated(sprAirBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); @@ -1615,10 +1615,10 @@ end; gtSwitcher: DrawSprite(sprSwitch, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 56 + WorldDy, (GameTicks shr 6) mod 12); gtTarget: begin - glColor4f(1, 1, 1, Gear^.Timer / 1000); - DrawSprite(sprTarget, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0); - glColor4f(1, 1, 1, 1); - end; + glColor4f(1, 1, 1, Gear^.Timer / 1000); + DrawSprite(sprTarget, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0); + glColor4f(1, 1, 1, 1); + end; gtMortar: DrawRotated(sprMortar, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX)); gtCake: if Gear^.Pos = 6 then DrawRotatedf(sprCakeWalk, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, (GameTicks div 40) mod 6, hwSign(Gear^.dX), Gear^.DirAngle * hwSign(Gear^.dX) + 90) @@ -1638,46 +1638,46 @@ procedure FreeGearsList; var t, tt: PGear; begin - tt:= GearsList; - GearsList:= nil; - while tt <> nil do - begin - t:= tt; - tt:= tt^.NextGear; - Dispose(t) - end; + tt:= GearsList; + GearsList:= nil; + while tt <> nil do + begin + t:= tt; + tt:= tt^.NextGear; + Dispose(t) + end; end; procedure AddMiscGears; var i: LongInt; - Gear: PGear; + Gear: PGear; begin AddGear(0, 0, gtATStartGame, 0, _0, _0, 2000); if (TrainingFlags and tfSpawnTargets) <> 0 then - begin - TrainingTargetGear:= AddGear(0, 0, gtTarget, 0, _0, _0, 0); - FindPlace(TrainingTargetGear, false, 0, LAND_WIDTH); - end; + begin + TrainingTargetGear:= AddGear(0, 0, gtTarget, 0, _0, _0, 0); + FindPlace(TrainingTargetGear, false, 0, LAND_WIDTH); + end; if ((GameFlags and gfForts) = 0) then - begin - // TODO: exclude each other or allow both, mines and explosives, on same map? - if ((GameFlags and gfMines) <> 0) then - for i:= 0 to Pred(cLandAdditions) do - begin - Gear:= AddGear(0, 0, gtMine, 0, _0, _0, 0); - Gear^.TriggerId:= i + 1; - FindPlace(Gear, false, 0, LAND_WIDTH); - end; + begin + // TODO: exclude each other or allow both, mines and explosives, on same map? + if ((GameFlags and gfMines) <> 0) then + for i:= 0 to Pred(cLandAdditions) do + begin + Gear:= AddGear(0, 0, gtMine, 0, _0, _0, 0); + Gear^.TriggerId:= i + 1; + FindPlace(Gear, false, 0, LAND_WIDTH); + end; // No game flag for this for now -// if ((GameFlags and gfExplosives) <> 0) then - for i:= 0 to Pred(cExplosives) do - begin - Gear:= AddGear(0, 0, gtExplosives, 0, _0, _0, 0); - FindPlace(Gear, false, 0, LAND_WIDTH); - end; - end; +// if ((GameFlags and gfExplosives) <> 0) then + for i:= 0 to Pred(cExplosives) do + begin + Gear:= AddGear(0, 0, gtExplosives, 0, _0, _0, 0); + FindPlace(Gear, false, 0, LAND_WIDTH); + end; + end; if (GameFlags and gfLowGravity) <> 0 then cGravity:= cMaxWindSpeed / 2; @@ -1710,56 +1710,56 @@ if (Mask and EXPLAutoSound) <> 0 then PlaySound(sndExplosion); if (Mask and EXPLAllDamageInRadius) = 0 then - dmgRadius:= Radius shl 1 + dmgRadius:= Radius shl 1 else - dmgRadius:= Radius; + dmgRadius:= Radius; Gear:= GearsList; while Gear <> nil do - begin - dmg:= dmgRadius + cHHRadius div 2 - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y))); - if (dmg > 1) and - ((Gear^.State and gstNoDamage) = 0) then - begin - dmg:= ModifyDamage(min(dmg div 2, Radius), Gear); - case Gear^.Kind of - gtHedgehog, - gtMine, - gtCase, - gtTarget, - gtFlame, - gtExplosives: begin - //{$IFDEF DEBUGFILE}AddFileLog('Damage: ' + inttostr(dmg));{$ENDIF} - if (Mask and EXPLNoDamage) = 0 then - begin - if not Gear^.Invulnerable then + begin + dmg:= dmgRadius + cHHRadius div 2 - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y))); + if (dmg > 1) and + ((Gear^.State and gstNoDamage) = 0) then + begin + dmg:= ModifyDamage(min(dmg div 2, Radius), Gear); + case Gear^.Kind of + gtHedgehog, + gtMine, + gtCase, + gtTarget, + gtFlame, + gtExplosives: begin + //{$IFDEF DEBUGFILE}AddFileLog('Damage: ' + inttostr(dmg));{$ENDIF} + if (Mask and EXPLNoDamage) = 0 then + begin + if not Gear^.Invulnerable then ApplyDamage(Gear, dmg) else Gear^.State:= Gear^.State or gstWinner; - end; - if ((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog) then - begin - DeleteCI(Gear); - Gear^.dX:= Gear^.dX + SignAs(_0_005 * dmg + cHHKick, Gear^.X - int2hwFloat(X)); - Gear^.dY:= Gear^.dY + SignAs(_0_005 * dmg + cHHKick, Gear^.Y - int2hwFloat(Y)); - Gear^.State:= (Gear^.State or gstMoving) and (not gstLoser); - if not Gear^.Invulnerable then - Gear^.State:= (Gear^.State or gstMoving) and (not gstWinner); - Gear^.Active:= true; - FollowGear:= Gear - end; - end; - gtGrave: begin - Gear^.dY:= - _0_004 * dmg; - Gear^.Active:= true; - end; - end; - end; - Gear:= Gear^.NextGear - end; + end; + if ((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog) then + begin + DeleteCI(Gear); + Gear^.dX:= Gear^.dX + SignAs(_0_005 * dmg + cHHKick, Gear^.X - int2hwFloat(X)); + Gear^.dY:= Gear^.dY + SignAs(_0_005 * dmg + cHHKick, Gear^.Y - int2hwFloat(Y)); + Gear^.State:= (Gear^.State or gstMoving) and (not gstLoser); + if not Gear^.Invulnerable then + Gear^.State:= (Gear^.State or gstMoving) and (not gstWinner); + Gear^.Active:= true; + FollowGear:= Gear + end; + end; + gtGrave: begin + Gear^.dY:= - _0_004 * dmg; + Gear^.Active:= true; + end; + end; + end; + Gear:= Gear^.NextGear + end; if (Mask and EXPLDontDraw) = 0 then - if (GameFlags and gfSolidLand) = 0 then DrawExplosion(X, Y, Radius); + if (GameFlags and gfSolidLand) = 0 then DrawExplosion(X, Y, Radius); uAIMisc.AwareOfExplosion(0, 0, 0) end; @@ -1771,34 +1771,34 @@ Gear^.Radius:= cShotgunRadius; t:= GearsList; while t <> nil do - begin - dmg:= ModifyDamage(min(Gear^.Radius + t^.Radius - hwRound(Distance(Gear^.X - t^.X, Gear^.Y - t^.Y)), 25), t); - if dmg > 0 then - case t^.Kind of - gtHedgehog, - gtMine, - gtCase, - gtTarget, - gtExplosives: begin + begin + dmg:= ModifyDamage(min(Gear^.Radius + t^.Radius - hwRound(Distance(Gear^.X - t^.X, Gear^.Y - t^.Y)), 25), t); + if dmg > 0 then + case t^.Kind of + gtHedgehog, + gtMine, + gtCase, + gtTarget, + gtExplosives: begin if (not t^.Invulnerable) then ApplyDamage(t, dmg) else Gear^.State:= Gear^.State or gstWinner; - DeleteCI(t); - t^.dX:= t^.dX + Gear^.dX * dmg * _0_01 + SignAs(cHHKick, Gear^.dX); - t^.dY:= t^.dY + Gear^.dY * dmg * _0_01; - t^.State:= t^.State or gstMoving; - t^.Active:= true; - FollowGear:= t - end; - gtGrave: begin - t^.dY:= - _0_1; - t^.Active:= true - end; - end; - t:= t^.NextGear - end; + DeleteCI(t); + t^.dX:= t^.dX + Gear^.dX * dmg * _0_01 + SignAs(cHHKick, Gear^.dX); + t^.dY:= t^.dY + Gear^.dY * dmg * _0_01; + t^.State:= t^.State or gstMoving; + t^.Active:= true; + FollowGear:= t + end; + gtGrave: begin + t^.dY:= - _0_1; + t^.Active:= true + end; + end; + t:= t^.NextGear + end; if (GameFlags and gfSolidLand) = 0 then DrawExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cShotgunRadius) end; @@ -1812,28 +1812,28 @@ if (Ammo^.Kind = gtFlame) and (i > 0) then Ammo^.Health:= 0; while i > 0 do - begin - dec(i); - Gear:= t^.ar[i]; + begin + dec(i); + Gear:= t^.ar[i]; tmpDmg:= ModifyDamage(Damage, Gear); - if (Gear^.State and gstNoDamage) = 0 then - begin - if (Gear^.Kind = gtHedgehog) and (Ammo^.State and gsttmpFlag <> 0) and (Ammo^.Kind = gtShover) then Gear^.FlightTime:= 1; - - case Gear^.Kind of - gtHedgehog, - gtMine, - gtTarget, - gtCase, - gtExplosives: begin - if (Ammo^.Kind = gtDrill) then begin Ammo^.Timer:= 0; exit; end; + if (Gear^.State and gstNoDamage) = 0 then + begin + if (Gear^.Kind = gtHedgehog) and (Ammo^.State and gsttmpFlag <> 0) and (Ammo^.Kind = gtShover) then Gear^.FlightTime:= 1; + + case Gear^.Kind of + gtHedgehog, + gtMine, + gtTarget, + gtCase, + gtExplosives: begin + if (Ammo^.Kind = gtDrill) then begin Ammo^.Timer:= 0; exit; end; if (not Gear^.Invulnerable) then ApplyDamage(Gear, tmpDmg) else Gear^.State:= Gear^.State or gstWinner; if (Gear^.Kind = gtExplosives) and (Ammo^.Kind = gtBlowtorch) then ApplyDamage(Gear, tmpDmg * 100); // crank up damage for explosives + blowtorch - DeleteCI(Gear); + DeleteCI(Gear); if (Gear^.Kind = gtHedgehog) and PHedgehog(Gear^.Hedgehog)^.King then begin Gear^.dX:= Ammo^.dX * Power * _0_005; @@ -1845,88 +1845,88 @@ Gear^.dY:= Ammo^.dY * Power * _0_01 end; - Gear^.Active:= true; - Gear^.State:= Gear^.State or gstMoving; + Gear^.Active:= true; + Gear^.State:= Gear^.State or gstMoving; - if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then - begin - if not (TestCollisionXwithXYShift(Gear, _0, -3, hwSign(Gear^.dX)) - or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; - if not (TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) - or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; - if not (TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) - or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; - end; - + if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then + begin + if not (TestCollisionXwithXYShift(Gear, _0, -3, hwSign(Gear^.dX)) + or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; + if not (TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) + or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; + if not (TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) + or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1; + end; + if (Ammo^.Kind <> gtFlame) or ((Ammo^.State and gsttmpFlag) = 0) then FollowGear:= Gear - end; - end - end; - end; + end; + end + end; + end; if i <> 0 then SetAllToActive end; procedure AssignHHCoords; var i, t, p, j: LongInt; - ar: array[0..Pred(cMaxHHs)] of PHedgehog; - Count: Longword; + ar: array[0..Pred(cMaxHHs)] of PHedgehog; + Count: Longword; begin if (GameFlags and gfPlaceHog) <> 0 then PlacingHogs:= true; if (GameFlags and (gfForts or gfDivideTeams)) <> 0 then - begin - t:= 0; - TryDo(ClansCount = 2, 'More or less than 2 clans on map in divided teams mode!', true); - for p:= 0 to 1 do - begin - with ClansArray[p]^ do - for j:= 0 to Pred(TeamsNumber) do - with Teams[j]^ do - for i:= 0 to cMaxHHIndex do - with Hedgehogs[i] do - if (Gear <> nil) and (Gear^.X.QWordValue = 0) then - begin + begin + t:= 0; + TryDo(ClansCount = 2, 'More or less than 2 clans on map in divided teams mode!', true); + for p:= 0 to 1 do + begin + with ClansArray[p]^ do + for j:= 0 to Pred(TeamsNumber) do + with Teams[j]^ do + for i:= 0 to cMaxHHIndex do + with Hedgehogs[i] do + if (Gear <> nil) and (Gear^.X.QWordValue = 0) then + begin if PlacingHogs then Unplaced:= true else FindPlace(Gear, false, t, t + LAND_WIDTH div 2);// could make Gear == nil; - if Gear <> nil then - begin - Gear^.Pos:= GetRandom(49); - Gear^.dX.isNegative:= p = 1; - end - end; - t:= LAND_WIDTH div 2 - end - end else // mix hedgehogs - begin - Count:= 0; - for p:= 0 to Pred(TeamsCount) do - with TeamsArray[p]^ do - begin - for i:= 0 to cMaxHHIndex do - with Hedgehogs[i] do - if (Gear <> nil) and (Gear^.X.QWordValue = 0) then - begin - ar[Count]:= @Hedgehogs[i]; - inc(Count) - end; - end; + if Gear <> nil then + begin + Gear^.Pos:= GetRandom(49); + Gear^.dX.isNegative:= p = 1; + end + end; + t:= LAND_WIDTH div 2 + end + end else // mix hedgehogs + begin + Count:= 0; + for p:= 0 to Pred(TeamsCount) do + with TeamsArray[p]^ do + begin + for i:= 0 to cMaxHHIndex do + with Hedgehogs[i] do + if (Gear <> nil) and (Gear^.X.QWordValue = 0) then + begin + ar[Count]:= @Hedgehogs[i]; + inc(Count) + end; + end; // unC0Rr, while it is true user can watch value on map screen, IMO this (and check above) should be enforced in UI // - is there a good place to put values for the different widgets to check? Right now they are kind of disconnected. //it would be nice if divide teams, forts mode and hh per map could all be checked by the team widget, or maybe disable start button - TryDo(Count <= MaxHedgehogs, 'Too many hedgehogs for this map! (max # is ' + inttostr(MaxHedgehogs) + ')', true); - while (Count > 0) do - begin - i:= GetRandom(Count); + TryDo(Count <= MaxHedgehogs, 'Too many hedgehogs for this map! (max # is ' + inttostr(MaxHedgehogs) + ')', true); + while (Count > 0) do + begin + i:= GetRandom(Count); if PlacingHogs then ar[i]^.Unplaced:= true else FindPlace(ar[i]^.Gear, false, 0, LAND_WIDTH); - if ar[i]^.Gear <> nil then - begin - ar[i]^.Gear^.dX.isNegative:= hwRound(ar[i]^.Gear^.X) > LAND_WIDTH div 2; - ar[i]^.Gear^.Pos:= GetRandom(19) - end; - ar[i]:= ar[Count - 1]; - dec(Count) - end - end + if ar[i]^.Gear <> nil then + begin + ar[i]^.Gear^.dX.isNegative:= hwRound(ar[i]^.Gear^.X) > LAND_WIDTH div 2; + ar[i]^.Gear^.Pos:= GetRandom(19) + end; + ar[i]:= ar[Count - 1]; + dec(Count) + end + end end; function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: LongInt): PGear; @@ -1937,12 +1937,12 @@ rY:= sqr(rY); while t <> nil do - begin - if (t <> Gear) and (t^.Kind = Kind) then - if not((hwSqr(Gear^.X - t^.X) / rX + hwSqr(Gear^.Y - t^.Y) / rY) > _1) then - exit(t); - t:= t^.NextGear - end; + begin + if (t <> Gear) and (t^.Kind = Kind) then + if not((hwSqr(Gear^.X - t^.X) / rX + hwSqr(Gear^.Y - t^.Y) / rY) > _1) then + exit(t); + t:= t^.NextGear + end; CheckGearNear:= nil end; @@ -1952,19 +1952,19 @@ begin t:= GearsList; while t <> nil do - begin - if (t^.Kind = gtHedgehog) and (t^.Y < Ammo^.Y) then - if not (hwSqr(Ammo^.X - t^.X) + hwSqr(Ammo^.Y - t^.Y - int2hwFloat(cHHRadius)) * 2 > _2) then - begin + begin + if (t^.Kind = gtHedgehog) and (t^.Y < Ammo^.Y) then + if not (hwSqr(Ammo^.X - t^.X) + hwSqr(Ammo^.Y - t^.Y - int2hwFloat(cHHRadius)) * 2 > _2) then + begin ApplyDamage(t, 5); - t^.dX:= t^.dX + (t^.X - Ammo^.X) * _0_02; - t^.dY:= - _0_25; - t^.Active:= true; - DeleteCI(t); - FollowGear:= t - end; - t:= t^.NextGear - end; + t^.dX:= t^.dX + (t^.X - Ammo^.X) * _0_02; + t^.dY:= - _0_25; + t^.Active:= true; + DeleteCI(t); + FollowGear:= t + end; + t:= t^.NextGear + end; end;} function CheckGearsNear(mX, mY: LongInt; Kind: TGearsType; rX, rY: LongInt): PGear; @@ -1974,12 +1974,12 @@ rX:= sqr(rX); rY:= sqr(rY); while t <> nil do - begin - if t^.Kind in Kind then - if not (hwSqr(int2hwFloat(mX) - t^.X) / rX + hwSqr(int2hwFloat(mY) - t^.Y) / rY > _1) then - exit(t); - t:= t^.NextGear - end; + begin + if t^.Kind in Kind then + if not (hwSqr(int2hwFloat(mX) - t^.X) / rX + hwSqr(int2hwFloat(mY) - t^.Y) / rY > _1) then + exit(t); + t:= t^.NextGear + end; CheckGearsNear:= nil end; @@ -1990,10 +1990,10 @@ t:= GearsList; while t <> nil do - begin - if t^.Kind = Kind then inc(count); - t:= t^.NextGear - end; + begin + if t^.Kind = Kind then inc(count); + t:= t^.NextGear + end; CountGears:= count; end; @@ -2015,14 +2015,14 @@ // avoid health crates if all hogs are invulnerable if (t < 13) and ((GameFlags and gfInvulnerable) <> 0) then t:= t * 13 div 20 + 7; - + //case getrandom(20) of case t of 0..6: begin FollowGear:= AddGear(0, 0, gtCase, 0, _0, _0, 0); FollowGear^.Health:= 25; FollowGear^.Pos:= posCaseHealth; - AddCaption(GetEventString(eidNewHealthPack), cWhiteColor, capgrpGameState); + AddCaption(GetEventString(eidNewHealthPack), cWhiteColor, capgrpGameState); end; 7..13: begin t:= 0; @@ -2044,7 +2044,7 @@ end; FollowGear^.Pos:= posCaseAmmo; FollowGear^.State:= Longword(i); - AddCaption(GetEventString(eidNewAmmoPack), cWhiteColor, capgrpGameState); + AddCaption(GetEventString(eidNewAmmoPack), cWhiteColor, capgrpGameState); end end; 14..19: begin @@ -2067,112 +2067,112 @@ end; FollowGear^.Pos:= posCaseUtility; FollowGear^.State:= Longword(i); - AddCaption(GetEventString(eidNewUtilityPack), cWhiteColor, capgrpGameState); + AddCaption(GetEventString(eidNewUtilityPack), cWhiteColor, capgrpGameState); end end; end; // handles case of no ammo or utility crates - considered also placing booleans in uAmmos and altering probabilities if (FollowGear <> nil) then - begin - FindPlace(FollowGear, true, 0, LAND_WIDTH); + begin + FindPlace(FollowGear, true, 0, LAND_WIDTH); - if (FollowGear <> nil) then - PlaySound(sndReinforce, CurrentTeam^.voicepack) - end + if (FollowGear <> nil) then + PlaySound(sndReinforce, CurrentTeam^.voicepack) + end end; procedure FindPlace(var Gear: PGear; withFall: boolean; Left, Right: LongInt); - function CountNonZeroz(x, y, r, c: LongInt): LongInt; - var i: LongInt; - count: LongInt = 0; - begin - if (y and LAND_HEIGHT_MASK) = 0 then - for i:= max(x - r, 0) to min(x + r, LAND_WIDTH - 4) do - if Land[y, i] <> 0 then + function CountNonZeroz(x, y, r, c: LongInt): LongInt; + var i: LongInt; + count: LongInt = 0; + begin + if (y and LAND_HEIGHT_MASK) = 0 then + for i:= max(x - r, 0) to min(x + r, LAND_WIDTH - 4) do + if Land[y, i] <> 0 then begin inc(count); if count = c then exit(count) end; - CountNonZeroz:= count; - end; + CountNonZeroz:= count; + end; var x: LongInt; - y, sy: LongInt; - ar: array[0..511] of TPoint; - ar2: array[0..1023] of TPoint; - cnt, cnt2: Longword; - delta: LongInt; + y, sy: LongInt; + ar: array[0..511] of TPoint; + ar2: array[0..1023] of TPoint; + cnt, cnt2: Longword; + delta: LongInt; begin delta:= 250; cnt2:= 0; repeat - x:= Left + LongInt(GetRandom(Delta)); - repeat - inc(x, Delta); - cnt:= 0; + x:= Left + LongInt(GetRandom(Delta)); + repeat + inc(x, Delta); + cnt:= 0; if topY > 1024 then - y:= 1024-Gear^.Radius * 2 + y:= 1024-Gear^.Radius * 2 else - y:= topY-Gear^.Radius * 2; - while y < LAND_HEIGHT do - begin - repeat - inc(y, 2); - until (y >= LAND_HEIGHT) or (CountNonZeroz(x, y, Gear^.Radius - 1, 1) = 0); + y:= topY-Gear^.Radius * 2; + while y < LAND_HEIGHT do + begin + repeat + inc(y, 2); + until (y >= LAND_HEIGHT) or (CountNonZeroz(x, y, Gear^.Radius - 1, 1) = 0); - sy:= y; + sy:= y; - repeat - inc(y); - until (y >= LAND_HEIGHT) or (CountNonZeroz(x, y, Gear^.Radius - 1, 1) <> 0); + repeat + inc(y); + until (y >= LAND_HEIGHT) or (CountNonZeroz(x, y, Gear^.Radius - 1, 1) <> 0); if (y - sy > Gear^.Radius * 2) and (((Gear^.Kind = gtExplosives) - and (y < LAND_HEIGHT-1) - and (CheckGearsNear(x, y - Gear^.Radius, [gtFlame, gtHedgehog, gtMine, gtCase, gtExplosives], 60, 60) = nil) + and (y < LAND_HEIGHT-1) + and (CheckGearsNear(x, y - Gear^.Radius, [gtFlame, gtHedgehog, gtMine, gtCase, gtExplosives], 60, 60) = nil) and (CountNonZeroz(x, y+1, Gear^.Radius - 1, Gear^.Radius+1) > Gear^.Radius)) or ((Gear^.Kind <> gtExplosives) - and (y < LAND_HEIGHT) - and (CheckGearsNear(x, y - Gear^.Radius, [gtFlame, gtHedgehog, gtMine, gtCase, gtExplosives], 110, 110) = nil))) then - begin - ar[cnt].X:= x; - if withFall then ar[cnt].Y:= sy + Gear^.Radius - else ar[cnt].Y:= y - Gear^.Radius; - inc(cnt) - end; + and (y < LAND_HEIGHT) + and (CheckGearsNear(x, y - Gear^.Radius, [gtFlame, gtHedgehog, gtMine, gtCase, gtExplosives], 110, 110) = nil))) then + begin + ar[cnt].X:= x; + if withFall then ar[cnt].Y:= sy + Gear^.Radius + else ar[cnt].Y:= y - Gear^.Radius; + inc(cnt) + end; - inc(y, 45) - end; + inc(y, 45) + end; - if cnt > 0 then - with ar[GetRandom(cnt)] do - begin - ar2[cnt2].x:= x; - ar2[cnt2].y:= y; - inc(cnt2) - end - until (x + Delta > Right); + if cnt > 0 then + with ar[GetRandom(cnt)] do + begin + ar2[cnt2].x:= x; + ar2[cnt2].y:= y; + inc(cnt2) + end + until (x + Delta > Right); - dec(Delta, 60) + dec(Delta, 60) until (cnt2 > 0) or (Delta < 70); if cnt2 > 0 then - with ar2[GetRandom(cnt2)] do - begin - Gear^.X:= int2hwFloat(x); - Gear^.Y:= int2hwFloat(y); - {$IFDEF DEBUGFILE} - AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')'); - {$ENDIF} - end - else - begin - OutError('Can''t find place for Gear', false); - DeleteGear(Gear); - Gear:= nil - end + with ar2[GetRandom(cnt2)] do + begin + Gear^.X:= int2hwFloat(x); + Gear^.Y:= int2hwFloat(y); + {$IFDEF DEBUGFILE} + AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')'); + {$ENDIF} + end + else + begin + OutError('Can''t find place for Gear', false); + DeleteGear(Gear); + Gear:= nil + end end; function ModifyDamage(dmg: Longword; Gear: PGear): Longword; @@ -2196,33 +2196,33 @@ GearByUID:= nil; gear:= GearsList; while gear <> nil do - begin - if gear^.uid = uid then - begin - GearByUID:= gear; - exit - end; - gear:= gear^.NextGear - end + begin + if gear^.uid = uid then + begin + GearByUID:= gear; + exit + end; + gear:= gear^.NextGear + end end; procedure init_uGears; begin - CurAmmoGear:= nil; - GearsList:= nil; - KilledHHs:= 0; - SuddenDeathDmg:= false; - SpeechType:= 1; - TrainingTargetGear:= nil; - skipFlag:= false; - - AllInactive:= false; - PrvInactive:= false; + CurAmmoGear:= nil; + GearsList:= nil; + KilledHHs:= 0; + SuddenDeathDmg:= false; + SpeechType:= 1; + TrainingTargetGear:= nil; + skipFlag:= false; + + AllInactive:= false; + PrvInactive:= false; end; procedure free_uGears; begin - FreeGearsList(); + FreeGearsList(); end; end. diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/uIO.pas --- a/hedgewars/uIO.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/uIO.pas Sat Mar 06 10:59:20 2010 +0000 @@ -55,14 +55,14 @@ 2: (str: shortstring); end; -var IPCSock: PTCPSocket; - fds: PSDLNet_SocketSet; - isPonged: boolean; +var IPCSock: PTCPSocket; + fds: PSDLNet_SocketSet; + isPonged: boolean; - headcmd: PCmd; - lastcmd: PCmd; + headcmd: PCmd; + lastcmd: PCmd; - SendEmptyPacketTicks: LongWord; + SendEmptyPacketTicks: LongWord; function AddCmd(Time: Word; str: shortstring): PCmd; @@ -112,9 +112,9 @@ procedure CloseIPC; begin - SDLNet_FreeSocketSet(fds); - SDLNet_TCP_Close(IPCSock); - SDLNet_Quit(); + SDLNet_FreeSocketSet(fds); + SDLNet_TCP_Close(IPCSock); + SDLNet_Quit(); end; procedure ParseIPCCommand(s: shortstring); @@ -143,8 +143,8 @@ procedure IPCCheckSock; const ss: shortstring = ''; var i: LongInt; - buf: array[0..255] of byte; - s: shortstring absolute buf; + buf: array[0..255] of byte; + s: shortstring absolute buf; begin if IPCSock = nil then exit; @@ -153,27 +153,27 @@ SDLNet_AddSocket(fds, IPCSock); while SDLNet_CheckSockets(fds, 0) > 0 do - begin - i:= SDLNet_TCP_Recv(IPCSock, @buf[1], 255 - Length(ss)); - if i > 0 then - begin - buf[0]:= i; - ss:= ss + s; - while (Length(ss) > 1) and (Length(ss) > byte(ss[1])) do - begin - ParseIPCCommand(copy(ss, 2, byte(ss[1]))); - Delete(ss, 1, Succ(byte(ss[1]))) - end - end else OutError('IPC connection lost', true) - end; + begin + i:= SDLNet_TCP_Recv(IPCSock, @buf[1], 255 - Length(ss)); + if i > 0 then + begin + buf[0]:= i; + ss:= ss + s; + while (Length(ss) > 1) and (Length(ss) > byte(ss[1])) do + begin + ParseIPCCommand(copy(ss, 2, byte(ss[1]))); + Delete(ss, 1, Succ(byte(ss[1]))) + end + end else OutError('IPC connection lost', true) + end; end; procedure LoadRecordFromFile(fileName: shortstring); var f: file; - ss: shortstring = ''; - i: LongInt; - buf: array[0..255] of byte; - s: shortstring absolute buf; + ss: shortstring = ''; + i: LongInt; + buf: array[0..255] of byte; + s: shortstring absolute buf; begin // set RDNLY on file open @@ -183,17 +183,17 @@ reset(f, 1); repeat - BlockRead(f, buf[1], 255 - Length(ss), i); - if i > 0 then - begin - buf[0]:= i; - ss:= ss + s; - while (Length(ss) > 1)and(Length(ss) > byte(ss[1])) do - begin - ParseIPCCommand(copy(ss, 2, byte(ss[1]))); - Delete(ss, 1, Succ(byte(ss[1]))) - end - end + BlockRead(f, buf[1], 255 - Length(ss), i); + if i > 0 then + begin + buf[0]:= i; + ss:= ss + s; + while (Length(ss) > 1)and(Length(ss) > byte(ss[1])) do + begin + ParseIPCCommand(copy(ss, 2, byte(ss[1]))); + Delete(ss, 1, Succ(byte(ss[1]))) + end + end until i = 0; close(f) @@ -202,14 +202,14 @@ procedure SendIPC(s: shortstring); begin if IPCSock <> nil then - begin - SendEmptyPacketTicks:= 0; - if s[0]>#251 then s[0]:= #251; - SDLNet_Write16(GameTicks, @s[Succ(byte(s[0]))]); - {$IFDEF DEBUGFILE}AddFileLog('IPC send: '+ s[1]);{$ENDIF} - inc(s[0], 2); - SDLNet_TCP_Send(IPCSock, @s, Succ(byte(s[0]))) - end + begin + SendEmptyPacketTicks:= 0; + if s[0]>#251 then s[0]:= #251; + SDLNet_Write16(GameTicks, @s[Succ(byte(s[0]))]); + {$IFDEF DEBUGFILE}AddFileLog('IPC send: '+ s[1]);{$ENDIF} + inc(s[0], 2); + SDLNet_TCP_Send(IPCSock, @s, Succ(byte(s[0]))) + end end; procedure SendIPCRaw(p: pointer; len: Longword); @@ -256,88 +256,88 @@ begin inc(SendEmptyPacketTicks, Lag); if (SendEmptyPacketTicks >= cSendEmptyPacketTime) then - SendIPC('+') + SendIPC('+') end; procedure NetGetNextCmd; var tmpflag: boolean; - s: shortstring; - x16, y16: SmallInt; + s: shortstring; + x16, y16: SmallInt; begin tmpflag:= true; while (headcmd <> nil) - and (tmpflag or (headcmd^.cmd = '#')) // '#' is the only cmd which can be sent within same tick after 'N' - and ((GameTicks = hiTicks shl 16 + headcmd^.loTime) - or (headcmd^.cmd = 's') // for these commands time is not specified - or (headcmd^.cmd = '#') - or (headcmd^.cmd = 'b') - or (headcmd^.cmd = 'F')) do - begin - case headcmd^.cmd of - '+': ; // do nothing - it is just an empty packet - '#': inc(hiTicks); - 'L': ParseCommand('+left', true); - 'l': ParseCommand('-left', true); - 'R': ParseCommand('+right', true); - 'r': ParseCommand('-right', true); - 'U': ParseCommand('+up', true); - 'u': ParseCommand('-up', true); - 'D': ParseCommand('+down', true); - 'd': ParseCommand('-down', true); - 'Z': ParseCommand('+precise', true); - 'z': ParseCommand('-precise', true); - 'A': ParseCommand('+attack', true); - 'a': ParseCommand('-attack', true); - 'S': ParseCommand('switch', true); - 'j': ParseCommand('ljump', true); - 'J': ParseCommand('hjump', true); - ',': ParseCommand('skip', true); - 's': begin - s:= copy(headcmd^.str, 2, Pred(headcmd^.len)); - AddChatString(s); - WriteLnToConsole(s) - end; - 'b': begin - s:= copy(headcmd^.str, 2, Pred(headcmd^.len)); - AddChatString(#4 + s); - WriteLnToConsole(s) - end; - 'F': TeamGone(copy(headcmd^.str, 2, Pred(headcmd^.len))); - 'N': begin - tmpflag:= false; - {$IFDEF DEBUGFILE}AddFileLog('got cmd "N": time '+inttostr(hiTicks shl 16 + headcmd^.loTime)){$ENDIF} - end; - 'p': begin - x16:= SDLNet_Read16(@(headcmd^.X)); - y16:= SDLNet_Read16(@(headcmd^.Y)); - doPut(x16, y16, false) - end; - 'P': begin - // these are equations solved for CursorPoint - // SDLNet_Read16(@(headcmd^.X)) == CursorPoint.X - WorldDx; - // SDLNet_Read16(@(headcmd^.Y)) == cScreenHeight - CursorPoint.Y - WorldDy; - CursorPoint.X:= SmallInt(SDLNet_Read16(@(headcmd^.X))) + WorldDx; - CursorPoint.Y:= cScreenHeight - SmallInt(SDLNet_Read16(@(headcmd^.Y))) - WorldDy; - end; - 'w': ParseCommand('setweap ' + headcmd^.str[2], true); - 't': ParseCommand('taunt ' + headcmd^.str[2], true); - 'g': ParseCommand('newgrave', true); - 'h': ParseCommand('hogsay ' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true); - '1'..'5': ParseCommand('timer ' + headcmd^.cmd, true); - #128..char(128 + cMaxSlotIndex): ParseCommand('slot ' + char(byte(headcmd^.cmd) - 79), true) - else - OutError('Unexpected protocol command: ' + headcmd^.cmd, True) - end; - RemoveCmd - end; + and (tmpflag or (headcmd^.cmd = '#')) // '#' is the only cmd which can be sent within same tick after 'N' + and ((GameTicks = hiTicks shl 16 + headcmd^.loTime) + or (headcmd^.cmd = 's') // for these commands time is not specified + or (headcmd^.cmd = '#') + or (headcmd^.cmd = 'b') + or (headcmd^.cmd = 'F')) do + begin + case headcmd^.cmd of + '+': ; // do nothing - it is just an empty packet + '#': inc(hiTicks); + 'L': ParseCommand('+left', true); + 'l': ParseCommand('-left', true); + 'R': ParseCommand('+right', true); + 'r': ParseCommand('-right', true); + 'U': ParseCommand('+up', true); + 'u': ParseCommand('-up', true); + 'D': ParseCommand('+down', true); + 'd': ParseCommand('-down', true); + 'Z': ParseCommand('+precise', true); + 'z': ParseCommand('-precise', true); + 'A': ParseCommand('+attack', true); + 'a': ParseCommand('-attack', true); + 'S': ParseCommand('switch', true); + 'j': ParseCommand('ljump', true); + 'J': ParseCommand('hjump', true); + ',': ParseCommand('skip', true); + 's': begin + s:= copy(headcmd^.str, 2, Pred(headcmd^.len)); + AddChatString(s); + WriteLnToConsole(s) + end; + 'b': begin + s:= copy(headcmd^.str, 2, Pred(headcmd^.len)); + AddChatString(#4 + s); + WriteLnToConsole(s) + end; + 'F': TeamGone(copy(headcmd^.str, 2, Pred(headcmd^.len))); + 'N': begin + tmpflag:= false; + {$IFDEF DEBUGFILE}AddFileLog('got cmd "N": time '+inttostr(hiTicks shl 16 + headcmd^.loTime)){$ENDIF} + end; + 'p': begin + x16:= SDLNet_Read16(@(headcmd^.X)); + y16:= SDLNet_Read16(@(headcmd^.Y)); + doPut(x16, y16, false) + end; + 'P': begin + // these are equations solved for CursorPoint + // SDLNet_Read16(@(headcmd^.X)) == CursorPoint.X - WorldDx; + // SDLNet_Read16(@(headcmd^.Y)) == cScreenHeight - CursorPoint.Y - WorldDy; + CursorPoint.X:= SmallInt(SDLNet_Read16(@(headcmd^.X))) + WorldDx; + CursorPoint.Y:= cScreenHeight - SmallInt(SDLNet_Read16(@(headcmd^.Y))) - WorldDy; + end; + 'w': ParseCommand('setweap ' + headcmd^.str[2], true); + 't': ParseCommand('taunt ' + headcmd^.str[2], true); + 'g': ParseCommand('newgrave', true); + 'h': ParseCommand('hogsay ' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true); + '1'..'5': ParseCommand('timer ' + headcmd^.cmd, true); + #128..char(128 + cMaxSlotIndex): ParseCommand('slot ' + char(byte(headcmd^.cmd) - 79), true) + else + OutError('Unexpected protocol command: ' + headcmd^.cmd, True) + end; + RemoveCmd + end; if (headcmd <> nil) and tmpflag and (not CurrentTeam^.hasGone) then - TryDo(GameTicks < hiTicks shl 16 + headcmd^.loTime, - 'oops, queue error. in buffer: ' + headcmd^.cmd + - ' (' + inttostr(GameTicks) + ' > ' + - inttostr(hiTicks shl 16 + headcmd^.loTime) + ')', - true); + TryDo(GameTicks < hiTicks shl 16 + headcmd^.loTime, + 'oops, queue error. in buffer: ' + headcmd^.cmd + + ' (' + inttostr(GameTicks) + ' > ' + + inttostr(hiTicks shl 16 + headcmd^.loTime) + ')', + true); isInLag:= (headcmd = nil) and tmpflag and (not CurrentTeam^.hasGone); @@ -346,15 +346,15 @@ procedure init_uIO; begin - IPCSock:= nil; + IPCSock:= nil; - headcmd:= nil; - lastcmd:= nil; - isPonged:= false; // was const + headcmd:= nil; + lastcmd:= nil; + isPonged:= false; // was const - hiTicks:= 0; - SendEmptyPacketTicks:= 0; - ipcPort:= 0; + hiTicks:= 0; + SendEmptyPacketTicks:= 0; + ipcPort:= 0; end; procedure free_uIO; diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/uKeys.pas --- a/hedgewars/uKeys.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/uKeys.pas Sat Mar 06 10:59:20 2010 +0000 @@ -43,44 +43,44 @@ procedure ControllerHatEvent(joy, hat, value: Byte); procedure ControllerButtonEvent(joy, button: Byte; pressed: Boolean); -var hideAmmoMenu: boolean; - wheelUp: boolean; - wheelDown: boolean; +var hideAmmoMenu: boolean; + wheelUp: boolean; + wheelDown: boolean; - ControllerNumControllers: Integer; - ControllerEnabled: Integer; - ControllerNumAxes: array[0..5] of Integer; - //ControllerNumBalls: array[0..5] of Integer; - ControllerNumHats: array[0..5] of Integer; - ControllerNumButtons: array[0..5] of Integer; - ControllerAxes: array[0..5] of array[0..19] of Integer; - //ControllerBalls: array[0..5] of array[0..19] of array[0..1] of Integer; - ControllerHats: array[0..5] of array[0..19] of Byte; - ControllerButtons: array[0..5] of array[0..19] of Byte; + ControllerNumControllers: Integer; + ControllerEnabled: Integer; + ControllerNumAxes: array[0..5] of Integer; + //ControllerNumBalls: array[0..5] of Integer; + ControllerNumHats: array[0..5] of Integer; + ControllerNumButtons: array[0..5] of Integer; + ControllerAxes: array[0..5] of array[0..19] of Integer; + //ControllerBalls: array[0..5] of array[0..19] of array[0..1] of Integer; + ControllerHats: array[0..5] of array[0..19] of Byte; + ControllerButtons: array[0..5] of array[0..19] of Byte; - DefaultBinds, CurrentBinds: TBinds; + DefaultBinds, CurrentBinds: TBinds; {$IFDEF IPHONEOS} - leftClick: boolean; - middleClick: boolean; - rightClick: boolean; + leftClick: boolean; + middleClick: boolean; + rightClick: boolean; - upKey: boolean; - downKey: boolean; - rightKey: boolean; - leftKey: boolean; + upKey: boolean; + downKey: boolean; + rightKey: boolean; + leftKey: boolean; - backspaceKey: boolean; - spaceKey: boolean; - enterKey: boolean; - tabKey: boolean; - - chatAction: boolean; - pauseAction: boolean; - switchAction: boolean; + backspaceKey: boolean; + spaceKey: boolean; + enterKey: boolean; + tabKey: boolean; + + chatAction: boolean; + pauseAction: boolean; + switchAction: boolean; - theJoystick: PSDL_Joystick; - + theJoystick: PSDL_Joystick; + procedure setiPhoneBinds; {$ENDIF} implementation @@ -89,13 +89,13 @@ var tkbd, tkbdn: TKeyboardState; KeyNames: array [0..cKeyMaxIndex] of string[15]; - + function KeyNameToCode(name: shortstring): word; var code: Word; begin - code:= cKeyMaxIndex; - while (code > 0) and (KeyNames[code] <> name) do dec(code); - KeyNameToCode:= code; + code:= cKeyMaxIndex; + while (code > 0) and (KeyNames[code] <> name) do dec(code); + KeyNameToCode:= code; end; @@ -119,7 +119,7 @@ {$IFNDEF IPHONEOS} for i:= 6 to pred(j) do // first 6 will be overwritten - tkbdn[i]:= pkbd^[i]; + tkbdn[i]:= pkbd^[i]; {$ENDIF} // mouse buttons @@ -145,44 +145,44 @@ // Controller(s) k:= j; // should we test k for hitting the limit? sounds rather unlikely to ever reach it for j:= 0 to Pred(ControllerNumControllers) do - begin - for i:= 0 to Pred(ControllerNumAxes[j]) do - begin - if ControllerAxes[j][i] > 20000 then tkbdn[k + 0]:= 1 else tkbdn[k + 0]:= 0; - if ControllerAxes[j][i] < -20000 then tkbdn[k + 1]:= 1 else tkbdn[k + 1]:= 0; - inc(k, 2); - end; - for i:= 0 to Pred(ControllerNumHats[j]) do - begin - tkbdn[k + 0]:= ControllerHats[j][i] and SDL_HAT_UP; - tkbdn[k + 1]:= ControllerHats[j][i] and SDL_HAT_RIGHT; - tkbdn[k + 2]:= ControllerHats[j][i] and SDL_HAT_DOWN; - tkbdn[k + 3]:= ControllerHats[j][i] and SDL_HAT_LEFT; - inc(k, 4); - end; - for i:= 0 to Pred(ControllerNumButtons[j]) do - begin - tkbdn[k]:= ControllerButtons[j][i]; - inc(k, 1); - end; - end; + begin + for i:= 0 to Pred(ControllerNumAxes[j]) do + begin + if ControllerAxes[j][i] > 20000 then tkbdn[k + 0]:= 1 else tkbdn[k + 0]:= 0; + if ControllerAxes[j][i] < -20000 then tkbdn[k + 1]:= 1 else tkbdn[k + 1]:= 0; + inc(k, 2); + end; + for i:= 0 to Pred(ControllerNumHats[j]) do + begin + tkbdn[k + 0]:= ControllerHats[j][i] and SDL_HAT_UP; + tkbdn[k + 1]:= ControllerHats[j][i] and SDL_HAT_RIGHT; + tkbdn[k + 2]:= ControllerHats[j][i] and SDL_HAT_DOWN; + tkbdn[k + 3]:= ControllerHats[j][i] and SDL_HAT_LEFT; + inc(k, 4); + end; + for i:= 0 to Pred(ControllerNumButtons[j]) do + begin + tkbdn[k]:= ControllerButtons[j][i]; + inc(k, 1); + end; + end; // now process strokes for i:= 0 to cKeyMaxIndex do if CurrentBinds[i][0] <> #0 then - begin - if (i > 3) and (tkbdn[i] <> 0) and not ((CurrentBinds[i] = 'put') or (CurrentBinds[i] = 'ammomenu') or (CurrentBinds[i] = '+cur_u') or (CurrentBinds[i] = '+cur_d') or (CurrentBinds[i] = '+cur_l') or (CurrentBinds[i] = '+cur_r')) then hideAmmoMenu:= true; - if (tkbd[i] = 0) and (tkbdn[i] <> 0) then ParseCommand(CurrentBinds[i], Trusted) - else if (CurrentBinds[i][1] = '+') - and (tkbdn[i] = 0) - and (tkbd[i] <> 0) then - begin - s:= CurrentBinds[i]; - s[1]:= '-'; - ParseCommand(s, Trusted) - end; - tkbd[i]:= tkbdn[i] - end + begin + if (i > 3) and (tkbdn[i] <> 0) and not ((CurrentBinds[i] = 'put') or (CurrentBinds[i] = 'ammomenu') or (CurrentBinds[i] = '+cur_u') or (CurrentBinds[i] = '+cur_d') or (CurrentBinds[i] = '+cur_l') or (CurrentBinds[i] = '+cur_r')) then hideAmmoMenu:= true; + if (tkbd[i] = 0) and (tkbdn[i] <> 0) then ParseCommand(CurrentBinds[i], Trusted) + else if (CurrentBinds[i][1] = '+') + and (tkbdn[i] = 0) + and (tkbd[i] <> 0) then + begin + s:= CurrentBinds[i]; + s[1]:= '-'; + ParseCommand(s, Trusted) + end; + tkbd[i]:= tkbdn[i] + end end; procedure ResetKbd; @@ -197,7 +197,7 @@ {$IFNDEF IPHONEOS} for i:= 1 to pred(j) do - tkbdn[i]:= pkbd^[i]; + tkbdn[i]:= pkbd^[i]; {$ENDIF} // mouse buttons @@ -223,28 +223,28 @@ // Controller(s) k:= j; // should we test k for hitting the limit? sounds rather unlikely to ever reach it for j:= 0 to Pred(ControllerNumControllers) do - begin - for i:= 0 to Pred(ControllerNumAxes[j]) do - begin - if ControllerAxes[j][i] > 20000 then tkbdn[k + 0]:= 1 else tkbdn[k + 0]:= 0; - if ControllerAxes[j][i] < -20000 then tkbdn[k + 1]:= 1 else tkbdn[k + 1]:= 0; - inc(k, 2); - end; - for i:= 0 to Pred(ControllerNumHats[j]) do - begin - tkbdn[k + 0]:= ControllerHats[j][i] and SDL_HAT_UP; - tkbdn[k + 1]:= ControllerHats[j][i] and SDL_HAT_RIGHT; - tkbdn[k + 2]:= ControllerHats[j][i] and SDL_HAT_DOWN; - tkbdn[k + 3]:= ControllerHats[j][i] and SDL_HAT_LEFT; - inc(k, 4); - end; - for i:= 0 to Pred(ControllerNumButtons[j]) do - begin - tkbdn[k]:= ControllerButtons[j][i]; - inc(k, 1); - end; - end; - + begin + for i:= 0 to Pred(ControllerNumAxes[j]) do + begin + if ControllerAxes[j][i] > 20000 then tkbdn[k + 0]:= 1 else tkbdn[k + 0]:= 0; + if ControllerAxes[j][i] < -20000 then tkbdn[k + 1]:= 1 else tkbdn[k + 1]:= 0; + inc(k, 2); + end; + for i:= 0 to Pred(ControllerNumHats[j]) do + begin + tkbdn[k + 0]:= ControllerHats[j][i] and SDL_HAT_UP; + tkbdn[k + 1]:= ControllerHats[j][i] and SDL_HAT_RIGHT; + tkbdn[k + 2]:= ControllerHats[j][i] and SDL_HAT_DOWN; + tkbdn[k + 3]:= ControllerHats[j][i] and SDL_HAT_LEFT; + inc(k, 4); + end; + for i:= 0 to Pred(ControllerNumButtons[j]) do + begin + tkbdn[k]:= ControllerButtons[j][i]; + inc(k, 1); + end; + end; + for t:= 0 to cKeyMaxIndex do tkbd[i]:= tkbdn[i] end; @@ -260,15 +260,15 @@ KeyNames[5]:= 'wheeldown'; for i:= 6 to cKeyMaxIndex do - begin - s:= shortstring(sdl_getkeyname(i)); - //writeln(stdout,inttostr(i) + ': ' + s); - if s = 'unknown key' then KeyNames[i]:= '' - else begin - for t:= 1 to Length(s) do - if s[t] = ' ' then s[t]:= '_'; - KeyNames[i]:= s - end; + begin + s:= shortstring(sdl_getkeyname(i)); + //writeln(stdout,inttostr(i) + ': ' + s); + if s = 'unknown key' then KeyNames[i]:= '' + else begin + for t:= 1 to Length(s) do + if s[t] = ' ' then s[t]:= '_'; + KeyNames[i]:= s + end; end; //for i:= 0 to cKeyMaxIndex do writeln(stdout,inttostr(i) + ': ' + KeyNames[i]); @@ -278,27 +278,27 @@ // Controller(s) for j:= 0 to Pred(ControllerNumControllers) do - begin - for i:= 0 to Pred(ControllerNumAxes[j]) do - begin - keynames[k + 0]:= 'j' + inttostr(j) + 'a' + inttostr(i) + 'u'; - keynames[k + 1]:= 'j' + inttostr(j) + 'a' + inttostr(i) + 'd'; - inc(k, 2); - end; - for i:= 0 to Pred(ControllerNumHats[j]) do - begin - keynames[k + 0]:= 'j' + inttostr(j) + 'h' + inttostr(i) + 'u'; - keynames[k + 1]:= 'j' + inttostr(j) + 'h' + inttostr(i) + 'r'; - keynames[k + 2]:= 'j' + inttostr(j) + 'h' + inttostr(i) + 'd'; - keynames[k + 3]:= 'j' + inttostr(j) + 'h' + inttostr(i) + 'l'; - inc(k, 4); - end; - for i:= 0 to Pred(ControllerNumButtons[j]) do - begin - keynames[k]:= 'j' + inttostr(j) + 'b' + inttostr(i); - inc(k, 1); - end; - end; + begin + for i:= 0 to Pred(ControllerNumAxes[j]) do + begin + keynames[k + 0]:= 'j' + inttostr(j) + 'a' + inttostr(i) + 'u'; + keynames[k + 1]:= 'j' + inttostr(j) + 'a' + inttostr(i) + 'd'; + inc(k, 2); + end; + for i:= 0 to Pred(ControllerNumHats[j]) do + begin + keynames[k + 0]:= 'j' + inttostr(j) + 'h' + inttostr(i) + 'u'; + keynames[k + 1]:= 'j' + inttostr(j) + 'h' + inttostr(i) + 'r'; + keynames[k + 2]:= 'j' + inttostr(j) + 'h' + inttostr(i) + 'd'; + keynames[k + 3]:= 'j' + inttostr(j) + 'h' + inttostr(i) + 'l'; + inc(k, 4); + end; + for i:= 0 to Pred(ControllerNumButtons[j]) do + begin + keynames[k]:= 'j' + inttostr(j) + 'b' + inttostr(i); + inc(k, 1); + end; + end; DefaultBinds[ 27]:= 'quit'; DefaultBinds[ 96]:= 'history'; @@ -351,47 +351,47 @@ procedure SetBinds(var binds: TBinds); begin - CurrentBinds:= binds; + CurrentBinds:= binds; end; procedure SetDefaultBinds; begin - CurrentBinds:= DefaultBinds; + CurrentBinds:= DefaultBinds; end; {$IFDEF IPHONEOS} procedure setiPhoneBinds; // set to false the keys that only need one stoke begin - tkbdn[1]:= ord(leftClick); - tkbdn[2]:= ord(middleClick); - tkbdn[3]:= ord(rightClick); + tkbdn[1]:= ord(leftClick); + tkbdn[2]:= ord(middleClick); + tkbdn[3]:= ord(rightClick); - tkbdn[23]:= ord(upKey); - tkbdn[24]:= ord(downKey); - tkbdn[25]:= ord(leftKey); - tkbdn[26]:= ord(rightKey); + tkbdn[23]:= ord(upKey); + tkbdn[24]:= ord(downKey); + tkbdn[25]:= ord(leftKey); + tkbdn[26]:= ord(rightKey); - tkbdn[ 8]:= ord(backspaceKey); - tkbdn[ 9]:= ord(tabKey); - tkbdn[13]:= ord(enterKey); - tkbdn[32]:= ord(spaceKey); + tkbdn[ 8]:= ord(backspaceKey); + tkbdn[ 9]:= ord(tabKey); + tkbdn[13]:= ord(enterKey); + tkbdn[32]:= ord(spaceKey); - tkbdn[44]:= ord(chatAction); - tkbdn[55]:= ord(pauseAction); - //tkbdn[100]:= ord(switchAction); - - leftClick:= false; - middleClick:= false; - rightClick:= false; + tkbdn[44]:= ord(chatAction); + tkbdn[55]:= ord(pauseAction); + //tkbdn[100]:= ord(switchAction); + + leftClick:= false; + middleClick:= false; + rightClick:= false; - tabKey:= false; - enterKey:= false; - backspaceKey:= false; - - chatAction:= false; - pauseAction:= false; - //switchAction:= false; + tabKey:= false; + enterKey:= false; + backspaceKey:= false; + + chatAction:= false; + pauseAction:= false; + //switchAction:= false; end; {$ENDIF} @@ -402,7 +402,7 @@ end; var Controller: array [0..5] of PSDL_Joystick; - + procedure ControllerInit; var i, j: Integer; begin @@ -416,49 +416,49 @@ WriteLnToConsole('Number of game controllers: ' + inttostr(ControllerNumControllers)); if ControllerNumControllers > 0 then - begin - for j:= 0 to pred(ControllerNumControllers) do - begin - WriteLnToConsole('Using game controller: ' + SDL_JoystickName(j)); - Controller[j]:= SDL_JoystickOpen(j); - if Controller[j] = nil then - WriteLnToConsole('* Failed to open game controller!') - else - begin - ControllerNumAxes[j]:= SDL_JoystickNumAxes(Controller[j]); - //ControllerNumBalls[j]:= SDL_JoystickNumBalls(Controller[j]); - ControllerNumHats[j]:= SDL_JoystickNumHats(Controller[j]); - ControllerNumButtons[j]:= SDL_JoystickNumButtons(Controller[j]); - WriteLnToConsole('* Number of axes: ' + inttostr(ControllerNumAxes[j])); - //WriteLnToConsole('* Number of balls: ' + inttostr(ControllerNumBalls[j])); - WriteLnToConsole('* Number of hats: ' + inttostr(ControllerNumHats[j])); - WriteLnToConsole('* Number of buttons: ' + inttostr(ControllerNumButtons[j])); - ControllerEnabled:= 1; - - if ControllerNumAxes[j] > 20 then ControllerNumAxes[j]:= 20; - //if ControllerNumBalls[j] > 20 then ControllerNumBalls[j]:= 20; - if ControllerNumHats[j] > 20 then ControllerNumHats[j]:= 20; - if ControllerNumButtons[j] > 20 then ControllerNumButtons[j]:= 20; - - // reset all buttons/axes - for i:= 0 to pred(ControllerNumAxes[j]) do - ControllerAxes[j][i]:= 0; - (*for i:= 0 to pred(ControllerNumBalls[j]) do - begin - ControllerBalls[j][i][0]:= 0; - ControllerBalls[j][i][1]:= 0; - end;*) - for i:= 0 to pred(ControllerNumHats[j]) do - ControllerHats[j][i]:= SDL_HAT_CENTERED; - for i:= 0 to pred(ControllerNumButtons[j]) do - ControllerButtons[j][i]:= 0; - end; - end; - // enable event generation/controller updating - SDL_JoystickEventState(1); - end -else - WriteLnToConsole('Not using any game controller'); + begin + for j:= 0 to pred(ControllerNumControllers) do + begin + WriteLnToConsole('Using game controller: ' + SDL_JoystickName(j)); + Controller[j]:= SDL_JoystickOpen(j); + if Controller[j] = nil then + WriteLnToConsole('* Failed to open game controller!') + else + begin + ControllerNumAxes[j]:= SDL_JoystickNumAxes(Controller[j]); + //ControllerNumBalls[j]:= SDL_JoystickNumBalls(Controller[j]); + ControllerNumHats[j]:= SDL_JoystickNumHats(Controller[j]); + ControllerNumButtons[j]:= SDL_JoystickNumButtons(Controller[j]); + WriteLnToConsole('* Number of axes: ' + inttostr(ControllerNumAxes[j])); + //WriteLnToConsole('* Number of balls: ' + inttostr(ControllerNumBalls[j])); + WriteLnToConsole('* Number of hats: ' + inttostr(ControllerNumHats[j])); + WriteLnToConsole('* Number of buttons: ' + inttostr(ControllerNumButtons[j])); + ControllerEnabled:= 1; + + if ControllerNumAxes[j] > 20 then ControllerNumAxes[j]:= 20; + //if ControllerNumBalls[j] > 20 then ControllerNumBalls[j]:= 20; + if ControllerNumHats[j] > 20 then ControllerNumHats[j]:= 20; + if ControllerNumButtons[j] > 20 then ControllerNumButtons[j]:= 20; + + // reset all buttons/axes + for i:= 0 to pred(ControllerNumAxes[j]) do + ControllerAxes[j][i]:= 0; + (*for i:= 0 to pred(ControllerNumBalls[j]) do + begin + ControllerBalls[j][i][0]:= 0; + ControllerBalls[j][i][1]:= 0; + end;*) + for i:= 0 to pred(ControllerNumHats[j]) do + ControllerHats[j][i]:= SDL_HAT_CENTERED; + for i:= 0 to pred(ControllerNumButtons[j]) do + ControllerButtons[j][i]:= 0; + end; + end; + // enable event generation/controller updating + SDL_JoystickEventState(1); + end +else + WriteLnToConsole('Not using any game controller'); {$IFDEF IPHONEOS} theJoystick:= Controller[0]; {$ENDIF} @@ -467,50 +467,50 @@ procedure ControllerClose; var j: Integer; begin - if ControllerEnabled > 0 then - for j:= 0 to pred(ControllerNumControllers) do - SDL_JoystickClose(Controller[j]); + if ControllerEnabled > 0 then + for j:= 0 to pred(ControllerNumControllers) do + SDL_JoystickClose(Controller[j]); end; procedure ControllerAxisEvent(joy, axis: Byte; value: Integer); begin - ControllerAxes[joy][axis]:= value; + ControllerAxes[joy][axis]:= value; end; procedure ControllerHatEvent(joy, hat, value: Byte); begin - ControllerHats[joy][hat]:= value; + ControllerHats[joy][hat]:= value; end; procedure ControllerButtonEvent(joy, button: Byte; pressed: Boolean); begin - if pressed then ControllerButtons[joy][button]:= 1 - else ControllerButtons[joy][button]:= 0; + if pressed then ControllerButtons[joy][button]:= 1 + else ControllerButtons[joy][button]:= 0; end; procedure init_uKeys; begin - wheelUp:= false; - wheelDown:= false; + wheelUp:= false; + wheelDown:= false; {$IFDEF IPHONEOS} - // this function is called by HW_allKeysUp so be careful - leftClick:= false; - middleClick:= false; - rightClick:= false; + // this function is called by HW_allKeysUp so be careful + leftClick:= false; + middleClick:= false; + rightClick:= false; - upKey:= false; - downKey:= false; - rightKey:= false; - leftKey:= false; + upKey:= false; + downKey:= false; + rightKey:= false; + leftKey:= false; - backspaceKey:= false; - spaceKey:= false; - enterKey:= false; - tabKey:= false; - - chatAction:= false; - pauseAction:= false; - switchAction:= false; + backspaceKey:= false; + spaceKey:= false; + enterKey:= false; + tabKey:= false; + + chatAction:= false; + pauseAction:= false; + switchAction:= false; {$ENDIF} end; diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/uLand.pas --- a/hedgewars/uLand.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/uLand.pas Sat Mar 06 10:59:20 2010 +0000 @@ -22,15 +22,15 @@ interface uses SDLh, uLandTemplates, uFloat, uConsts, {$IFDEF GLES11} - gles11; + gles11; {$ELSE} - GL; + GL; {$ENDIF} type TLandArray = packed array[0 .. LAND_HEIGHT - 1, 0 .. LAND_WIDTH - 1] of LongWord; - TCollisionArray = packed array[0 .. LAND_HEIGHT - 1, 0 .. LAND_WIDTH - 1] of Word; - TPreview = packed array[0..127, 0..31] of byte; - TDirtyTag = packed array[0 .. LAND_HEIGHT div 32 - 1, 0 .. LAND_WIDTH div 32 - 1] of byte; + TCollisionArray = packed array[0 .. LAND_HEIGHT - 1, 0 .. LAND_WIDTH - 1] of Word; + TPreview = packed array[0..127, 0..31] of byte; + TDirtyTag = packed array[0 .. LAND_HEIGHT div 32 - 1, 0 .. LAND_WIDTH div 32 - 1] of byte; var Land: TCollisionArray; LandPixels: TLandArray; @@ -314,12 +314,12 @@ function LandBackPixel(x, y: LongInt): LongWord; var p: PLongWordArray; begin - if LandBackSurface = nil then LandBackPixel:= 0 - else - begin - p:= LandBackSurface^.pixels; - LandBackPixel:= p^[LandBackSurface^.w * (y mod LandBackSurface^.h) + (x mod LandBackSurface^.w)];// or $FF000000; - end + if LandBackSurface = nil then LandBackPixel:= 0 + else + begin + p:= LandBackSurface^.pixels; + LandBackPixel:= p^[LandBackSurface^.w * (y mod LandBackSurface^.h) + (x mod LandBackSurface^.w)];// or $FF000000; + end end; procedure ColorizeLand(Surface: PSDL_Surface); @@ -327,63 +327,63 @@ r, rr: TSDL_Rect; x, yd, yu: LongInt; begin - tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/LandTex', ifCritical or ifIgnoreCaps); - r.y:= 0; - while r.y < LAND_HEIGHT do - begin - r.x:= 0; - while r.x < LAND_WIDTH do - begin - SDL_UpperBlit(tmpsurf, nil, Surface, @r); - inc(r.x, tmpsurf^.w) - end; - inc(r.y, tmpsurf^.h) - end; - SDL_FreeSurface(tmpsurf); + tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/LandTex', ifCritical or ifIgnoreCaps); + r.y:= 0; + while r.y < LAND_HEIGHT do + begin + r.x:= 0; + while r.x < LAND_WIDTH do + begin + SDL_UpperBlit(tmpsurf, nil, Surface, @r); + inc(r.x, tmpsurf^.w) + end; + inc(r.y, tmpsurf^.h) + end; + SDL_FreeSurface(tmpsurf); - // freed in free_uLand() below - LandBackSurface:= LoadImage(Pathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent); + // freed in free_uLand() below + LandBackSurface:= LoadImage(Pathz[ptCurrTheme] + '/LandBackTex', ifIgnoreCaps or ifTransparent); - tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/Border', ifCritical or ifIgnoreCaps or ifTransparent); - for x:= 0 to LAND_WIDTH - 1 do - begin - yd:= LAND_HEIGHT - 1; - repeat - while (yd > 0) and (Land[yd, x] = 0) do dec(yd); + tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/Border', ifCritical or ifIgnoreCaps or ifTransparent); + for x:= 0 to LAND_WIDTH - 1 do + begin + yd:= LAND_HEIGHT - 1; + repeat + while (yd > 0) and (Land[yd, x] = 0) do dec(yd); - if (yd < 0) then yd:= 0; + if (yd < 0) then yd:= 0; - while (yd < LAND_HEIGHT) and (Land[yd, x] <> 0) do inc(yd); - dec(yd); - yu:= yd; + while (yd < LAND_HEIGHT) and (Land[yd, x] <> 0) do inc(yd); + dec(yd); + yu:= yd; - while (yu > 0 ) and (Land[yu, x] <> 0) do dec(yu); - while (yu < yd ) and (Land[yu, x] = 0) do inc(yu); + while (yu > 0 ) and (Land[yu, x] <> 0) do dec(yu); + while (yu < yd ) and (Land[yu, x] = 0) do inc(yu); - if (yd < LAND_HEIGHT - 1) and ((yd - yu) >= 16) then - begin - rr.x:= x; - rr.y:= yd - 15; - r.x:= x mod tmpsurf^.w; - r.y:= 16; - r.w:= 1; - r.h:= 16; - SDL_UpperBlit(tmpsurf, @r, Surface, @rr); - end; - if (yu > 0) then - begin - rr.x:= x; - rr.y:= yu; - r.x:= x mod tmpsurf^.w; - r.y:= 0; - r.w:= 1; - r.h:= min(16, yd - yu + 1); - SDL_UpperBlit(tmpsurf, @r, Surface, @rr); - end; - yd:= yu - 1; - until yd < 0; - end; - SDL_FreeSurface(tmpsurf); + if (yd < LAND_HEIGHT - 1) and ((yd - yu) >= 16) then + begin + rr.x:= x; + rr.y:= yd - 15; + r.x:= x mod tmpsurf^.w; + r.y:= 16; + r.w:= 1; + r.h:= 16; + SDL_UpperBlit(tmpsurf, @r, Surface, @rr); + end; + if (yu > 0) then + begin + rr.x:= x; + rr.y:= yu; + r.x:= x mod tmpsurf^.w; + r.y:= 0; + r.w:= 1; + r.h:= min(16, yd - yu + 1); + SDL_UpperBlit(tmpsurf, @r, Surface, @rr); + end; + yd:= yu - 1; + until yd < 0; + end; + SDL_FreeSurface(tmpsurf); end; procedure SetPoints(var Template: TEdgeTemplate; var pa: TPixAr); @@ -616,42 +616,42 @@ procedure LandSurface2LandPixels(Surface: PSDL_Surface); var x, y: LongInt; - p: PLongwordArray; + p: PLongwordArray; begin TryDo(Surface <> nil, 'Assert (LandSurface <> nil) failed', true); if SDL_MustLock(Surface) then - SDLTry(SDL_LockSurface(Surface) >= 0, true); + SDLTry(SDL_LockSurface(Surface) >= 0, true); p:= Surface^.pixels; for y:= 0 to LAND_HEIGHT - 1 do - begin - for x:= 0 to LAND_WIDTH - 1 do - if Land[y, x] <> 0 then LandPixels[y, x]:= p^[x] or AMask; + begin + for x:= 0 to LAND_WIDTH - 1 do + if Land[y, x] <> 0 then LandPixels[y, x]:= p^[x] or AMask; - p:= @(p^[Surface^.pitch div 4]); - end; + p:= @(p^[Surface^.pitch div 4]); + end; if SDL_MustLock(Surface) then - SDL_UnlockSurface(Surface); + SDL_UnlockSurface(Surface); end; procedure GenLandSurface; var tmpsurf: PSDL_Surface; begin - WriteLnToConsole('Generating land...'); - GenBlank(EdgeTemplates[SelectTemplate]); - AddProgress(); + WriteLnToConsole('Generating land...'); + GenBlank(EdgeTemplates[SelectTemplate]); + AddProgress(); - tmpsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, LAND_WIDTH, LAND_HEIGHT, 32, RMask, GMask, BMask, 0); + tmpsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, LAND_WIDTH, LAND_HEIGHT, 32, RMask, GMask, BMask, 0); - TryDo(tmpsurf <> nil, 'Error creating pre-land surface', true); - ColorizeLand(tmpsurf); - AddOnLandObjects(tmpsurf); + TryDo(tmpsurf <> nil, 'Error creating pre-land surface', true); + ColorizeLand(tmpsurf); + AddOnLandObjects(tmpsurf); - LandSurface2LandPixels(tmpsurf); - SDL_FreeSurface(tmpsurf); - AddProgress(); + LandSurface2LandPixels(tmpsurf); + SDL_FreeSurface(tmpsurf); + AddProgress(); end; procedure MakeFortsMap; @@ -687,40 +687,40 @@ p: PLongwordArray; x, y, cpX, cpY: Longword; begin - tmpsurf:= LoadImage(Pathz[ptMapCurrent] + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps); - if (tmpsurf <> nil) and (tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT) and (tmpsurf^.format^.BytesPerPixel = 4) then - begin - cpX:= (LAND_WIDTH - tmpsurf^.w) div 2; - cpY:= LAND_HEIGHT - tmpsurf^.h; - if SDL_MustLock(tmpsurf) then - SDLTry(SDL_LockSurface(tmpsurf) >= 0, true); + tmpsurf:= LoadImage(Pathz[ptMapCurrent] + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps); + if (tmpsurf <> nil) and (tmpsurf^.w <= LAND_WIDTH) and (tmpsurf^.h <= LAND_HEIGHT) and (tmpsurf^.format^.BytesPerPixel = 4) then + begin + cpX:= (LAND_WIDTH - tmpsurf^.w) div 2; + cpY:= LAND_HEIGHT - tmpsurf^.h; + if SDL_MustLock(tmpsurf) then + SDLTry(SDL_LockSurface(tmpsurf) >= 0, true); - p:= tmpsurf^.pixels; - for y:= 0 to Pred(tmpsurf^.h) do - begin - for x:= 0 to Pred(tmpsurf^.w) do - begin - if ((AMask and p^[x]) = 0) then // Tiy was having trouble generating transparent black - Land[cpY + y, cpX + x]:= 0 - else if p^[x] = (AMask or RMask) then - Land[cpY + y, cpX + x]:= COLOR_INDESTRUCTIBLE - else if p^[x] = $FFFFFFFF then - Land[cpY + y, cpX + x]:= COLOR_LAND; - end; - p:= @(p^[tmpsurf^.pitch div 4]); - end; + p:= tmpsurf^.pixels; + for y:= 0 to Pred(tmpsurf^.h) do + begin + for x:= 0 to Pred(tmpsurf^.w) do + begin + if ((AMask and p^[x]) = 0) then // Tiy was having trouble generating transparent black + Land[cpY + y, cpX + x]:= 0 + else if p^[x] = (AMask or RMask) then + Land[cpY + y, cpX + x]:= COLOR_INDESTRUCTIBLE + else if p^[x] = $FFFFFFFF then + Land[cpY + y, cpX + x]:= COLOR_LAND; + end; + p:= @(p^[tmpsurf^.pitch div 4]); + end; - if SDL_MustLock(tmpsurf) then - SDL_UnlockSurface(tmpsurf); - end; - if (tmpsurf <> nil) then - SDL_FreeSurface(tmpsurf); + if SDL_MustLock(tmpsurf) then + SDL_UnlockSurface(tmpsurf); + end; + if (tmpsurf <> nil) then + SDL_FreeSurface(tmpsurf); end; procedure LoadMap; var tmpsurf: PSDL_Surface; - s: shortstring; - f: textfile; + s: shortstring; + f: textfile; begin WriteLnToConsole('Loading land from file...'); AddProgress; @@ -747,10 +747,10 @@ TryDo(tmpsurf^.format^.BytesPerPixel = 4, 'Map should be 32bit', true); BlitImageAndGenerateCollisionInfo( - (LAND_WIDTH - tmpsurf^.w) div 2, - LAND_HEIGHT - tmpsurf^.h, - tmpsurf^.w, - tmpsurf); + (LAND_WIDTH - tmpsurf^.w) div 2, + LAND_HEIGHT - tmpsurf^.h, + tmpsurf^.w, + tmpsurf); SDL_FreeSurface(tmpsurf); LoadMask; @@ -789,38 +789,38 @@ end; if hasBorder then - begin - for y:= 0 to LAND_HEIGHT - 1 do - for x:= 0 to LAND_WIDTH - 1 do - if (y < topY) or (x < leftX) or (x > rightX) then - Land[y, x]:= COLOR_INDESTRUCTIBLE; - // experiment hardcoding cave - // also try basing cave dimensions on map/template dimensions, if they exist - for w:= 0 to 5 do // width of 3 allowed hogs to be knocked through with grenade - begin - for y:= topY to LAND_HEIGHT - 1 do - begin - Land[y, leftX + w]:= COLOR_INDESTRUCTIBLE; - Land[y, rightX - w]:= COLOR_INDESTRUCTIBLE; - if (y + w) mod 32 < 16 then - c:= AMask - else - c:= AMask or RMask or GMask; // FF00FFFF - LandPixels[y, leftX + w]:= c; - LandPixels[y, rightX - w]:= c; - end; + begin + for y:= 0 to LAND_HEIGHT - 1 do + for x:= 0 to LAND_WIDTH - 1 do + if (y < topY) or (x < leftX) or (x > rightX) then + Land[y, x]:= COLOR_INDESTRUCTIBLE; + // experiment hardcoding cave + // also try basing cave dimensions on map/template dimensions, if they exist + for w:= 0 to 5 do // width of 3 allowed hogs to be knocked through with grenade + begin + for y:= topY to LAND_HEIGHT - 1 do + begin + Land[y, leftX + w]:= COLOR_INDESTRUCTIBLE; + Land[y, rightX - w]:= COLOR_INDESTRUCTIBLE; + if (y + w) mod 32 < 16 then + c:= AMask + else + c:= AMask or RMask or GMask; // FF00FFFF + LandPixels[y, leftX + w]:= c; + LandPixels[y, rightX - w]:= c; + end; - for x:= leftX to rightX do - begin - Land[topY + w, x]:= COLOR_INDESTRUCTIBLE; - if (x + w) mod 32 < 16 then - c:= AMask - else - c:= AMask or RMask or GMask; // FF00FFFF - LandPixels[topY + w, x]:= c; - end; - end; - end; + for x:= leftX to rightX do + begin + Land[topY + w, x]:= COLOR_INDESTRUCTIBLE; + if (x + w) mod 32 < 16 then + c:= AMask + else + c:= AMask or RMask or GMask; // FF00FFFF + LandPixels[topY + w, x]:= c; + end; + end; + end; if (GameFlags and gfDisableGirders) <> 0 then hasGirders:= false; @@ -854,13 +854,13 @@ procedure init_uLand; begin - LandBackSurface:= nil; + LandBackSurface:= nil; end; procedure free_uLand; begin - if LandBackSurface <> nil then - SDL_FreeSurface(LandBackSurface); + if LandBackSurface <> nil then + SDL_FreeSurface(LandBackSurface); end; end. diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/uLandGraphics.pas --- a/hedgewars/uLandGraphics.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/uLandGraphics.pas Sat Mar 06 10:59:20 2010 +0000 @@ -232,68 +232,68 @@ begin // draw background land texture - begin - dx:= 0; - dy:= Radius; - d:= 3 - 2 * Radius; + begin + dx:= 0; + dy:= Radius; + d:= 3 - 2 * Radius; - while (dx < dy) do - begin - FillLandCircleLinesBG(x, y, dx, dy); - if (d < 0) - then d:= d + 4 * dx + 6 - else begin - d:= d + 4 * (dx - dy) + 10; - dec(dy) - end; - inc(dx) - end; - if (dx = dy) then FillLandCircleLinesBG(x, y, dx, dy); - end; + while (dx < dy) do + begin + FillLandCircleLinesBG(x, y, dx, dy); + if (d < 0) + then d:= d + 4 * dx + 6 + else begin + d:= d + 4 * (dx - dy) + 10; + dec(dy) + end; + inc(dx) + end; + if (dx = dy) then FillLandCircleLinesBG(x, y, dx, dy); + end; // draw a hole in land if Radius > 20 then - begin - dx:= 0; - dy:= Radius - 15; - d:= 3 - 2 * dy; + begin + dx:= 0; + dy:= Radius - 15; + d:= 3 - 2 * dy; - while (dx < dy) do - begin - FillLandCircleLines0(x, y, dx, dy); - if (d < 0) - then d:= d + 4 * dx + 6 - else begin - d:= d + 4 * (dx - dy) + 10; - dec(dy) - end; - inc(dx) - end; - if (dx = dy) then FillLandCircleLines0(x, y, dx, dy); - end; + while (dx < dy) do + begin + FillLandCircleLines0(x, y, dx, dy); + if (d < 0) + then d:= d + 4 * dx + 6 + else begin + d:= d + 4 * (dx - dy) + 10; + dec(dy) + end; + inc(dx) + end; + if (dx = dy) then FillLandCircleLines0(x, y, dx, dy); + end; // FillRoundInLand after erasing land pixels to allow Land 0 check for mask.png to function - FillRoundInLand(X, Y, Radius, 0); + FillRoundInLand(X, Y, Radius, 0); // draw explosion border - begin - inc(Radius, 4); - dx:= 0; - dy:= Radius; - d:= 3 - 2 * Radius; - while (dx < dy) do - begin - FillLandCircleLinesEBC(x, y, dx, dy); - if (d < 0) - then d:= d + 4 * dx + 6 - else begin - d:= d + 4 * (dx - dy) + 10; - dec(dy) - end; - inc(dx) - end; - if (dx = dy) then FillLandCircleLinesEBC(x, y, dx, dy); - end; + begin + inc(Radius, 4); + dx:= 0; + dy:= Radius; + d:= 3 - 2 * Radius; + while (dx < dy) do + begin + FillLandCircleLinesEBC(x, y, dx, dy); + if (d < 0) + then d:= d + 4 * dx + 6 + else begin + d:= d + 4 * (dx - dy) + 10; + dec(dy) + end; + inc(dx) + end; + if (dx = dy) then FillLandCircleLinesEBC(x, y, dx, dy); + end; tx:= max(X - Radius - 1, 0); dx:= min(X + Radius + 1, LAND_WIDTH) - tx; @@ -306,15 +306,15 @@ var tx, ty, i: LongInt; begin for i:= 0 to Pred(Count) do - begin - for ty:= max(y - Radius, 0) to min(y + Radius, LAND_HEIGHT) do - for tx:= max(0, ar^[i].Left - Radius) to min(LAND_WIDTH, ar^[i].Right + Radius) do - if Land[ty, tx] = COLOR_LAND then - LandPixels[ty, tx]:= LandBackPixel(tx, ty) - else if Land[ty, tx] = COLOR_OBJECT then - LandPixels[ty, tx]:= 0; - inc(y, dY) - end; + begin + for ty:= max(y - Radius, 0) to min(y + Radius, LAND_HEIGHT) do + for tx:= max(0, ar^[i].Left - Radius) to min(LAND_WIDTH, ar^[i].Right + Radius) do + if Land[ty, tx] = COLOR_LAND then + LandPixels[ty, tx]:= LandBackPixel(tx, ty) + else if Land[ty, tx] = COLOR_OBJECT then + LandPixels[ty, tx]:= 0; + inc(y, dY) + end; inc(Radius, 4); dec(y, Count * dY); @@ -356,15 +356,15 @@ Y:= ny - dY8; for t:= -8 to ticks + 8 do begin - X:= X + dX; - Y:= Y + dY; - tx:= hwRound(X); - ty:= hwRound(Y); - if ((ty and LAND_HEIGHT_MASK) = 0) and - ((tx and LAND_WIDTH_MASK) = 0) and - ((Land[ty, tx] = COLOR_LAND) or - (Land[ty, tx] = COLOR_OBJECT)) then - LandPixels[ty, tx]:= cExplosionBorderColor + X:= X + dX; + Y:= Y + dY; + tx:= hwRound(X); + ty:= hwRound(Y); + if ((ty and LAND_HEIGHT_MASK) = 0) and + ((tx and LAND_WIDTH_MASK) = 0) and + ((Land[ty, tx] = COLOR_LAND) or + (Land[ty, tx] = COLOR_OBJECT)) then + LandPixels[ty, tx]:= cExplosionBorderColor end; nx:= nx - dY; ny:= ny + dX; @@ -376,15 +376,15 @@ Y:= ny - dY8; for t:= 0 to 7 do begin - X:= X + dX; - Y:= Y + dY; - tx:= hwRound(X); - ty:= hwRound(Y); - if ((ty and LAND_HEIGHT_MASK) = 0) and - ((tx and LAND_WIDTH_MASK) = 0) and - ((Land[ty, tx] = COLOR_LAND) or - (Land[ty, tx] = COLOR_OBJECT)) then - LandPixels[ty, tx]:= cExplosionBorderColor + X:= X + dX; + Y:= Y + dY; + tx:= hwRound(X); + ty:= hwRound(Y); + if ((ty and LAND_HEIGHT_MASK) = 0) and + ((tx and LAND_WIDTH_MASK) = 0) and + ((Land[ty, tx] = COLOR_LAND) or + (Land[ty, tx] = COLOR_OBJECT)) then + LandPixels[ty, tx]:= cExplosionBorderColor end; X:= nx; Y:= ny; @@ -405,15 +405,15 @@ end; for t:= 0 to 7 do begin - X:= X + dX; - Y:= Y + dY; - tx:= hwRound(X); - ty:= hwRound(Y); - if ((ty and LAND_HEIGHT_MASK) = 0) and - ((tx and LAND_WIDTH_MASK) = 0) and - ((Land[ty, tx] = COLOR_LAND) or - (Land[ty, tx] = COLOR_OBJECT)) then - LandPixels[ty, tx]:= cExplosionBorderColor + X:= X + dX; + Y:= Y + dY; + tx:= hwRound(X); + ty:= hwRound(Y); + if ((ty and LAND_HEIGHT_MASK) = 0) and + ((tx and LAND_WIDTH_MASK) = 0) and + ((Land[ty, tx] = COLOR_LAND) or + (Land[ty, tx] = COLOR_OBJECT)) then + LandPixels[ty, tx]:= cExplosionBorderColor end; nx:= nx - dY; ny:= ny + dX; @@ -425,15 +425,15 @@ Y:= ny - dY8; for t:= -8 to ticks + 8 do begin - X:= X + dX; - Y:= Y + dY; - tx:= hwRound(X); - ty:= hwRound(Y); - if ((ty and LAND_HEIGHT_MASK) = 0) and - ((tx and LAND_WIDTH_MASK) = 0) and - ((Land[ty, tx] = COLOR_LAND) or - (Land[ty, tx] = COLOR_OBJECT)) then - LandPixels[ty, tx]:= cExplosionBorderColor + X:= X + dX; + Y:= Y + dY; + tx:= hwRound(X); + ty:= hwRound(Y); + if ((ty and LAND_HEIGHT_MASK) = 0) and + ((tx and LAND_WIDTH_MASK) = 0) and + ((Land[ty, tx] = COLOR_LAND) or + (Land[ty, tx] = COLOR_OBJECT)) then + LandPixels[ty, tx]:= cExplosionBorderColor end; nx:= nx - dY; ny:= ny + dX; @@ -524,26 +524,26 @@ var nx, ny, i, j, c: LongInt; begin if (Land[Y, X] <> 0) and (Land[Y, X] <> COLOR_INDESTRUCTIBLE) and (LandPixels[Y, X] = cExplosionBorderColor)then // check neighbours - begin - c:= 0; - for i:= -1 to 1 do - for j:= -1 to 1 do - if (i <> 0) or (j <> 0) then - begin - ny:= Y + i; - nx:= X + j; - if ((ny and LAND_HEIGHT_MASK) = 0) and ((nx and LAND_WIDTH_MASK) = 0) then - if Land[ny, nx] > 255 then - inc(c); - end; + begin + c:= 0; + for i:= -1 to 1 do + for j:= -1 to 1 do + if (i <> 0) or (j <> 0) then + begin + ny:= Y + i; + nx:= X + j; + if ((ny and LAND_HEIGHT_MASK) = 0) and ((nx and LAND_WIDTH_MASK) = 0) then + if Land[ny, nx] > 255 then + inc(c); + end; - if c < 4 then // 0-3 neighbours - begin + if c < 4 then // 0-3 neighbours + begin if Land[Y, X] = COLOR_LAND then LandPixels[Y, X]:= LandBackPixel(X, Y) else LandPixels[Y, X]:= 0; - Land[Y, X]:= 0; - exit(true); - end; - end; + Land[Y, X]:= 0; + exit(true); + end; + end; Despeckle:= false end; @@ -554,13 +554,13 @@ bRes:= false; for y:= 0 to LAND_HEIGHT div 32 - 1 do - begin + begin - for x:= 0 to LAND_WIDTH div 32 - 1 do - begin - if LandDirty[y, x] <> 0 then - begin - updateBlock:= false; + for x:= 0 to LAND_WIDTH div 32 - 1 do + begin + if LandDirty[y, x] <> 0 then + begin + updateBlock:= false; resweep:= true; while(resweep) do begin @@ -574,11 +574,11 @@ resweep:= true; end; end; - if updateBlock then UpdateLandTexture(x * 32, 32, y * 32, 32); - LandDirty[y, x]:= 0; - end; - end; - end; + if updateBlock then UpdateLandTexture(x * 32, 32, y * 32, 32); + LandDirty[y, x]:= 0; + end; + end; + end; SweepDirty:= bRes; end; diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/uLandObjects.pas --- a/hedgewars/uLandObjects.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/uLandObjects.pas Sat Mar 06 10:59:20 2010 +0000 @@ -30,9 +30,9 @@ implementation uses uLand, uStore, uConsts, uMisc, uConsole, uRandom, uVisualGears, uFloat, uSound, uWorld, {$IFDEF GLES11} - gles11; + gles11; {$ELSE} - GL; + GL; {$ENDIF} const MaxRects = 512; @@ -86,15 +86,15 @@ p:= Image^.pixels; for y:= 0 to Pred(Image^.h) do - begin - for x:= 0 to Pred(Width) do - if LandPixels[cpY + y, cpX + x] = 0 then - begin - LandPixels[cpY + y, cpX + x]:= p^[x]; - if (p^[x] and AMask) <> 0 then Land[cpY + y, cpX + x]:= COLOR_OBJECT; - end; - p:= @(p^[Image^.pitch shr 2]); - end; + begin + for x:= 0 to Pred(Width) do + if LandPixels[cpY + y, cpX + x] = 0 then + begin + LandPixels[cpY + y, cpX + x]:= p^[x]; + if (p^[x] and AMask) <> 0 then Land[cpY + y, cpX + x]:= COLOR_OBJECT; + end; + p:= @(p^[Image^.pitch shr 2]); + end; if SDL_MustLock(Image) then SDL_UnlockSurface(Image); @@ -122,7 +122,7 @@ procedure FreeRects; begin - Dispose(rects) + Dispose(rects) end; function CheckIntersect(x1, y1, w1, h1: LongInt): boolean; @@ -147,61 +147,61 @@ rr: TSDL_Rect; bRes: boolean; - function CountNonZeroz(x, y: LongInt): Longword; - var i: LongInt; - lRes: Longword; - begin - lRes:= 0; - for i:= y to y + 15 do - if Land[i, x] <> 0 then inc(lRes); - CountNonZeroz:= lRes; - end; + function CountNonZeroz(x, y: LongInt): Longword; + var i: LongInt; + lRes: Longword; + begin + lRes:= 0; + for i:= y to y + 15 do + if Land[i, x] <> 0 then inc(lRes); + CountNonZeroz:= lRes; + end; begin y:= topY+150; repeat - inc(y, 24); - x1:= gX; - x2:= gX; + inc(y, 24); + x1:= gX; + x2:= gX; - while (x1 > Longint(leftX)+150) and (CountNonZeroz(x1, y) = 0) do dec(x1, 2); + while (x1 > Longint(leftX)+150) and (CountNonZeroz(x1, y) = 0) do dec(x1, 2); - i:= x1 - 12; - repeat - dec(x1, 2); - k:= CountNonZeroz(x1, y) - until (x1 < Longint(leftX)+150) or (k = 0) or (k = 16) or (x1 < i); + i:= x1 - 12; + repeat + dec(x1, 2); + k:= CountNonZeroz(x1, y) + until (x1 < Longint(leftX)+150) or (k = 0) or (k = 16) or (x1 < i); - inc(x1, 2); - if k = 16 then - begin - while (x2 < (rightX-150)) and (CountNonZeroz(x2, y) = 0) do inc(x2, 2); - i:= x2 + 12; - repeat - inc(x2, 2); - k:= CountNonZeroz(x2, y) - until (x2 >= (rightX-150)) or (k = 0) or (k = 16) or (x2 > i) or (x2 - x1 >= 768); - if (x2 < (rightX - 150)) and (k = 16) and (x2 - x1 > 250) and (x2 - x1 < 768) - and not CheckIntersect(x1 - 32, y - 64, x2 - x1 + 64, 144) then break; - end; + inc(x1, 2); + if k = 16 then + begin + while (x2 < (rightX-150)) and (CountNonZeroz(x2, y) = 0) do inc(x2, 2); + i:= x2 + 12; + repeat + inc(x2, 2); + k:= CountNonZeroz(x2, y) + until (x2 >= (rightX-150)) or (k = 0) or (k = 16) or (x2 > i) or (x2 - x1 >= 768); + if (x2 < (rightX - 150)) and (k = 16) and (x2 - x1 > 250) and (x2 - x1 < 768) + and not CheckIntersect(x1 - 32, y - 64, x2 - x1 + 64, 144) then break; + end; x1:= 0; until y > (LAND_HEIGHT-125); if x1 > 0 then begin - bRes:= true; - tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/Girder', ifTransparent or ifIgnoreCaps); - if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptGraphics] + '/Girder', ifCritical or ifTransparent or ifIgnoreCaps); + bRes:= true; + tmpsurf:= LoadImage(Pathz[ptCurrTheme] + '/Girder', ifTransparent or ifIgnoreCaps); + if tmpsurf = nil then tmpsurf:= LoadImage(Pathz[ptGraphics] + '/Girder', ifCritical or ifTransparent or ifIgnoreCaps); - rr.x:= x1; - while rr.x < x2 do - begin - BlitImageAndGenerateCollisionInfo(rr.x, y, min(x2 - rr.x, tmpsurf^.w), tmpsurf); - inc(rr.x, tmpsurf^.w); - end; - SDL_FreeSurface(tmpsurf); + rr.x:= x1; + while rr.x < x2 do + begin + BlitImageAndGenerateCollisionInfo(rr.x, y, min(x2 - rr.x, tmpsurf^.w), tmpsurf); + inc(rr.x, tmpsurf^.w); + end; + SDL_FreeSurface(tmpsurf); - AddRect(x1 - 8, y - 32, x2 - x1 + 16, 80); + AddRect(x1 - 8, y - 32, x2 - x1 + 16, 80); end else bRes:= false; @@ -305,46 +305,46 @@ begin cnt:= 0; with Obj do - begin - if Maxcnt = 0 then - exit(false); - x:= 0; - r.x:= 0; - r.y:= 0; - r.w:= Width; - r.h:= Height + 16; - repeat - y:= 8; - repeat - if CheckLand(r, x, y - 8, COLOR_LAND) - and not CheckIntersect(x, y, Width, Height) then - begin - ar[cnt].x:= x; - ar[cnt].y:= y; - inc(cnt); - if cnt > MaxPointsIndex then // buffer is full, do not check the rest land - begin - y:= 5000; - x:= 5000; - end - end; - inc(y, 12); + begin + if Maxcnt = 0 then + exit(false); + x:= 0; + r.x:= 0; + r.y:= 0; + r.w:= Width; + r.h:= Height + 16; + repeat + y:= 8; + repeat + if CheckLand(r, x, y - 8, COLOR_LAND) + and not CheckIntersect(x, y, Width, Height) then + begin + ar[cnt].x:= x; + ar[cnt].y:= y; + inc(cnt); + if cnt > MaxPointsIndex then // buffer is full, do not check the rest land + begin + y:= 5000; + x:= 5000; + end + end; + inc(y, 12); until y > LAND_HEIGHT - 1 - Height - 8; - inc(x, getrandom(12) + 12) + inc(x, getrandom(12) + 12) until x > LAND_WIDTH - 1 - Width; - bRes:= cnt <> 0; - if bRes then - begin - i:= getrandom(cnt); - r.x:= ar[i].X; - r.y:= ar[i].Y; - r.w:= Width; - r.h:= Height; - SDL_UpperBlit(Obj.Surf, nil, Surface, @r); - AddRect(ar[i].x - 32, ar[i].y - 32, Width + 64, Height + 64); - dec(Maxcnt) - end else Maxcnt:= 0 - end; + bRes:= cnt <> 0; + if bRes then + begin + i:= getrandom(cnt); + r.x:= ar[i].X; + r.y:= ar[i].Y; + r.w:= Width; + r.h:= Height; + SDL_UpperBlit(Obj.Surf, nil, Surface, @r); + AddRect(ar[i].x - 32, ar[i].y - 32, Width + 64, Height + 64); + dec(Maxcnt) + end else Maxcnt:= 0 + end; TryPut:= bRes; end; @@ -355,11 +355,11 @@ vobcount: Longword; c1, c2: TSDL_Color; - procedure CheckRect(Width, Height, x, y, w, h: LongWord); - begin - if (x + w > Width) then OutError('Object''s rectangle exceeds image: x + w (' + inttostr(x) + ' + ' + inttostr(w) + ') > Width (' + inttostr(Width) + ')', true); - if (y + h > Height) then OutError('Object''s rectangle exceeds image: y + h (' + inttostr(y) + ' + ' + inttostr(h) + ') > Height (' + inttostr(Height) + ')', true); - end; + procedure CheckRect(Width, Height, x, y, w, h: LongWord); + begin + if (x + w > Width) then OutError('Object''s rectangle exceeds image: x + w (' + inttostr(x) + ' + ' + inttostr(w) + ') > Width (' + inttostr(Width) + ')', true); + if (y + h > Height) then OutError('Object''s rectangle exceeds image: y + h (' + inttostr(y) + ' + ' + inttostr(h) + ') > Height (' + inttostr(Height) + ')', true); + end; begin @@ -396,30 +396,30 @@ Readln(f, ThemeObjects.Count); for i:= 0 to Pred(ThemeObjects.Count) do - begin - Readln(f, s); // filename - with ThemeObjects.objs[i] do - begin - Surf:= LoadImage(Pathz[ptCurrTheme] + '/' + s, ifCritical or ifTransparent or ifIgnoreCaps); - Width:= Surf^.w; - Height:= Surf^.h; - Read(f, Maxcnt); - if (Maxcnt < 1) or (Maxcnt > MAXTHEMEOBJECTS) then OutError('Object''s max count should be between 1 and '+ inttostr(MAXTHEMEOBJECTS) +' (it was '+ inttostr(Maxcnt) +').', true); - with inland do - begin - Read(f, x, y, w, h); - CheckRect(Width, Height, x, y, w, h) - end; - Read(f, rectcnt); - for ii:= 1 to rectcnt do - with outland[ii] do - begin - Read(f, x, y, w, h); - CheckRect(Width, Height, x, y, w, h) - end; - ReadLn(f) - end; - end; + begin + Readln(f, s); // filename + with ThemeObjects.objs[i] do + begin + Surf:= LoadImage(Pathz[ptCurrTheme] + '/' + s, ifCritical or ifTransparent or ifIgnoreCaps); + Width:= Surf^.w; + Height:= Surf^.h; + Read(f, Maxcnt); + if (Maxcnt < 1) or (Maxcnt > MAXTHEMEOBJECTS) then OutError('Object''s max count should be between 1 and '+ inttostr(MAXTHEMEOBJECTS) +' (it was '+ inttostr(Maxcnt) +').', true); + with inland do + begin + Read(f, x, y, w, h); + CheckRect(Width, Height, x, y, w, h) + end; + Read(f, rectcnt); + for ii:= 1 to rectcnt do + with outland[ii] do + begin + Read(f, x, y, w, h); + CheckRect(Width, Height, x, y, w, h) + end; + ReadLn(f) + end; + end; // sprays Readln(f, SprayObjects.Count); @@ -453,46 +453,46 @@ var i, ii, t: LongInt; b: boolean; begin - if ThemeObjects.Count = 0 then exit; - WriteLnToConsole('Adding theme objects...'); + if ThemeObjects.Count = 0 then exit; + WriteLnToConsole('Adding theme objects...'); - for i:=0 to ThemeObjects.Count do - ThemeObjects.objs[i].Maxcnt := max(1, (ThemeObjects.objs[i].Maxcnt * MaxHedgehogs) div 18); // Maxcnt is proportional to map size, but allow objects to span even if we're on a tiny map - - repeat - t := getrandom(ThemeObjects.Count); - b := false; - for i:=0 to ThemeObjects.Count do - begin - ii := (i+t) mod ThemeObjects.Count; - - if ThemeObjects.objs[ii].Maxcnt <> 0 then - b := b or TryPut(ThemeObjects.objs[ii]) - end; - until not b; + for i:=0 to ThemeObjects.Count do + ThemeObjects.objs[i].Maxcnt := max(1, (ThemeObjects.objs[i].Maxcnt * MaxHedgehogs) div 18); // Maxcnt is proportional to map size, but allow objects to span even if we're on a tiny map + + repeat + t := getrandom(ThemeObjects.Count); + b := false; + for i:=0 to ThemeObjects.Count do + begin + ii := (i+t) mod ThemeObjects.Count; + + if ThemeObjects.objs[ii].Maxcnt <> 0 then + b := b or TryPut(ThemeObjects.objs[ii]) + end; + until not b; end; procedure AddSprayObjects(Surface: PSDL_Surface; var SprayObjects: TSprayObjects); var i, ii, t: LongInt; b: boolean; begin - if SprayObjects.Count = 0 then exit; - WriteLnToConsole('Adding spray objects...'); + if SprayObjects.Count = 0 then exit; + WriteLnToConsole('Adding spray objects...'); - for i:=0 to SprayObjects.Count do - SprayObjects.objs[i].Maxcnt := max(1, (SprayObjects.objs[i].Maxcnt * MaxHedgehogs) div 18); // Maxcnt is proportional to map size, but allow objects to span even if we're on a tiny map - - repeat - t := getrandom(SprayObjects.Count); - b := false; - for i:=0 to SprayObjects.Count do - begin - ii := (i+t) mod SprayObjects.Count; - - if SprayObjects.objs[ii].Maxcnt <> 0 then - b := b or TryPut(SprayObjects.objs[ii], Surface) - end; - until not b; + for i:=0 to SprayObjects.Count do + SprayObjects.objs[i].Maxcnt := max(1, (SprayObjects.objs[i].Maxcnt * MaxHedgehogs) div 18); // Maxcnt is proportional to map size, but allow objects to span even if we're on a tiny map + + repeat + t := getrandom(SprayObjects.Count); + b := false; + for i:=0 to SprayObjects.Count do + begin + ii := (i+t) mod SprayObjects.Count; + + if SprayObjects.objs[ii].Maxcnt <> 0 then + b := b or TryPut(SprayObjects.objs[ii], Surface) + end; + until not b; end; procedure AddObjects(); diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/uLandTexture.pas --- a/hedgewars/uLandTexture.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/uLandTexture.pas Sat Mar 06 10:59:20 2010 +0000 @@ -29,30 +29,30 @@ implementation uses uMisc, uLand, uStore, uConsts, {$IFDEF GLES11} - gles11; + gles11; {$ELSE} - GL; + GL; {$ENDIF} const TEXSIZE = 256; - LANDTEXARW = LAND_WIDTH div TEXSIZE; - LANDTEXARH = LAND_HEIGHT div TEXSIZE; + LANDTEXARW = LAND_WIDTH div TEXSIZE; + LANDTEXARH = LAND_HEIGHT div TEXSIZE; var - LandTextures: array[0..LANDTEXARW - 1, 0..LANDTEXARH - 1] of - record - shouldUpdate: boolean; - tex: PTexture; - end; + LandTextures: array[0..LANDTEXARW - 1, 0..LANDTEXARH - 1] of + record + shouldUpdate: boolean; + tex: PTexture; + end; - tmpPixels: array [0..TEXSIZE - 1, 0..TEXSIZE - 1] of LongWord; + tmpPixels: array [0..TEXSIZE - 1, 0..TEXSIZE - 1] of LongWord; function Pixels(x, y: Longword): Pointer; var ty: Longword; begin for ty:= 0 to TEXSIZE - 1 do - Move(LandPixels[y * TEXSIZE + ty, x * TEXSIZE], tmpPixels[ty, 0], sizeof(Longword) * TEXSIZE); + Move(LandPixels[y * TEXSIZE + ty, x * TEXSIZE], tmpPixels[ty, 0], sizeof(Longword) * TEXSIZE); Pixels:= @tmpPixels end; @@ -61,8 +61,8 @@ var tx, ty: Longword; begin for ty:= 0 to TEXSIZE - 1 do - for tx:= 0 to TEXSIZE - 1 do - tmpPixels[ty, tx]:= Land[y * TEXSIZE + ty, x * TEXSIZE + tx] or AMask; + for tx:= 0 to TEXSIZE - 1 do + tmpPixels[ty, tx]:= Land[y * TEXSIZE + ty, x * TEXSIZE + tx] or AMask; Pixels2:= @tmpPixels end; @@ -77,28 +77,28 @@ TryDo(Y + Height <= LAND_HEIGHT, 'UpdateLandTexture: wrong Height parameter', true); for ty:= Y div TEXSIZE to (Y + Height - 1) div TEXSIZE do - for tx:= X div TEXSIZE to (X + Width - 1) div TEXSIZE do - LandTextures[tx, ty].shouldUpdate:= true + for tx:= X div TEXSIZE to (X + Width - 1) div TEXSIZE do + LandTextures[tx, ty].shouldUpdate:= true end; procedure RealLandTexUpdate; var x, y: LongWord; begin if LandTextures[0, 0].tex = nil then - for x:= 0 to LANDTEXARW -1 do - for y:= 0 to LANDTEXARH - 1 do - with LandTextures[x, y] do - tex:= NewTexture(TEXSIZE, TEXSIZE, Pixels(x, y)) + for x:= 0 to LANDTEXARW -1 do + for y:= 0 to LANDTEXARH - 1 do + with LandTextures[x, y] do + tex:= NewTexture(TEXSIZE, TEXSIZE, Pixels(x, y)) else - for x:= 0 to LANDTEXARW -1 do - for y:= 0 to LANDTEXARH - 1 do - with LandTextures[x, y] do - if shouldUpdate then - begin - shouldUpdate:= false; - glBindTexture(GL_TEXTURE_2D, tex^.id); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, TEXSIZE, TEXSIZE, GL_RGBA, GL_UNSIGNED_BYTE, Pixels(x, y)); - end + for x:= 0 to LANDTEXARW -1 do + for y:= 0 to LANDTEXARH - 1 do + with LandTextures[x, y] do + if shouldUpdate then + begin + shouldUpdate:= false; + glBindTexture(GL_TEXTURE_2D, tex^.id); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, TEXSIZE, TEXSIZE, GL_RGBA, GL_UNSIGNED_BYTE, Pixels(x, y)); + end end; procedure DrawLand(dX, dY: LongInt); @@ -107,21 +107,21 @@ RealLandTexUpdate; for x:= 0 to LANDTEXARW -1 do - for y:= 0 to LANDTEXARH - 1 do - with LandTextures[x, y] do - DrawTexture(dX + x * TEXSIZE, dY + y * TEXSIZE, tex) + for y:= 0 to LANDTEXARH - 1 do + with LandTextures[x, y] do + DrawTexture(dX + x * TEXSIZE, dY + y * TEXSIZE, tex) end; procedure FreeLand; var x, y: LongInt; begin - for x:= 0 to LANDTEXARW -1 do - for y:= 0 to LANDTEXARH - 1 do - with LandTextures[x, y] do - begin - FreeTexture(tex); - tex:= nil; - end; + for x:= 0 to LANDTEXARW -1 do + for y:= 0 to LANDTEXARH - 1 do + with LandTextures[x, y] do + begin + FreeTexture(tex); + tex:= nil; + end; end; end. diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/uLocale.pas --- a/hedgewars/uLocale.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/uLocale.pas Sat Mar 06 10:59:20 2010 +0000 @@ -21,27 +21,27 @@ unit uLocale; interface type TAmmoStrId = (sidNothing, sidGrenade, sidClusterBomb, sidBazooka, sidUFO, sidShotgun, - sidPickHammer, sidSkip, sidRope, sidMine, sidDEagle, - sidDynamite, sidBaseballBat, sidFirePunch, sidSeconds, - sidParachute, sidAirAttack, sidMineStrike, sidBlowTorch, - sidGirder, sidTeleport, sidSwitch, sidMortar, sidWhip, - sidKamikaze, sidCake, sidSeduction, sidWatermelon, - sidHellishBomb, sidDrill, sidBallgun, sidNapalm, sidRCPlane, + sidPickHammer, sidSkip, sidRope, sidMine, sidDEagle, + sidDynamite, sidBaseballBat, sidFirePunch, sidSeconds, + sidParachute, sidAirAttack, sidMineStrike, sidBlowTorch, + sidGirder, sidTeleport, sidSwitch, sidMortar, sidWhip, + sidKamikaze, sidCake, sidSeduction, sidWatermelon, + sidHellishBomb, sidDrill, sidBallgun, sidNapalm, sidRCPlane, sidLowGravity, sidExtraDamage, sidInvulnerable, sidExtraTime, sidLaserSight, sidVampiric, sidSniperRifle, sidJetpack, sidMolotov); - TMsgStrId = (sidStartFight, sidDraw, sidWinner, sidVolume, sidPaused, - sidConfirm, sidSuddenDeath, sidRemaining, sidFuel, sidSync, - sidNoEndTurn, sidNotYetAvailable); + TMsgStrId = (sidStartFight, sidDraw, sidWinner, sidVolume, sidPaused, + sidConfirm, sidSuddenDeath, sidRemaining, sidFuel, sidSync, + sidNoEndTurn, sidNotYetAvailable); - TEventId = (eidDied, eidDrowned, eidRoundStart, eidRoundWin, eidRoundDraw, - eidNewHealthPack, eidNewAmmoPack, eidNewUtilityPack, eidTurnSkipped, eidHurtSelf, - eidHomerun, eidFrozen); + TEventId = (eidDied, eidDrowned, eidRoundStart, eidRoundWin, eidRoundDraw, + eidNewHealthPack, eidNewAmmoPack, eidNewUtilityPack, eidTurnSkipped, eidHurtSelf, + eidHomerun, eidFrozen); - TGoalStrId = (gidCaption, gidSubCaption, gidForts, gidLowGravity, gidInvulnerable, - gidVampiric, gidKarma, gidKing, gidPlaceHog, gidArtillery, - gidSolidLand, gidSharedAmmo, gidMineTimer, gidNoMineTimer, gidRandomMineTimer, - gidDamageModifier); + TGoalStrId = (gidCaption, gidSubCaption, gidForts, gidLowGravity, gidInvulnerable, + gidVampiric, gidKarma, gidKing, gidPlaceHog, gidArtillery, + gidSolidLand, gidSharedAmmo, gidMineTimer, gidNoMineTimer, gidRandomMineTimer, + gidDamageModifier); const MAX_EVENT_STRINGS = 100; var trammo: array[TAmmoStrId] of ansistring; @@ -59,15 +59,15 @@ implementation uses uMisc, uRandom, uConsole; -var trevt: array[TEventId] of array [0..Pred(MAX_EVENT_STRINGS)] of ansistring; - trevt_n: array[TEventId] of integer; +var trevt: array[TEventId] of array [0..Pred(MAX_EVENT_STRINGS)] of ansistring; + trevt_n: array[TEventId] of integer; procedure LoadLocale(FileName: shortstring); var s: shortstring; f: textfile; a, b, c: LongInt; - first: array[TEventId] of boolean; - e: TEventId; + first: array[TEventId] of boolean; + e: TEventId; loaded: boolean; begin loaded:= false; @@ -120,10 +120,10 @@ function GetEventString(e: TEventId): ansistring; begin - if trevt_n[e] = 0 then // no messages for this event type? - GetEventString:= '*missing translation*' - else - GetEventString:= trevt[e][GetRandom(trevt_n[e])]; // Pick a random message and return it + if trevt_n[e] = 0 then // no messages for this event type? + GetEventString:= '*missing translation*' + else + GetEventString:= trevt[e][GetRandom(trevt_n[e])]; // Pick a random message and return it end; function Format(fmt: shortstring; var arg: shortstring): shortstring; diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/uMisc.pas --- a/hedgewars/uMisc.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/uMisc.pas Sat Mar 06 10:59:20 2010 +0000 @@ -21,7 +21,7 @@ unit uMisc; interface -uses SDLh, uConsts, uFloat, +uses SDLh, uConsts, uFloat, {$IFDEF GLES11} gles11; {$ELSE} @@ -71,58 +71,58 @@ cGearScrEdgesDist: LongInt; cAltDamage : boolean; - GameTicks : LongWord; - TrainingTimeInc : Longword; - TrainingTimeInD : Longword; - TrainingTimeInM : Longword; - TrainingTimeMax : Longword; + GameTicks : LongWord; + TrainingTimeInc : Longword; + TrainingTimeInD : Longword; + TrainingTimeInM : Longword; + TrainingTimeMax : Longword; TimeTrialStartTime: Longword; TimeTrialStopTime : Longword; - recordFileName : shortstring; - cShowFPS : boolean; - cCaseFactor : Longword; - cLandAdditions : Longword; - cExplosives : Longword; - cFullScreen : boolean; - cReducedQuality : boolean; - cLocaleFName : shortstring; - cSeed : shortstring; - cInitVolume : LongInt; - cVolumeDelta : LongInt; - cTimerInterval : Longword; - cHasFocus : boolean; - cInactDelay : Longword; + recordFileName : shortstring; + cShowFPS : boolean; + cCaseFactor : Longword; + cLandAdditions : Longword; + cExplosives : Longword; + cFullScreen : boolean; + cReducedQuality : boolean; + cLocaleFName : shortstring; + cSeed : shortstring; + cInitVolume : LongInt; + cVolumeDelta : LongInt; + cTimerInterval : Longword; + cHasFocus : boolean; + cInactDelay : Longword; - bBetweenTurns : boolean; - cHealthDecrease : LongWord; - bWaterRising : Boolean; + bBetweenTurns : boolean; + cHealthDecrease : LongWord; + bWaterRising : Boolean; - ShowCrosshair : boolean; + ShowCrosshair : boolean; CursorMovementX : Integer; CursorMovementY : Integer; - cDrownSpeed : hwFloat; - cMaxWindSpeed : hwFloat; - cWindSpeed : hwFloat; - cGravity : hwFloat; - cDamageModifier : hwFloat; - cLaserSighting : boolean; - cVampiric : boolean; - cArtillery : boolean; + cDrownSpeed : hwFloat; + cMaxWindSpeed : hwFloat; + cWindSpeed : hwFloat; + cGravity : hwFloat; + cDamageModifier : hwFloat; + cLaserSighting : boolean; + cVampiric : boolean; + cArtillery : boolean; WeaponTooltipTex : PTexture; cWeaponTooltips: boolean; - flagMakeCapture : boolean; + flagMakeCapture : boolean; - InitStepsFlags : Longword; - RealTicks : Longword; - AttackBar : LongInt; + InitStepsFlags : Longword; + RealTicks : Longword; + AttackBar : LongInt; - WaterColorArray : array[0..3] of HwColor4f; + WaterColorArray : array[0..3] of HwColor4f; - CursorPoint : TPoint; - TargetPoint : TPoint; + CursorPoint : TPoint; + TargetPoint : TPoint; TextureList : PTexture; @@ -646,95 +646,95 @@ procedure init_uMisc; {$IFNDEF IPHONEOS}var i: LongInt;{$ENDIF} begin - cDrownSpeed.QWordValue := 257698038; // 0.06 - cMaxWindSpeed.QWordValue:= 2147484; // 0.0005 - cWindSpeed.QWordValue := 429496; // 0.0001 + cDrownSpeed.QWordValue := 257698038; // 0.06 + cMaxWindSpeed.QWordValue:= 2147484; // 0.0005 + cWindSpeed.QWordValue := 429496; // 0.0001 cGravity := cMaxWindSpeed; cDamageModifier := _1; TargetPoint := cTargetPointRef; TextureList := nil; // int, longint longword and byte - CursorMovementX := 0; - CursorMovementY := 0; - GameTicks := 0; - TrainingTimeInc := 10000; - TrainingTimeInD := 500; - TrainingTimeInM := 5000; - TrainingTimeMax := 60000; - TimeTrialStartTime := 0; - TimeTrialStopTime := 0; - cWaterLine := LAND_HEIGHT; - cGearScrEdgesDist := 240; - cHealthDecrease := 0; + CursorMovementX := 0; + CursorMovementY := 0; + GameTicks := 0; + TrainingTimeInc := 10000; + TrainingTimeInD := 500; + TrainingTimeInM := 5000; + TrainingTimeMax := 60000; + TimeTrialStartTime := 0; + TimeTrialStopTime := 0; + cWaterLine := LAND_HEIGHT; + cGearScrEdgesDist := 240; + cHealthDecrease := 0; - GameFlags := 0; - TrainingFlags := 0; - TurnTimeLeft := 0; - cSuddenDTurns := 15; - cDamagePercent := 100; - cMineDudPercent := 0; - cTemplateFilter := 0; + GameFlags := 0; + TrainingFlags := 0; + TurnTimeLeft := 0; + cSuddenDTurns := 15; + cDamagePercent := 100; + cMineDudPercent := 0; + cTemplateFilter := 0; - cHedgehogTurnTime := 45000; - cMinesTime := 3000; - cMaxAIThinkTime := 9000; + cHedgehogTurnTime := 45000; + cMinesTime := 3000; + cMaxAIThinkTime := 9000; - cCloudsNumber := 9; - cScreenWidth := 1024; - cScreenHeight := 768; - cInitWidth := cScreenWidth; - cInitHeight := cScreenHeight; - cBits := 32; - cTagsMask := 0; - KBnum := 0; - InitStepsFlags := 0; - RealTicks := 0; - AttackBar := 0; // 0 - none, 1 - just bar at the right-down corner, 2 - like in WWP + cCloudsNumber := 9; + cScreenWidth := 1024; + cScreenHeight := 768; + cInitWidth := cScreenWidth; + cInitHeight := cScreenHeight; + cBits := 32; + cTagsMask := 0; + KBnum := 0; + InitStepsFlags := 0; + RealTicks := 0; + AttackBar := 0; // 0 - none, 1 - just bar at the right-down corner, 2 - like in WWP // tgametype and glfloat and string - GameState := Low(TGameState); - GameType := gmtLocal; - zoom := 2.0; - ZoomValue := 2.0; - cBitsStr := '32'; - WeaponTooltipTex := nil; + GameState := Low(TGameState); + GameType := gmtLocal; + zoom := 2.0; + ZoomValue := 2.0; + cBitsStr := '32'; + WeaponTooltipTex := nil; // booleans - cLaserSighting := false; - cVampiric := false; - cArtillery := false; - flagMakeCapture := false; - bBetweenTurns := false; - bWaterRising := false; - isCursorVisible := false; - isTerminated := false; - isInLag := false; - isPaused := false; - isMusicEnabled := false; - isInMultiShoot := false; - isSpeed := false; - fastUntilLag := false; - cVSyncInUse := true; - isSoundEnabled := true; - isSEBackup := true; + cLaserSighting := false; + cVampiric := false; + cArtillery := false; + flagMakeCapture := false; + bBetweenTurns := false; + bWaterRising := false; + isCursorVisible := false; + isTerminated := false; + isInLag := false; + isPaused := false; + isMusicEnabled := false; + isInMultiShoot := false; + isSpeed := false; + fastUntilLag := false; + cVSyncInUse := true; + isSoundEnabled := true; + isSEBackup := true; // init flags - recordFileName := ''; - cShowFPS := false; - cCaseFactor := 5; {0..9} - cLandAdditions := 4; - cExplosives := 2; - cFullScreen := false; - cReducedQuality := false; - cLocaleFName := 'en.txt'; - cSeed := ''; - cInitVolume := 50; - cVolumeDelta := 0; - cTimerInterval := 8; - cHasFocus := true; - cInactDelay := 1250; - cAltDamage := true; + recordFileName := ''; + cShowFPS := false; + cCaseFactor := 5; {0..9} + cLandAdditions := 4; + cExplosives := 2; + cFullScreen := false; + cReducedQuality := false; + cLocaleFName := 'en.txt'; + cSeed := ''; + cInitVolume := 50; + cVolumeDelta := 0; + cTimerInterval := 8; + cHasFocus := true; + cInactDelay := 1250; + cAltDamage := true; {$IFDEF DEBUGFILE} {$I-} {$IFDEF IPHONEOS} diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/uRandom.pas --- a/hedgewars/uRandom.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/uRandom.pas Sat Mar 06 10:59:20 2010 +0000 @@ -92,13 +92,13 @@ var i: LongInt; begin for i:= 0 to 63 do - AddFileLog('[' + inttostr(i) + '] = ' + inttostr(cirbuf[i])) + AddFileLog('[' + inttostr(i) + '] = ' + inttostr(cirbuf[i])) end; {$ENDIF} procedure init_uRandom; begin - n:= 54; + n:= 54; end; procedure free_uRandom; diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/uScript.pas --- a/hedgewars/uScript.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/uScript.pas Sat Mar 06 10:59:20 2010 +0000 @@ -39,22 +39,22 @@ implementation {$IFNDEF IPHONEOS} uses LuaPas in 'LuaPas.pas', - uConsole, - uMisc, - uConsts, - uGears, - uFloat, - uWorld, - uAmmos, - uSound, - uTeams, - uKeys, - typinfo; - + uConsole, + uMisc, + uConsts, + uGears, + uFloat, + uWorld, + uAmmos, + uSound, + uTeams, + uKeys, + typinfo; + var luaState : Plua_State; - ScriptAmmoStore : shortstring; - ScriptLoaded : boolean; - + ScriptAmmoStore : shortstring; + ScriptLoaded : boolean; + procedure ScriptPrepareAmmoStore; forward; procedure ScriptApplyAmmoStore; forward; procedure ScriptSetAmmo(ammo : TAmmoType; count, propability: Byte); forward; @@ -68,237 +68,237 @@ function lc_writelntoconsole(L : Plua_State) : LongInt; Cdecl; begin - if lua_gettop(L) = 1 then - begin - WriteLnToConsole('LUA: ' + lua_tostring(L ,1)); - end - else - WriteLnToConsole('LUA: Wrong number of parameters passed to WriteLnToConsole!'); - lc_writelntoconsole:= 0; + if lua_gettop(L) = 1 then + begin + WriteLnToConsole('LUA: ' + lua_tostring(L ,1)); + end + else + WriteLnToConsole('LUA: Wrong number of parameters passed to WriteLnToConsole!'); + lc_writelntoconsole:= 0; end; function lc_parsecommand(L : Plua_State) : LongInt; Cdecl; begin - if lua_gettop(L) = 1 then - begin - ParseCommand(lua_tostring(L ,1), true); - end - else - WriteLnToConsole('LUA: Wrong number of parameters passed to ParseCommand!'); - lc_parsecommand:= 0; + if lua_gettop(L) = 1 then + begin + ParseCommand(lua_tostring(L ,1), true); + end + else + WriteLnToConsole('LUA: Wrong number of parameters passed to ParseCommand!'); + lc_parsecommand:= 0; end; function lc_showmission(L : Plua_State) : LongInt; Cdecl; begin - if lua_gettop(L) = 5 then - begin - ShowMission(lua_tostring(L, 1), lua_tostring(L, 2), lua_tostring(L, 3), lua_tointeger(L, 4), lua_tointeger(L, 5)); - end - else - WriteLnToConsole('LUA: Wrong number of parameters passed to ShowMission!'); - lc_showmission:= 0; + if lua_gettop(L) = 5 then + begin + ShowMission(lua_tostring(L, 1), lua_tostring(L, 2), lua_tostring(L, 3), lua_tointeger(L, 4), lua_tointeger(L, 5)); + end + else + WriteLnToConsole('LUA: Wrong number of parameters passed to ShowMission!'); + lc_showmission:= 0; end; function lc_hidemission(L : Plua_State) : LongInt; Cdecl; begin - HideMission; - lc_hidemission:= 0; + HideMission; + lc_hidemission:= 0; end; function lc_addgear(L : Plua_State) : LongInt; Cdecl; var gear : PGear; - x, y, s, t: LongInt; - dx, dy: hwFloat; - gt: TGearType; + x, y, s, t: LongInt; + dx, dy: hwFloat; + gt: TGearType; begin - if lua_gettop(L) <> 7 then - begin - WriteLnToConsole('LUA: Wrong number of parameters passed to AddGear!'); - lua_pushnil(L); // return value on stack (nil) - end - else - begin - x:= lua_tointeger(L, 1); - y:= lua_tointeger(L, 2); - gt:= TGearType(lua_tointeger(L, 3)); - s:= lua_tointeger(L, 4); - dx:= int2hwFloat(round(lua_tonumber(L, 5) * 1000)) / 1000; - dy:= int2hwFloat(round(lua_tonumber(L, 6) * 1000)) / 1000; - t:= lua_tointeger(L, 7); + if lua_gettop(L) <> 7 then + begin + WriteLnToConsole('LUA: Wrong number of parameters passed to AddGear!'); + lua_pushnil(L); // return value on stack (nil) + end + else + begin + x:= lua_tointeger(L, 1); + y:= lua_tointeger(L, 2); + gt:= TGearType(lua_tointeger(L, 3)); + s:= lua_tointeger(L, 4); + dx:= int2hwFloat(round(lua_tonumber(L, 5) * 1000)) / 1000; + dy:= int2hwFloat(round(lua_tonumber(L, 6) * 1000)) / 1000; + t:= lua_tointeger(L, 7); - gear:= AddGear(x, y, gt, s, dx, dy, t); - lua_pushnumber(L, gear^.uid) - end; - lc_addgear:= 1; // 1 return value + gear:= AddGear(x, y, gt, s, dx, dy, t); + lua_pushnumber(L, gear^.uid) + end; + lc_addgear:= 1; // 1 return value end; function lc_getgeartype(L : Plua_State) : LongInt; Cdecl; var gear : PGear; begin - if lua_gettop(L) <> 1 then - begin - WriteLnToConsole('LUA: Wrong number of parameters passed to GetGearType!'); - lua_pushnil(L); // return value on stack (nil) - end - else - begin - gear:= GearByUID(lua_tointeger(L, 1)); - if gear <> nil then - lua_pushinteger(L, ord(gear^.Kind)) - end; - lc_getgeartype:= 1 + if lua_gettop(L) <> 1 then + begin + WriteLnToConsole('LUA: Wrong number of parameters passed to GetGearType!'); + lua_pushnil(L); // return value on stack (nil) + end + else + begin + gear:= GearByUID(lua_tointeger(L, 1)); + if gear <> nil then + lua_pushinteger(L, ord(gear^.Kind)) + end; + lc_getgeartype:= 1 end; function lc_sethealth(L : Plua_State) : LongInt; Cdecl; var gear : PGear; begin - if lua_gettop(L) <> 2 then - begin - WriteLnToConsole('LUA: Wrong number of parameters passed to SetHealth!'); - end - else - begin - gear:= GearByUID(lua_tointeger(L, 1)); - if (gear <> nil) and (gear^.Kind = gtHedgehog) then gear^.Health:= lua_tointeger(L, 2) - end; - lc_sethealth:= 0 + if lua_gettop(L) <> 2 then + begin + WriteLnToConsole('LUA: Wrong number of parameters passed to SetHealth!'); + end + else + begin + gear:= GearByUID(lua_tointeger(L, 1)); + if (gear <> nil) and (gear^.Kind = gtHedgehog) then gear^.Health:= lua_tointeger(L, 2) + end; + lc_sethealth:= 0 end; function lc_endgame(L : Plua_State) : LongInt; Cdecl; begin - GameState:= gsExit; - lc_endgame:= 0 + GameState:= gsExit; + lc_endgame:= 0 end; function lc_findplace(L : Plua_State) : LongInt; Cdecl; var gear: PGear; - fall: boolean; - left, right: LongInt; + fall: boolean; + left, right: LongInt; begin - if lua_gettop(L) <> 4 then - WriteLnToConsole('LUA: Wrong number of parameters passed to FindPlace!') - else - begin - gear:= GearByUID(lua_tointeger(L, 1)); - fall:= lua_toboolean(L, 2); - left:= lua_tointeger(L, 3); - right:= lua_tointeger(L, 4); - if gear <> nil then - FindPlace(gear, fall, left, right) - end; - lc_findplace:= 0 + if lua_gettop(L) <> 4 then + WriteLnToConsole('LUA: Wrong number of parameters passed to FindPlace!') + else + begin + gear:= GearByUID(lua_tointeger(L, 1)); + fall:= lua_toboolean(L, 2); + left:= lua_tointeger(L, 3); + right:= lua_tointeger(L, 4); + if gear <> nil then + FindPlace(gear, fall, left, right) + end; + lc_findplace:= 0 end; function lc_playsound(L : Plua_State) : LongInt; Cdecl; begin - if lua_gettop(L) <> 1 then - WriteLnToConsole('LUA: Wrong number of parameters passed to PlaySound!') - else - PlaySound(TSound(lua_tointeger(L, 1))); - lc_playsound:= 0; + if lua_gettop(L) <> 1 then + WriteLnToConsole('LUA: Wrong number of parameters passed to PlaySound!') + else + PlaySound(TSound(lua_tointeger(L, 1))); + lc_playsound:= 0; end; function lc_addteam(L : Plua_State) : LongInt; Cdecl; begin - if lua_gettop(L) <> 5 then - begin - WriteLnToConsole('LUA: Wrong number of parameters passed to AddTeam!'); - //lua_pushnil(L) - end - else - begin - ParseCommand('addteam x ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 1), true); - ParseCommand('grave ' + lua_tostring(L, 3), true); - ParseCommand('fort ' + lua_tostring(L, 4), true); - ParseCommand('voicepack ' + lua_tostring(L, 5), true); - CurrentTeam^.Binds:= DefaultBinds; - // fails on x64 - //lua_pushinteger(L, LongInt(CurrentTeam)); - end; - lc_addteam:= 0;//1; + if lua_gettop(L) <> 5 then + begin + WriteLnToConsole('LUA: Wrong number of parameters passed to AddTeam!'); + //lua_pushnil(L) + end + else + begin + ParseCommand('addteam x ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 1), true); + ParseCommand('grave ' + lua_tostring(L, 3), true); + ParseCommand('fort ' + lua_tostring(L, 4), true); + ParseCommand('voicepack ' + lua_tostring(L, 5), true); + CurrentTeam^.Binds:= DefaultBinds; + // fails on x64 + //lua_pushinteger(L, LongInt(CurrentTeam)); + end; + lc_addteam:= 0;//1; end; function lc_addhog(L : Plua_State) : LongInt; Cdecl; begin - if lua_gettop(L) <> 4 then - begin - WriteLnToConsole('LUA: Wrong number of parameters passed to AddHog!'); - lua_pushnil(L) - end - else - begin - ParseCommand('addhh ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 3) + ' ' + lua_tostring(L, 1), true); - ParseCommand('hat ' + lua_tostring(L, 4), true); - lua_pushinteger(L, CurrentHedgehog^.Gear^.uid); - end; - lc_addhog:= 1; + if lua_gettop(L) <> 4 then + begin + WriteLnToConsole('LUA: Wrong number of parameters passed to AddHog!'); + lua_pushnil(L) + end + else + begin + ParseCommand('addhh ' + lua_tostring(L, 2) + ' ' + lua_tostring(L, 3) + ' ' + lua_tostring(L, 1), true); + ParseCommand('hat ' + lua_tostring(L, 4), true); + lua_pushinteger(L, CurrentHedgehog^.Gear^.uid); + end; + lc_addhog:= 1; end; function lc_getgearposition(L : Plua_State) : LongInt; Cdecl; var gear: PGear; begin - if lua_gettop(L) <> 1 then - begin - WriteLnToConsole('LUA: Wrong number of parameters passed to GetGearPosition!'); - lua_pushnil(L); - lua_pushnil(L) - end - else - begin - gear:= GearByUID(lua_tointeger(L, 1)); - if gear <> nil then - begin - lua_pushinteger(L, hwRound(gear^.X)); - lua_pushinteger(L, hwRound(gear^.Y)) - end - end; - lc_getgearposition:= 2; + if lua_gettop(L) <> 1 then + begin + WriteLnToConsole('LUA: Wrong number of parameters passed to GetGearPosition!'); + lua_pushnil(L); + lua_pushnil(L) + end + else + begin + gear:= GearByUID(lua_tointeger(L, 1)); + if gear <> nil then + begin + lua_pushinteger(L, hwRound(gear^.X)); + lua_pushinteger(L, hwRound(gear^.Y)) + end + end; + lc_getgearposition:= 2; end; function lc_setgearposition(L : Plua_State) : LongInt; Cdecl; var gear: PGear; - x, y: LongInt; + x, y: LongInt; begin - if lua_gettop(L) <> 3 then - WriteLnToConsole('LUA: Wrong number of parameters passed to SetGearPosition!') - else - begin - gear:= GearByUID(lua_tointeger(L, 1)); - if gear <> nil then - begin - x:= lua_tointeger(L, 2); - y:= lua_tointeger(L, 3); - gear^.X:= int2hwfloat(x); - gear^.Y:= int2hwfloat(y); - end - end; - lc_setgearposition:= 0 + if lua_gettop(L) <> 3 then + WriteLnToConsole('LUA: Wrong number of parameters passed to SetGearPosition!') + else + begin + gear:= GearByUID(lua_tointeger(L, 1)); + if gear <> nil then + begin + x:= lua_tointeger(L, 2); + y:= lua_tointeger(L, 3); + gear^.X:= int2hwfloat(x); + gear^.Y:= int2hwfloat(y); + end + end; + lc_setgearposition:= 0 end; function lc_setammo(L : Plua_State) : LongInt; Cdecl; begin - if lua_gettop(L) <> 3 then - WriteLnToConsole('LUA: Wrong number of parameters passed to SetAmmo!') - else - begin - ScriptSetAmmo(TAmmoType(lua_tointeger(L, 1)), lua_tointeger(L, 2), lua_tointeger(L, 3)); - end; - lc_setammo:= 0 + if lua_gettop(L) <> 3 then + WriteLnToConsole('LUA: Wrong number of parameters passed to SetAmmo!') + else + begin + ScriptSetAmmo(TAmmoType(lua_tointeger(L, 1)), lua_tointeger(L, 2), lua_tointeger(L, 3)); + end; + lc_setammo:= 0 end; /////////////////// procedure ScriptPrintStack; var n, i : LongInt; begin - n:= lua_gettop(luaState); - WriteLnToConsole('LUA: Stack (' + inttostr(n) + ' elements):'); - for i:= 1 to n do - if not lua_isboolean(luaState, i) then - WriteLnToConsole('LUA: ' + inttostr(i) + ': ' + lua_tostring(luaState, i)) - else if lua_toboolean(luaState, i) then - WriteLnToConsole('LUA: ' + inttostr(i) + ': true') - else - WriteLnToConsole('LUA: ' + inttostr(i) + ': false'); + n:= lua_gettop(luaState); + WriteLnToConsole('LUA: Stack (' + inttostr(n) + ' elements):'); + for i:= 1 to n do + if not lua_isboolean(luaState, i) then + WriteLnToConsole('LUA: ' + inttostr(i) + ': ' + lua_tostring(luaState, i)) + else if lua_toboolean(luaState, i) then + WriteLnToConsole('LUA: ' + inttostr(i) + ': true') + else + WriteLnToConsole('LUA: ' + inttostr(i) + ': false'); end; procedure ScriptClearStack; @@ -334,76 +334,76 @@ procedure ScriptOnGameInit; begin - // not required if there's no script to run - if not ScriptLoaded then - exit; - - // push game variables so they may be modified by the script - ScriptSetInteger('GameFlags', GameFlags); - ScriptSetString('Seed', cSeed); - ScriptSetInteger('TurnTime', cHedgehogTurnTime); - ScriptSetInteger('CaseFreq', cCaseFactor); - ScriptSetInteger('LandAdds', cLandAdditions); - ScriptSetInteger('Delay', cInactDelay); - ScriptSetString('Map', ''); - ScriptSetString('Theme', ''); + // not required if there's no script to run + if not ScriptLoaded then + exit; + + // push game variables so they may be modified by the script + ScriptSetInteger('GameFlags', GameFlags); + ScriptSetString('Seed', cSeed); + ScriptSetInteger('TurnTime', cHedgehogTurnTime); + ScriptSetInteger('CaseFreq', cCaseFactor); + ScriptSetInteger('LandAdds', cLandAdditions); + ScriptSetInteger('Delay', cInactDelay); + ScriptSetString('Map', ''); + ScriptSetString('Theme', ''); - ScriptCall('onGameInit'); - - // pop game variables - ParseCommand('seed ' + ScriptGetString('Seed'), true); - ParseCommand('$gmflags ' + ScriptGetString('GameFlags'), true); - ParseCommand('$turntime ' + ScriptGetString('TurnTime'), true); - ParseCommand('$casefreq ' + ScriptGetString('CaseFreq'), true); - ParseCommand('$landadds ' + ScriptGetString('LandAdds'), true); - ParseCommand('$delay ' + ScriptGetString('Delay'), true); - if ScriptGetString('Map') <> '' then - ParseCommand('map ' + ScriptGetString('Map'), true); - if ScriptGetString('Theme') <> '' then - ParseCommand('theme ' + ScriptGetString('Theme'), true); + ScriptCall('onGameInit'); + + // pop game variables + ParseCommand('seed ' + ScriptGetString('Seed'), true); + ParseCommand('$gmflags ' + ScriptGetString('GameFlags'), true); + ParseCommand('$turntime ' + ScriptGetString('TurnTime'), true); + ParseCommand('$casefreq ' + ScriptGetString('CaseFreq'), true); + ParseCommand('$landadds ' + ScriptGetString('LandAdds'), true); + ParseCommand('$delay ' + ScriptGetString('Delay'), true); + if ScriptGetString('Map') <> '' then + ParseCommand('map ' + ScriptGetString('Map'), true); + if ScriptGetString('Theme') <> '' then + ParseCommand('theme ' + ScriptGetString('Theme'), true); - ScriptPrepareAmmoStore; - ScriptCall('onAmmoStoreInit'); - ScriptApplyAmmoStore; + ScriptPrepareAmmoStore; + ScriptCall('onAmmoStoreInit'); + ScriptApplyAmmoStore; end; procedure ScriptLoad(name : shortstring); var ret : LongInt; begin - ret:= luaL_loadfile(luaState, Str2PChar(name)); - if ret <> 0 then - WriteLnToConsole('LUA: Failed to load ' + name + '(error ' + IntToStr(ret) + ')') - else - begin - WriteLnToConsole('LUA: ' + name + ' loaded'); - // call the script file - lua_pcall(luaState, 0, 0, 0); - ScriptLoaded:= true - end + ret:= luaL_loadfile(luaState, Str2PChar(name)); + if ret <> 0 then + WriteLnToConsole('LUA: Failed to load ' + name + '(error ' + IntToStr(ret) + ')') + else + begin + WriteLnToConsole('LUA: ' + name + ' loaded'); + // call the script file + lua_pcall(luaState, 0, 0, 0); + ScriptLoaded:= true + end end; procedure SetGlobals; begin - ScriptSetInteger('TurnTimeLeft', TurnTimeLeft); + ScriptSetInteger('TurnTimeLeft', TurnTimeLeft); end; procedure GetGlobals; begin - TurnTimeLeft:= ScriptGetInteger('TurnTimeLeft'); + TurnTimeLeft:= ScriptGetInteger('TurnTimeLeft'); end; procedure ScriptCall(fname : shortstring); begin - if not ScriptLoaded then - exit; - SetGlobals; - lua_getglobal(luaState, Str2PChar(fname)); - if lua_pcall(luaState, 0, 0, 0) <> 0 then - begin - WriteLnToConsole('LUA: Error while calling ' + fname + ': ' + lua_tostring(luaState, -1)); - lua_pop(luaState, 1) - end; - GetGlobals; + if not ScriptLoaded then + exit; + SetGlobals; + lua_getglobal(luaState, Str2PChar(fname)); + if lua_pcall(luaState, 0, 0, 0) <> 0 then + begin + WriteLnToConsole('LUA: Error while calling ' + fname + ': ' + lua_tostring(luaState, -1)); + lua_pop(luaState, 1) + end; + GetGlobals; end; function ScriptCall(fname : shortstring; par1: LongInt) : LongInt; @@ -423,26 +423,26 @@ function ScriptCall(fname : shortstring; par1, par2, par3, par4 : LongInt) : LongInt; begin - if not ScriptLoaded then - exit; - SetGlobals; - lua_getglobal(luaState, Str2PChar(fname)); - lua_pushinteger(luaState, par1); - lua_pushinteger(luaState, par2); - lua_pushinteger(luaState, par3); - lua_pushinteger(luaState, par4); - ScriptCall:= 0; - if lua_pcall(luaState, 4, 1, 0) <> 0 then - begin - WriteLnToConsole('LUA: Error while calling ' + fname + ': ' + lua_tostring(luaState, -1)); - lua_pop(luaState, 1) - end - else - begin - ScriptCall:= lua_tointeger(luaState, -1); - lua_pop(luaState, 1) - end; - GetGlobals; + if not ScriptLoaded then + exit; + SetGlobals; + lua_getglobal(luaState, Str2PChar(fname)); + lua_pushinteger(luaState, par1); + lua_pushinteger(luaState, par2); + lua_pushinteger(luaState, par3); + lua_pushinteger(luaState, par4); + ScriptCall:= 0; + if lua_pcall(luaState, 4, 1, 0) <> 0 then + begin + WriteLnToConsole('LUA: Error while calling ' + fname + ': ' + lua_tostring(luaState, -1)); + lua_pop(luaState, 1) + end + else + begin + ScriptCall:= lua_tointeger(luaState, -1); + lua_pop(luaState, 1) + end; + GetGlobals; end; procedure ScriptPrepareAmmoStore; @@ -450,20 +450,20 @@ begin ScriptAmmoStore:= ''; for i:=1 to ord(High(TAmmoType)) do - ScriptAmmoStore:= ScriptAmmoStore + '0000'; + ScriptAmmoStore:= ScriptAmmoStore + '0000'; end; procedure ScriptSetAmmo(ammo : TAmmoType; count, propability: Byte); begin if (ord(ammo) < 1) or (count > 9) or (count < 0) or (propability < 0) or (propability > 8) then - exit; + exit; ScriptAmmoStore[ord(ammo)]:= inttostr(count)[1]; ScriptAmmoStore[ord(ammo) + ord(high(TAmmoType))]:= inttostr(propability)[1]; end; procedure ScriptApplyAmmoStore; begin - AddAmmoStore(ScriptAmmoStore); + AddAmmoStore(ScriptAmmoStore); end; // small helper functions making registering enums a lot easier @@ -485,8 +485,8 @@ procedure init_uScript; var at : TGearType; - am : TAmmoType; - st : TSound; + am : TAmmoType; + st : TSound; begin // initialize lua luaState:= lua_open; @@ -519,16 +519,16 @@ // register gear types for at:= Low(TGearType) to High(TGearType) do - ScriptSetInteger(str(at), ord(at)); + ScriptSetInteger(str(at), ord(at)); // register sounds for st:= Low(TSound) to High(TSound) do - ScriptSetInteger(str(st), ord(st)); + ScriptSetInteger(str(st), ord(st)); // register ammo types for am:= Low(TAmmoType) to High(TAmmoType) do - ScriptSetInteger(str(am), ord(am)); - + ScriptSetInteger(str(am), ord(am)); + // register functions lua_register(luaState, 'AddGear', @lc_addgear); lua_register(luaState, 'WriteLnToConsole', @lc_writelntoconsole); diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/uSound.pas --- a/hedgewars/uSound.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/uSound.pas Sat Mar 06 10:59:20 2010 +0000 @@ -23,10 +23,10 @@ uses SDLh, uConsts; type PVoicepack = ^TVoicepack; - TVoicepack = record - name: shortstring; - chunks: array [TSound] of PMixChunk; - end; + TVoicepack = record + name: shortstring; + chunks: array [TSound] of PMixChunk; + end; var MusicFN: shortstring; @@ -64,10 +64,10 @@ begin i:= 0; while (voicepacks[i].name <> name) and (voicepacks[i].name <> '') do - begin - inc(i); - TryDo(i <= cMaxTeams, 'Engine bug: AskForVoicepack i > cMaxTeams', true) - end; + begin + inc(i); + TryDo(i <= cMaxTeams, 'Engine bug: AskForVoicepack i > cMaxTeams', true) + end; voicepacks[i].name:= name; AskForVoicepack:= @voicepacks[i] @@ -76,37 +76,37 @@ procedure InitSound; var i: TSound; begin - if not isSoundEnabled then exit; - WriteToConsole('Init sound...'); - isSoundEnabled:= SDL_InitSubSystem(SDL_INIT_AUDIO) >= 0; + if not isSoundEnabled then exit; + WriteToConsole('Init sound...'); + isSoundEnabled:= SDL_InitSubSystem(SDL_INIT_AUDIO) >= 0; - if isSoundEnabled then - isSoundEnabled:= Mix_OpenAudio(44100, $8010, 2, 1024) = 0; + if isSoundEnabled then + isSoundEnabled:= Mix_OpenAudio(44100, $8010, 2, 1024) = 0; - if isSoundEnabled then - WriteLnToConsole(msgOK) - else - WriteLnToConsole(msgFailed); + if isSoundEnabled then + WriteLnToConsole(msgOK) + else + WriteLnToConsole(msgFailed); - Mix_AllocateChannels(Succ(chanTPU)); - if isMusicEnabled then - Mix_VolumeMusic(50); - for i:= Low(TSound) to High(TSound) do - lastChan[i]:= -1; + Mix_AllocateChannels(Succ(chanTPU)); + if isMusicEnabled then + Mix_VolumeMusic(50); + for i:= Low(TSound) to High(TSound) do + lastChan[i]:= -1; - Volume:= 0; - ChangeVolume(cInitVolume) + Volume:= 0; + ChangeVolume(cInitVolume) end; procedure ReleaseSound; var i: TSound; - t: Longword; + t: Longword; begin for t:= 0 to cMaxTeams do - if voicepacks[t].name <> '' then - for i:= Low(TSound) to High(TSound) do - if voicepacks[t].chunks[i] <> nil then - Mix_FreeChunk(voicepacks[t].chunks[i]); + if voicepacks[t].name <> '' then + for i:= Low(TSound) to High(TSound) do + if voicepacks[t].chunks[i] <> nil then + Mix_FreeChunk(voicepacks[t].chunks[i]); Mix_FreeMusic(Mus); Mix_CloseAudio(); @@ -114,50 +114,50 @@ procedure SoundLoad; var i: TSound; - s: shortstring; - t: Longword; + s: shortstring; + t: Longword; begin - if not isSoundEnabled then exit; + if not isSoundEnabled then exit; {$IFDEF SDL_MIXER_NEWER} - WriteToConsole('Init SDL_mixer... '); - SDLTry(Mix_Init(MIX_INIT_OGG) <> 0, true); - WriteLnToConsole(msgOK); + WriteToConsole('Init SDL_mixer... '); + SDLTry(Mix_Init(MIX_INIT_OGG) <> 0, true); + WriteLnToConsole(msgOK); {$ENDIF} - defVoicepack:= AskForVoicepack('Default'); + defVoicepack:= AskForVoicepack('Default'); for i:= Low(TSound) to High(TSound) do - if (Soundz[i].Path <> ptVoices) and (Soundz[i].FileName <> '') then - begin - s:= Pathz[Soundz[i].Path] + '/' + Soundz[i].FileName; - WriteToConsole(msgLoading + s + ' '); - defVoicepack^.chunks[i]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); - TryDo(defVoicepack^.chunks[i] <> nil, msgFailed, true); - WriteLnToConsole(msgOK); - end; + if (Soundz[i].Path <> ptVoices) and (Soundz[i].FileName <> '') then + begin + s:= Pathz[Soundz[i].Path] + '/' + Soundz[i].FileName; + WriteToConsole(msgLoading + s + ' '); + defVoicepack^.chunks[i]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); + TryDo(defVoicepack^.chunks[i] <> nil, msgFailed, true); + WriteLnToConsole(msgOK); + end; for t:= 0 to cMaxTeams do - if voicepacks[t].name <> '' then - for i:= Low(TSound) to High(TSound) do - if (Soundz[i].Path = ptVoices) and (Soundz[i].FileName <> '') then - begin - s:= Pathz[Soundz[i].Path] + '/' + voicepacks[t].name + '/' + Soundz[i].FileName; - WriteToConsole(msgLoading + s + ' '); - voicepacks[t].chunks[i]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); - if voicepacks[t].chunks[i] = nil then - WriteLnToConsole(msgFailed) - else - WriteLnToConsole(msgOK) - end; + if voicepacks[t].name <> '' then + for i:= Low(TSound) to High(TSound) do + if (Soundz[i].Path = ptVoices) and (Soundz[i].FileName <> '') then + begin + s:= Pathz[Soundz[i].Path] + '/' + voicepacks[t].name + '/' + Soundz[i].FileName; + WriteToConsole(msgLoading + s + ' '); + voicepacks[t].chunks[i]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); + if voicepacks[t].chunks[i] = nil then + WriteLnToConsole(msgFailed) + else + WriteLnToConsole(msgOK) + end; {$IFDEF SDL_MIXER_NEWER} - Mix_Quit(); -{$ENDIF} + Mix_Quit(); +{$ENDIF} end; procedure PlaySound(snd: TSound); begin - PlaySound(snd, nil); + PlaySound(snd, nil); end; procedure PlaySound(snd: TSound; voicepack: PVoicepack); @@ -165,38 +165,38 @@ if (not isSoundEnabled) or fastUntilLag then exit; if (voicepack <> nil) and (voicepack^.chunks[snd] <> nil) then - lastChan[snd]:= Mix_PlayChannelTimed(-1, voicepack^.chunks[snd], 0, -1) + lastChan[snd]:= Mix_PlayChannelTimed(-1, voicepack^.chunks[snd], 0, -1) else - lastChan[snd]:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], 0, -1) + lastChan[snd]:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], 0, -1) end; function LoopSound(snd: TSound): LongInt; begin - LoopSound:= LoopSound(snd, nil) + LoopSound:= LoopSound(snd, nil) end; function LoopSound(snd: TSound; voicepack: PVoicepack): LongInt; begin if (not isSoundEnabled) or fastUntilLag then - begin - LoopSound:= -1; - exit - end; + begin + LoopSound:= -1; + exit + end; if (voicepack <> nil) and (voicepack^.chunks[snd] <> nil) then - LoopSound:= Mix_PlayChannelTimed(-1, voicepack^.chunks[snd], -1, -1) + LoopSound:= Mix_PlayChannelTimed(-1, voicepack^.chunks[snd], -1, -1) else - LoopSound:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], -1, -1) + LoopSound:= Mix_PlayChannelTimed(-1, defVoicepack^.chunks[snd], -1, -1) end; procedure StopSound(snd: TSound); begin if not isSoundEnabled then exit; if (lastChan[snd] <> -1) and (Mix_Playing(lastChan[snd]) <> 0) then - begin - Mix_HaltChannel(lastChan[snd]); - lastChan[snd]:= -1; - end; + begin + Mix_HaltChannel(lastChan[snd]); + lastChan[snd]:= -1; + end; end; procedure StopSound(chn: LongInt); @@ -209,8 +209,8 @@ var s: shortstring; begin if (not isSoundEnabled) - or (MusicFN = '') - or (not isMusicEnabled) then exit; + or (MusicFN = '') + or (not isMusicEnabled) then exit; s:= PathPrefix + '/Music/' + MusicFN; WriteToConsole(msgLoading + s + ' '); @@ -225,7 +225,7 @@ function ChangeVolume(voldelta: LongInt): LongInt; begin if not isSoundEnabled then - exit(0); + exit(0); inc(Volume, voldelta); if Volume < 0 then Volume:= 0; @@ -251,7 +251,7 @@ procedure init_uSound; begin - MusicFN:=''; + MusicFN:=''; end; procedure free_uSound; diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/uStats.pas --- a/hedgewars/uStats.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/uStats.pas Sat Mar 06 10:59:20 2010 +0000 @@ -49,41 +49,41 @@ implementation uses uTeams, uSound, uMisc, uLocale, uWorld; var DamageGiven : Longword = 0; - DamageClan : Longword = 0; - DamageTotal : Longword = 0; - KillsClan : LongWord = 0; - Kills : LongWord = 0; - KillsTotal : LongWord = 0; - AmmoUsedCount : Longword = 0; - AmmoDamagingUsed : boolean = false; - SkippedTurns: LongWord = 0; - isTurnSkipped: boolean = false; - vpHurtSameClan: PVoicepack = nil; - vpHurtEnemy: PVoicepack = nil; + DamageClan : Longword = 0; + DamageTotal : Longword = 0; + KillsClan : LongWord = 0; + Kills : LongWord = 0; + KillsTotal : LongWord = 0; + AmmoUsedCount : Longword = 0; + AmmoDamagingUsed : boolean = false; + SkippedTurns: LongWord = 0; + isTurnSkipped: boolean = false; + vpHurtSameClan: PVoicepack = nil; + vpHurtEnemy: PVoicepack = nil; procedure HedgehogDamaged(Gear: PGear); begin if CurrentHedgehog^.Team^.Clan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan then - vpHurtSameClan:= CurrentHedgehog^.Team^.voicepack + vpHurtSameClan:= CurrentHedgehog^.Team^.voicepack else - vpHurtEnemy:= PHedgehog(Gear^.Hedgehog)^.Team^.voicepack; + vpHurtEnemy:= PHedgehog(Gear^.Hedgehog)^.Team^.voicepack; if bBetweenTurns then exit; ////////////////////////// if Gear <> CurrentHedgehog^.Gear then - inc(CurrentHedgehog^.stats.StepDamageGiven, Gear^.Damage); + inc(CurrentHedgehog^.stats.StepDamageGiven, Gear^.Damage); if CurrentHedgehog^.Team^.Clan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan then inc(DamageClan, Gear^.Damage); if Gear^.Health <= Gear^.Damage then - begin - inc(CurrentHedgehog^.stats.StepKills); - inc(Kills); - inc(KillsTotal); - if CurrentHedgehog^.Team^.Clan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan then inc(KillsClan); - end; + begin + inc(CurrentHedgehog^.stats.StepKills); + inc(Kills); + inc(KillsTotal); + if CurrentHedgehog^.Team^.Clan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan then inc(KillsClan); + end; inc(PHedgehog(Gear^.Hedgehog)^.stats.StepDamageRecv, Gear^.Damage); inc(DamageGiven, Gear^.Damage); @@ -103,68 +103,68 @@ inc(FinishedTurnsTotal); if FinishedTurnsTotal <> 0 then - begin - inc(CurrentHedgehog^.stats.FinishedTurns); + begin + inc(CurrentHedgehog^.stats.FinishedTurns); - if (DamageGiven = DamageTotal) and (DamageTotal > 0) then - PlaySound(sndFirstBlood, CurrentTeam^.voicepack) + if (DamageGiven = DamageTotal) and (DamageTotal > 0) then + PlaySound(sndFirstBlood, CurrentTeam^.voicepack) - else if CurrentHedgehog^.stats.StepDamageRecv > 0 then - begin - PlaySound(sndStupid, PreviousTeam^.voicepack); - if DamageGiven = CurrentHedgehog^.stats.StepDamageRecv then AddCaption(Format(GetEventString(eidHurtSelf), CurrentHedgehog^.Name), cWhiteColor, capgrpMessage); - end - else if DamageClan <> 0 then - if DamageTotal > DamageClan then - if random(2) = 0 then - PlaySound(sndNutter, CurrentTeam^.voicepack) - else - PlaySound(sndWatchIt, vpHurtSameClan) - else - if random(2) = 0 then - PlaySound(sndSameTeam, vpHurtSameClan) - else - PlaySound(sndTraitor, vpHurtSameClan) - else if DamageGiven <> 0 then - if Kills > 0 then - PlaySound(sndEnemyDown, CurrentTeam^.voicepack) - else - PlaySound(sndRegret, vpHurtEnemy) + else if CurrentHedgehog^.stats.StepDamageRecv > 0 then + begin + PlaySound(sndStupid, PreviousTeam^.voicepack); + if DamageGiven = CurrentHedgehog^.stats.StepDamageRecv then AddCaption(Format(GetEventString(eidHurtSelf), CurrentHedgehog^.Name), cWhiteColor, capgrpMessage); + end + else if DamageClan <> 0 then + if DamageTotal > DamageClan then + if random(2) = 0 then + PlaySound(sndNutter, CurrentTeam^.voicepack) + else + PlaySound(sndWatchIt, vpHurtSameClan) + else + if random(2) = 0 then + PlaySound(sndSameTeam, vpHurtSameClan) + else + PlaySound(sndTraitor, vpHurtSameClan) + else if DamageGiven <> 0 then + if Kills > 0 then + PlaySound(sndEnemyDown, CurrentTeam^.voicepack) + else + PlaySound(sndRegret, vpHurtEnemy) - else if AmmoDamagingUsed then - PlaySound(sndMissed, PreviousTeam^.voicepack) - else if (AmmoUsedCount > 0) and not isTurnSkipped then - // nothing ? - else if isTurnSkipped then - begin - PlaySound(sndBoring, PreviousTeam^.voicepack); - AddCaption(Format(GetEventString(eidTurnSkipped), CurrentHedgehog^.Name), cWhiteColor, capgrpMessage); - end - else if not PlacingHogs then - PlaySound(sndCoward, PreviousTeam^.voicepack); - end; + else if AmmoDamagingUsed then + PlaySound(sndMissed, PreviousTeam^.voicepack) + else if (AmmoUsedCount > 0) and not isTurnSkipped then + // nothing ? + else if isTurnSkipped then + begin + PlaySound(sndBoring, PreviousTeam^.voicepack); + AddCaption(Format(GetEventString(eidTurnSkipped), CurrentHedgehog^.Name), cWhiteColor, capgrpMessage); + end + else if not PlacingHogs then + PlaySound(sndCoward, PreviousTeam^.voicepack); + end; for t:= 0 to Pred(TeamsCount) do // send even on zero turn - with TeamsArray[t]^ do - for i:= 0 to cMaxHHIndex do - with Hedgehogs[i].stats do - begin - inc(DamageRecv, StepDamageRecv); - inc(DamageGiven, StepDamageGiven); - if StepDamageRecv > MaxStepDamageRecv then MaxStepDamageRecv:= StepDamageRecv; - if StepDamageGiven > MaxStepDamageGiven then MaxStepDamageGiven:= StepDamageGiven; - if StepKills > MaxStepKills then MaxStepKills:= StepKills; - StepKills:= 0; - StepDamageRecv:= 0; - StepDamageGiven:= 0 - end; + with TeamsArray[t]^ do + for i:= 0 to cMaxHHIndex do + with Hedgehogs[i].stats do + begin + inc(DamageRecv, StepDamageRecv); + inc(DamageGiven, StepDamageGiven); + if StepDamageRecv > MaxStepDamageRecv then MaxStepDamageRecv:= StepDamageRecv; + if StepDamageGiven > MaxStepDamageGiven then MaxStepDamageGiven:= StepDamageGiven; + if StepKills > MaxStepKills then MaxStepKills:= StepKills; + StepKills:= 0; + StepDamageRecv:= 0; + StepDamageGiven:= 0 + end; for t:= 0 to Pred(ClansCount) do - with ClansArray[t]^ do - begin - SendStat(siClanHealth, inttostr(Color) + ' ' + inttostr(ClanHealth)); - end; + with ClansArray[t]^ do + begin + SendStat(siClanHealth, inttostr(Color) + ' ' + inttostr(ClanHealth)); + end; Kills:= 0; KillsClan:= 0; @@ -191,38 +191,38 @@ mskcnt:= 0; for t:= 0 to Pred(TeamsCount) do - with TeamsArray[t]^ do - begin - for i:= 0 to cMaxHHIndex do - begin - if Hedgehogs[i].stats.MaxStepDamageGiven > msd then - begin - msdhh:= @Hedgehogs[i]; - msd:= Hedgehogs[i].stats.MaxStepDamageGiven - end; - if Hedgehogs[i].stats.MaxStepKills >= msk then - if Hedgehogs[i].stats.MaxStepKills = msk then - inc(mskcnt) - else - begin - mskcnt:= 1; - mskhh:= @Hedgehogs[i]; - msk:= Hedgehogs[i].stats.MaxStepKills - end; - end - end; + with TeamsArray[t]^ do + begin + for i:= 0 to cMaxHHIndex do + begin + if Hedgehogs[i].stats.MaxStepDamageGiven > msd then + begin + msdhh:= @Hedgehogs[i]; + msd:= Hedgehogs[i].stats.MaxStepDamageGiven + end; + if Hedgehogs[i].stats.MaxStepKills >= msk then + if Hedgehogs[i].stats.MaxStepKills = msk then + inc(mskcnt) + else + begin + mskcnt:= 1; + mskhh:= @Hedgehogs[i]; + msk:= Hedgehogs[i].stats.MaxStepKills + end; + end + end; if msdhh <> nil then - SendStat(siMaxStepDamage, inttostr(msd) + ' ' + msdhh^.Name + ' (' + msdhh^.Team^.TeamName + ')'); + SendStat(siMaxStepDamage, inttostr(msd) + ' ' + msdhh^.Name + ' (' + msdhh^.Team^.TeamName + ')'); if mskcnt = 1 then - SendStat(siMaxStepKills, inttostr(msk) + ' ' + mskhh^.Name + ' (' + mskhh^.Team^.TeamName + ')'); + SendStat(siMaxStepKills, inttostr(msk) + ' ' + mskhh^.Name + ' (' + mskhh^.Team^.TeamName + ')'); if KilledHHs > 0 then SendStat(siKilledHHs, inttostr(KilledHHs)); end; procedure init_uStats; begin - TotalRounds:= -1; - FinishedTurnsTotal:= -1; + TotalRounds:= -1; + FinishedTurnsTotal:= -1; end; procedure free_uStats; diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/uStore.pas --- a/hedgewars/uStore.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/uStore.pas Sat Mar 06 10:59:20 2010 +0000 @@ -22,9 +22,9 @@ interface uses sysutils, uConsts, uTeams, SDLh, uFloat, {$IFDEF GLES11} - gles11; + gles11; {$ELSE} - GL, GLext; + GL, GLext; {$ENDIF} @@ -175,171 +175,171 @@ procedure StoreLoad; var s: shortstring; - procedure WriteNames(Font: THWFont); - var t: LongInt; - i: LongInt; - r, rr: TSDL_Rect; - drY: LongInt; - texsurf, flagsurf, iconsurf: PSDL_Surface; - begin - r.x:= 0; - r.y:= 0; - drY:= - 4; - for t:= 0 to Pred(TeamsCount) do - with TeamsArray[t]^ do - begin - NameTagTex:= RenderStringTex(TeamName, Clan^.Color, Font); + procedure WriteNames(Font: THWFont); + var t: LongInt; + i: LongInt; + r, rr: TSDL_Rect; + drY: LongInt; + texsurf, flagsurf, iconsurf: PSDL_Surface; + begin + r.x:= 0; + r.y:= 0; + drY:= - 4; + for t:= 0 to Pred(TeamsCount) do + with TeamsArray[t]^ do + begin + NameTagTex:= RenderStringTex(TeamName, Clan^.Color, Font); - r.w:= cTeamHealthWidth + 5; - r.h:= NameTagTex^.h; + r.w:= cTeamHealthWidth + 5; + r.h:= NameTagTex^.h; - texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, r.w, r.h, 32, RMask, GMask, BMask, AMask); - TryDo(texsurf <> nil, errmsgCreateSurface, true); - TryDo(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); + texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, r.w, r.h, 32, RMask, GMask, BMask, AMask); + TryDo(texsurf <> nil, errmsgCreateSurface, true); + TryDo(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); - DrawRoundRect(@r, cWhiteColor, cNearBlackColorChannels.value, texsurf, true); - rr:= r; - inc(rr.x, 2); dec(rr.w, 4); inc(rr.y, 2); dec(rr.h, 4); - DrawRoundRect(@rr, Clan^.Color, Clan^.Color, texsurf, false); - HealthTex:= Surface2Tex(texsurf, false); - SDL_FreeSurface(texsurf); + DrawRoundRect(@r, cWhiteColor, cNearBlackColorChannels.value, texsurf, true); + rr:= r; + inc(rr.x, 2); dec(rr.w, 4); inc(rr.y, 2); dec(rr.h, 4); + DrawRoundRect(@rr, Clan^.Color, Clan^.Color, texsurf, false); + HealthTex:= Surface2Tex(texsurf, false); + SDL_FreeSurface(texsurf); - r.x:= 0; - r.y:= 0; - r.w:= 32; - r.h:= 32; - texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, r.w, r.h, 32, RMask, GMask, BMask, AMask); - TryDo(texsurf <> nil, errmsgCreateSurface, true); - TryDo(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); + r.x:= 0; + r.y:= 0; + r.w:= 32; + r.h:= 32; + texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, r.w, r.h, 32, RMask, GMask, BMask, AMask); + TryDo(texsurf <> nil, errmsgCreateSurface, true); + TryDo(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); - r.w:= 26; - r.h:= 19; + r.w:= 26; + r.h:= 19; - DrawRoundRect(@r, cWhiteColor, cNearBlackColor, texsurf, true); + DrawRoundRect(@r, cWhiteColor, cNearBlackColor, texsurf, true); - // overwrite flag for cpu teams and keep players from using it - if (Hedgehogs[0].Gear <> nil) and (Hedgehogs[0].BotLevel > 0) then - Flag:= 'cpu' - else if Flag = 'cpu' then - Flag:= 'hedgewars'; - - flagsurf:= LoadImage(Pathz[ptFlags] + '/' + Flag, ifNone); - if flagsurf = nil then - flagsurf:= LoadImage(Pathz[ptFlags] + '/hedgewars', ifNone); - TryDo(flagsurf <> nil, 'Failed to load flag "' + Flag + '" as well as the default flag', true); - copyToXY(flagsurf, texsurf, 2, 2); - SDL_FreeSurface(flagsurf); - - // restore black border pixels inside the flag - PLongwordArray(texsurf^.pixels)^[32 * 2 + 2]:= cNearBlackColor; - PLongwordArray(texsurf^.pixels)^[32 * 2 + 23]:= cNearBlackColor; - PLongwordArray(texsurf^.pixels)^[32 * 16 + 2]:= cNearBlackColor; - PLongwordArray(texsurf^.pixels)^[32 * 16 + 23]:= cNearBlackColor; + // overwrite flag for cpu teams and keep players from using it + if (Hedgehogs[0].Gear <> nil) and (Hedgehogs[0].BotLevel > 0) then + Flag:= 'cpu' + else if Flag = 'cpu' then + Flag:= 'hedgewars'; + + flagsurf:= LoadImage(Pathz[ptFlags] + '/' + Flag, ifNone); + if flagsurf = nil then + flagsurf:= LoadImage(Pathz[ptFlags] + '/hedgewars', ifNone); + TryDo(flagsurf <> nil, 'Failed to load flag "' + Flag + '" as well as the default flag', true); + copyToXY(flagsurf, texsurf, 2, 2); + SDL_FreeSurface(flagsurf); + + // restore black border pixels inside the flag + PLongwordArray(texsurf^.pixels)^[32 * 2 + 2]:= cNearBlackColor; + PLongwordArray(texsurf^.pixels)^[32 * 2 + 23]:= cNearBlackColor; + PLongwordArray(texsurf^.pixels)^[32 * 16 + 2]:= cNearBlackColor; + PLongwordArray(texsurf^.pixels)^[32 * 16 + 23]:= cNearBlackColor; - FlagTex:= Surface2Tex(texsurf, false); - - dec(drY, r.h + 2); - DrawHealthY:= drY; - for i:= 0 to 7 do - with Hedgehogs[i] do - if Gear <> nil then - begin - NameTagTex:= RenderStringTex(Name, Clan^.Color, CheckCJKFont(Name,fnt16)); - if Hat <> 'NoHat' then - begin + FlagTex:= Surface2Tex(texsurf, false); + + dec(drY, r.h + 2); + DrawHealthY:= drY; + for i:= 0 to 7 do + with Hedgehogs[i] do + if Gear <> nil then + begin + NameTagTex:= RenderStringTex(Name, Clan^.Color, CheckCJKFont(Name,fnt16)); + if Hat <> 'NoHat' then + begin texsurf:= nil; if (Length(Hat) > 39) and (Copy(Hat,1,8) = 'Reserved') and (Copy(Hat,9,32) = PlayerHash) then - texsurf:= LoadImage(Pathz[ptHats] + '/Reserved/' + Copy(Hat,9,Length(s)-8), ifNone) + texsurf:= LoadImage(Pathz[ptHats] + '/Reserved/' + Copy(Hat,9,Length(s)-8), ifNone) else - texsurf:= LoadImage(Pathz[ptHats] + '/' + Hat, ifNone); - if texsurf <> nil then - begin - HatTex:= Surface2Tex(texsurf, true); - SDL_FreeSurface(texsurf) - end - end - end; - end; - MissionIcons:= LoadImage(Pathz[ptGraphics] + '/missions', ifCritical); - iconsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, 28, 28, 32, RMask, GMask, BMask, AMask); - if iconsurf <> nil then - begin - r.x:= 0; - r.y:= 0; - r.w:= 28; - r.h:= 28; - DrawRoundRect(@r, cWhiteColor, cNearBlackColor, iconsurf, true); - ropeIconTex:= Surface2Tex(iconsurf, false); - SDL_FreeSurface(iconsurf) - end; - end; + texsurf:= LoadImage(Pathz[ptHats] + '/' + Hat, ifNone); + if texsurf <> nil then + begin + HatTex:= Surface2Tex(texsurf, true); + SDL_FreeSurface(texsurf) + end + end + end; + end; + MissionIcons:= LoadImage(Pathz[ptGraphics] + '/missions', ifCritical); + iconsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, 28, 28, 32, RMask, GMask, BMask, AMask); + if iconsurf <> nil then + begin + r.x:= 0; + r.y:= 0; + r.w:= 28; + r.h:= 28; + DrawRoundRect(@r, cWhiteColor, cNearBlackColor, iconsurf, true); + ropeIconTex:= Surface2Tex(iconsurf, false); + SDL_FreeSurface(iconsurf) + end; + end; - procedure MakeCrossHairs; - var t: LongInt; - tmpsurf, texsurf: PSDL_Surface; - Color, i: Longword; - begin - s:= Pathz[ptGraphics] + '/' + cCHFileName; - tmpsurf:= LoadImage(s, ifAlpha or ifCritical); + procedure MakeCrossHairs; + var t: LongInt; + tmpsurf, texsurf: PSDL_Surface; + Color, i: Longword; + begin + s:= Pathz[ptGraphics] + '/' + cCHFileName; + tmpsurf:= LoadImage(s, ifAlpha or ifCritical); - for t:= 0 to Pred(TeamsCount) do - with TeamsArray[t]^ do - begin - texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, tmpsurf^.w, tmpsurf^.h, 32, RMask, GMask, BMask, AMask); - TryDo(texsurf <> nil, errmsgCreateSurface, true); + for t:= 0 to Pred(TeamsCount) do + with TeamsArray[t]^ do + begin + texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, tmpsurf^.w, tmpsurf^.h, 32, RMask, GMask, BMask, AMask); + TryDo(texsurf <> nil, errmsgCreateSurface, true); - Color:= Clan^.Color; - Color:= SDL_MapRGB(texsurf^.format, Color shr 16, Color shr 8, Color and $FF); - SDL_FillRect(texsurf, nil, Color); + Color:= Clan^.Color; + Color:= SDL_MapRGB(texsurf^.format, Color shr 16, Color shr 8, Color and $FF); + SDL_FillRect(texsurf, nil, Color); - SDL_UpperBlit(tmpsurf, nil, texsurf, nil); + SDL_UpperBlit(tmpsurf, nil, texsurf, nil); - TryDo(tmpsurf^.format^.BytesPerPixel = 4, 'Ooops', true); + TryDo(tmpsurf^.format^.BytesPerPixel = 4, 'Ooops', true); - if SDL_MustLock(texsurf) then - SDLTry(SDL_LockSurface(texsurf) >= 0, true); + if SDL_MustLock(texsurf) then + SDLTry(SDL_LockSurface(texsurf) >= 0, true); - // make black pixel be alpha-transparent - for i:= 0 to texsurf^.w * texsurf^.h - 1 do - if PLongwordArray(texsurf^.pixels)^[i] = AMask then PLongwordArray(texsurf^.pixels)^[i]:= 0; + // make black pixel be alpha-transparent + for i:= 0 to texsurf^.w * texsurf^.h - 1 do + if PLongwordArray(texsurf^.pixels)^[i] = AMask then PLongwordArray(texsurf^.pixels)^[i]:= 0; - if SDL_MustLock(texsurf) then - SDL_UnlockSurface(texsurf); + if SDL_MustLock(texsurf) then + SDL_UnlockSurface(texsurf); - CrosshairTex:= Surface2Tex(texsurf, false); - SDL_FreeSurface(texsurf) - end; + CrosshairTex:= Surface2Tex(texsurf, false); + SDL_FreeSurface(texsurf) + end; - SDL_FreeSurface(tmpsurf) - end; + SDL_FreeSurface(tmpsurf) + end; - procedure InitHealth; - var i, t: LongInt; - begin - for t:= 0 to Pred(TeamsCount) do - if TeamsArray[t] <> nil then - with TeamsArray[t]^ do - begin - for i:= 0 to cMaxHHIndex do - if Hedgehogs[i].Gear <> nil then - RenderHealth(Hedgehogs[i]); - end - end; + procedure InitHealth; + var i, t: LongInt; + begin + for t:= 0 to Pred(TeamsCount) do + if TeamsArray[t] <> nil then + with TeamsArray[t]^ do + begin + for i:= 0 to cMaxHHIndex do + if Hedgehogs[i].Gear <> nil then + RenderHealth(Hedgehogs[i]); + end + end; - procedure LoadGraves; - var t: LongInt; - texsurf: PSDL_Surface; - begin - for t:= 0 to Pred(TeamsCount) do - if TeamsArray[t] <> nil then - with TeamsArray[t]^ do - begin - if GraveName = '' then GraveName:= 'Simple'; - texsurf:= LoadImage(Pathz[ptGraves] + '/' + GraveName, ifCritical or ifTransparent); - GraveTex:= Surface2Tex(texsurf, false); - SDL_FreeSurface(texsurf) - end - end; + procedure LoadGraves; + var t: LongInt; + texsurf: PSDL_Surface; + begin + for t:= 0 to Pred(TeamsCount) do + if TeamsArray[t] <> nil then + with TeamsArray[t]^ do + begin + if GraveName = '' then GraveName:= 'Simple'; + texsurf:= LoadImage(Pathz[ptGraves] + '/' + GraveName, ifCritical or ifTransparent); + GraveTex:= Surface2Tex(texsurf, false); + SDL_FreeSurface(texsurf) + end + end; var ii: TSprite; fi: THWFont; @@ -349,15 +349,15 @@ begin for fi:= Low(THWFont) to High(THWFont) do - with Fontz[fi] do - begin - s:= Pathz[ptFonts] + '/' + Name; - WriteToConsole(msgLoading + s + '... '); - Handle:= TTF_OpenFont(Str2PChar(s), Height); - SDLTry(Handle <> nil, true); - TTF_SetFontStyle(Handle, style); - WriteLnToConsole(msgOK) - end; + with Fontz[fi] do + begin + s:= Pathz[ptFonts] + '/' + Name; + WriteToConsole(msgLoading + s + '... '); + Handle:= TTF_OpenFont(Str2PChar(s), Height); + SDLTry(Handle <> nil, true); + TTF_SetFontStyle(Handle, style); + WriteLnToConsole(msgOK) + end; WriteNames(fnt16); MakeCrossHairs; @@ -365,42 +365,42 @@ AddProgress; for ii:= Low(TSprite) to High(TSprite) do - with SpritesData[ii] do + with SpritesData[ii] do // FIXME - add a sprite attribute if (not cReducedQuality) or (not (ii in [sprSky, sprSkyL, sprSkyR, sprHorizont, sprHorizontL, sprHorizontR, sprFlake])) then // FIXME: hack - begin - if AltPath = ptNone then - if ii in [sprHorizontL, sprHorizontR, sprSkyL, sprSkyR] then // FIXME: hack - tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent or ifLowRes) - else - tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent or ifCritical or ifLowRes) - else begin - tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent); - if tmpsurf = nil then - tmpsurf:= LoadImage(Pathz[AltPath] + '/' + FileName, ifAlpha or ifCritical or ifTransparent); - end; + begin + if AltPath = ptNone then + if ii in [sprHorizontL, sprHorizontR, sprSkyL, sprSkyR] then // FIXME: hack + tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent or ifLowRes) + else + tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent or ifCritical or ifLowRes) + else begin + tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent); + if tmpsurf = nil then + tmpsurf:= LoadImage(Pathz[AltPath] + '/' + FileName, ifAlpha or ifCritical or ifTransparent); + end; - if tmpsurf <> nil then - begin - if imageWidth = 0 then imageWidth:= tmpsurf^.w; - if imageHeight = 0 then imageHeight:= tmpsurf^.h; - if Width = 0 then Width:= tmpsurf^.w; - if Height = 0 then Height:= tmpsurf^.h; - if (ii in [sprSky, sprSkyL, sprSkyR, sprHorizont, sprHorizontL, sprHorizontR]) then - Texture:= Surface2Tex(tmpsurf, true) - else - begin - Texture:= Surface2Tex(tmpsurf, false); - if (ii = sprWater) and not cReducedQuality then // HACK: We should include some sprite attribute to define the texture wrap directions - begin - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - end; - end; - if saveSurf then Surface:= tmpsurf else SDL_FreeSurface(tmpsurf) - end - else - Surface:= nil - end; + if tmpsurf <> nil then + begin + if imageWidth = 0 then imageWidth:= tmpsurf^.w; + if imageHeight = 0 then imageHeight:= tmpsurf^.h; + if Width = 0 then Width:= tmpsurf^.w; + if Height = 0 then Height:= tmpsurf^.h; + if (ii in [sprSky, sprSkyL, sprSkyR, sprHorizont, sprHorizontL, sprHorizontR]) then + Texture:= Surface2Tex(tmpsurf, true) + else + begin + Texture:= Surface2Tex(tmpsurf, false); + if (ii = sprWater) and not cReducedQuality then // HACK: We should include some sprite attribute to define the texture wrap directions + begin + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + end; + end; + if saveSurf then Surface:= tmpsurf else SDL_FreeSurface(tmpsurf) + end + else + Surface:= nil + end; AddProgress; @@ -418,22 +418,22 @@ // name of weapons in ammo menu for ai:= Low(TAmmoType) to High(TAmmoType) do - with Ammoz[ai] do - begin - tmpsurf:= TTF_RenderUTF8_Blended(Fontz[CheckCJKFont(trAmmo[NameId],fnt16)].Handle, Str2PChar(trAmmo[NameId]), cWhiteColorChannels); - tmpsurf:= doSurfaceConversion(tmpsurf); - NameTex:= Surface2Tex(tmpsurf, false); - SDL_FreeSurface(tmpsurf) - end; + with Ammoz[ai] do + begin + tmpsurf:= TTF_RenderUTF8_Blended(Fontz[CheckCJKFont(trAmmo[NameId],fnt16)].Handle, Str2PChar(trAmmo[NameId]), cWhiteColorChannels); + tmpsurf:= doSurfaceConversion(tmpsurf); + NameTex:= Surface2Tex(tmpsurf, false); + SDL_FreeSurface(tmpsurf) + end; // number of weapons in ammo menu for i:= Low(CountTexz) to High(CountTexz) do - begin - tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(IntToStr(i) + 'x'), cWhiteColorChannels); - tmpsurf:= doSurfaceConversion(tmpsurf); - CountTexz[i]:= Surface2Tex(tmpsurf, false); - SDL_FreeSurface(tmpsurf) - end; + begin + tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(IntToStr(i) + 'x'), cWhiteColorChannels); + tmpsurf:= doSurfaceConversion(tmpsurf); + CountTexz[i]:= Surface2Tex(tmpsurf, false); + SDL_FreeSurface(tmpsurf) + end; {$IFDEF DUMP} //not working anymore, where are LandSurface and StoreSurface defined? @@ -516,7 +516,7 @@ procedure DrawTextureF(Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt); begin - DrawRotatedTextureF(Texture, Scale, 0, 0, X, Y, Frame, Dir, w, h, 0) + DrawRotatedTextureF(Texture, Scale, 0, 0, X, Y, Frame, Dir, w, h, 0) end; procedure DrawRotatedTextureF(Texture: PTexture; Scale, OffsetX, OffsetY: GLfloat; X, Y, Frame, Dir, w, h: LongInt; Angle: real); @@ -538,9 +538,9 @@ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); if Dir < 0 then - hw:= w div -2 + hw:= w div -2 else - hw:= w div 2; + hw:= w div 2; nx:= round(Texture^.w / w); // number of horizontal frames ny:= round(Texture^.h / h); // number of vertical frames @@ -587,9 +587,9 @@ procedure DrawRotated(Sprite: TSprite; X, Y, Dir: LongInt; Angle: real); begin DrawRotatedTex(SpritesData[Sprite].Texture, - SpritesData[Sprite].Width, - SpritesData[Sprite].Height, - X, Y, Dir, Angle) + SpritesData[Sprite].Width, + SpritesData[Sprite].Height, + X, Y, Dir, Angle) end; procedure DrawRotatedF(Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real); @@ -703,10 +703,10 @@ procedure DrawHedgehog(X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real); const VertexBuffer: array [0..3] of TVertex2f = ( - (x: -16; y: -16), - (x: 16; y: -16), - (x: 16; y: 16), - (x: -16; y: 16)); + (x: -16; y: -16), + (x: 16; y: -16), + (x: 16; y: 16), + (x: -16; y: 16)); var l, r, t, b: real; TextureBuffer: array [0..3] of TVertex2f; begin @@ -1032,81 +1032,81 @@ procedure RenderHealth(var Hedgehog: THedgehog); var s: shortstring; begin - str(Hedgehog.Gear^.Health, s); - if Hedgehog.HealthTagTex <> nil then - FreeTexture(Hedgehog.HealthTagTex); - Hedgehog.HealthTagTex:= RenderStringTex(s, Hedgehog.Team^.Clan^.Color, fnt16) + str(Hedgehog.Gear^.Health, s); + if Hedgehog.HealthTagTex <> nil then + FreeTexture(Hedgehog.HealthTagTex); + Hedgehog.HealthTagTex:= RenderStringTex(s, Hedgehog.Team^.Clan^.Color, fnt16) end; function LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface; var tmpsurf: PSDL_Surface; s: shortstring; begin - WriteToConsole(msgLoading + filename + ' [flags: ' + inttostr(imageFlags) + ']... '); + WriteToConsole(msgLoading + filename + ' [flags: ' + inttostr(imageFlags) + ']... '); - s:= filename + '.png'; - tmpsurf:= IMG_Load(Str2PChar(s)); + s:= filename + '.png'; + tmpsurf:= IMG_Load(Str2PChar(s)); - if (imageFlags and ifLowRes) <> 0 then - begin - s:= filename + '-lowres.png'; - if (tmpsurf <> nil) then - begin - if ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then - begin - SDL_FreeSurface(tmpsurf); - {$IFDEF DEBUGFILE} - AddFileLog('...image too big, trying to load lowres version: ' + s + '...'); - {$ENDIF} - tmpsurf:= IMG_Load(Str2PChar(s)) - end; - end - else - begin - {$IFDEF DEBUGFILE} - AddFileLog('...image not found, trying to load lowres version: ' + s + '...'); - {$ENDIF} - tmpsurf:= IMG_Load(Str2PChar(s)) - end; - end; + if (imageFlags and ifLowRes) <> 0 then + begin + s:= filename + '-lowres.png'; + if (tmpsurf <> nil) then + begin + if ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then + begin + SDL_FreeSurface(tmpsurf); + {$IFDEF DEBUGFILE} + AddFileLog('...image too big, trying to load lowres version: ' + s + '...'); + {$ENDIF} + tmpsurf:= IMG_Load(Str2PChar(s)) + end; + end + else + begin + {$IFDEF DEBUGFILE} + AddFileLog('...image not found, trying to load lowres version: ' + s + '...'); + {$ENDIF} + tmpsurf:= IMG_Load(Str2PChar(s)) + end; + end; - if tmpsurf = nil then - begin - OutError(msgFailed, (imageFlags and ifCritical) <> 0); - exit(nil) - end; + if tmpsurf = nil then + begin + OutError(msgFailed, (imageFlags and ifCritical) <> 0); + exit(nil) + end; - if ((imageFlags and ifIgnoreCaps) = 0) and ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then - begin - SDL_FreeSurface(tmpsurf); - OutError(msgFailedSize, (imageFlags and ifCritical) <> 0); - // dummy surface to replace non-critical textures that failed to load due to their size - exit(SDL_CreateRGBSurface(SDL_SWSURFACE, 32, 32, 32, RMask, GMask, BMask, AMask)); - end; + if ((imageFlags and ifIgnoreCaps) = 0) and ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then + begin + SDL_FreeSurface(tmpsurf); + OutError(msgFailedSize, (imageFlags and ifCritical) <> 0); + // dummy surface to replace non-critical textures that failed to load due to their size + exit(SDL_CreateRGBSurface(SDL_SWSURFACE, 32, 32, 32, RMask, GMask, BMask, AMask)); + end; - tmpsurf:= doSurfaceConversion(tmpsurf); + tmpsurf:= doSurfaceConversion(tmpsurf); - if (imageFlags and ifTransparent) <> 0 then - TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); + if (imageFlags and ifTransparent) <> 0 then + TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); - WriteLnToConsole('(' + inttostr(tmpsurf^.w) + ',' + inttostr(tmpsurf^.h) + ') '); - WriteLnToConsole(msgOK); + WriteLnToConsole('(' + inttostr(tmpsurf^.w) + ',' + inttostr(tmpsurf^.h) + ') '); + WriteLnToConsole(msgOK); - LoadImage:= tmpsurf //Result + LoadImage:= tmpsurf //Result end; function glLoadExtension(extension : shortstring) : boolean; begin {$IFDEF IPHONEOS} - glLoadExtension:= false; + glLoadExtension:= false; {$ELSE} - glLoadExtension:= glext_LoadExtension(extension); + glLoadExtension:= glext_LoadExtension(extension); {$ENDIF} {$IFDEF DEBUGFILE} - if not glLoadExtension then - AddFileLog('OpenGL - "' + extension + '" failed to load') - else - AddFileLog('OpenGL - "' + extension + '" loaded'); + if not glLoadExtension then + AddFileLog('OpenGL - "' + extension + '" failed to load') + else + AddFileLog('OpenGL - "' + extension + '" loaded'); {$ENDIF} end; @@ -1115,84 +1115,84 @@ begin {$IFDEF IPHONEOS} //these are good performance savers, perhaps we could enable them by default - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0); - SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 1); - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); - SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); - SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6); - SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); - SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0); - SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); - //SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0); + SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 1); + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); + SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0); + SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); + //SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32); {$ELSE} - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); {$ENDIF} {$IFNDEF SDL13} // this attribute is default in 1.3 and must be enabled in MacOSX {$IFNDEF DARWIN} - if cVSyncInUse then + if cVSyncInUse then {$ENDIF} - SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1); + SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1); {$ENDIF} - glGetIntegerv(GL_MAX_TEXTURE_SIZE, @MaxTextureSize); + glGetIntegerv(GL_MAX_TEXTURE_SIZE, @MaxTextureSize); - vendor:= LowerCase(shortstring(pchar(glGetString(GL_VENDOR)))); + vendor:= LowerCase(shortstring(pchar(glGetString(GL_VENDOR)))); {$IFDEF DEBUGFILE} - AddFileLog('OpenGL-- Renderer: ' + shortstring(pchar(glGetString(GL_RENDERER)))); - AddFileLog(' |----- Vendor: ' + vendor); - AddFileLog(' |----- Version: ' + shortstring(pchar(glGetString(GL_VERSION)))); - AddFileLog(' \----- GL_MAX_TEXTURE_SIZE: ' + inttostr(MaxTextureSize)); + AddFileLog('OpenGL-- Renderer: ' + shortstring(pchar(glGetString(GL_RENDERER)))); + AddFileLog(' |----- Vendor: ' + vendor); + AddFileLog(' |----- Version: ' + shortstring(pchar(glGetString(GL_VERSION)))); + AddFileLog(' \----- GL_MAX_TEXTURE_SIZE: ' + inttostr(MaxTextureSize)); {$ENDIF} - if MaxTextureSize <= 0 then - begin - MaxTextureSize:= 1024; + if MaxTextureSize <= 0 then + begin + MaxTextureSize:= 1024; {$IFDEF DEBUGFILE} - AddFileLog('OpenGL Warning - driver didn''t provide any valid max texture size; assuming 1024'); + AddFileLog('OpenGL Warning - driver didn''t provide any valid max texture size; assuming 1024'); {$ENDIF} - end; + end; {$IFNDEF IPHONEOS} - if StrPos(Str2PChar(vendor), Str2PChar('nvidia')) <> nil then - cGPUVendor:= gvNVIDIA - else if StrPos(Str2PChar(vendor), Str2PChar('intel')) <> nil then - cGPUVendor:= gvATI - else if StrPos(Str2PChar(vendor), Str2PChar('ati')) <> nil then - cGPUVendor:= gvIntel; + if StrPos(Str2PChar(vendor), Str2PChar('nvidia')) <> nil then + cGPUVendor:= gvNVIDIA + else if StrPos(Str2PChar(vendor), Str2PChar('intel')) <> nil then + cGPUVendor:= gvATI + else if StrPos(Str2PChar(vendor), Str2PChar('ati')) <> nil then + cGPUVendor:= gvIntel; //SupportNPOTT:= glLoadExtension('GL_ARB_texture_non_power_of_two'); {$ELSE} - cGPUVendor:= gvApple; + cGPUVendor:= gvApple; {$ENDIF} {$IFDEF DEBUGFILE} - if cGPUVendor = gvUnknown then - AddFileLog('OpenGL Warning - unknown hardware vendor; please report'); + if cGPUVendor = gvUnknown then + AddFileLog('OpenGL Warning - unknown hardware vendor; please report'); {$ELSE} - // just avoid 'never used' compiler warning for now - if cGPUVendor = gvUnknown then cGPUVendor:= gvUnknown; + // just avoid 'never used' compiler warning for now + if cGPUVendor = gvUnknown then cGPUVendor:= gvUnknown; {$ENDIF} - // set view port to whole window + // set view port to whole window {$IFDEF IPHONEOS} - glViewport(0, 0, cScreenHeight, cScreenWidth); + glViewport(0, 0, cScreenHeight, cScreenWidth); {$ELSE} - glViewport(0, 0, cScreenWidth, cScreenHeight); + glViewport(0, 0, cScreenWidth, cScreenHeight); {$ENDIF} - glMatrixMode(GL_MODELVIEW); - // prepare default translation/scaling - glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + // prepare default translation/scaling + glLoadIdentity(); {$IFDEF IPHONEOS} - glRotatef(-90, 0, 0, 1); + glRotatef(-90, 0, 0, 1); {$ENDIF} - glScalef(2.0 / cScreenWidth, -2.0 / cScreenHeight, 1.0); - glTranslatef(0, -cScreenHeight / 2, 0); + glScalef(2.0 / cScreenWidth, -2.0 / cScreenHeight, 1.0); + glTranslatef(0, -cScreenHeight / 2, 0); - // enable alpha blending - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + // enable alpha blending + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); end; procedure SetScale(f: GLfloat); @@ -1203,22 +1203,22 @@ scale: GLfloat = 2.0; {$ENDIF} begin - // leave immediately if scale factor did not change - if f = cScaleFactor then exit; + // leave immediately if scale factor did not change + if f = cScaleFactor then exit; - if f = scale then glPopMatrix // "return" to default scaling - else // other scaling - begin - glPushMatrix; // save default scaling - glLoadIdentity; + if f = scale then glPopMatrix // "return" to default scaling + else // other scaling + begin + glPushMatrix; // save default scaling + glLoadIdentity; {$IFDEF IPHONEOS} - glRotatef(-90, 0, 0, 1); + glRotatef(-90, 0, 0, 1); {$ENDIF} - glScalef(f / cScreenWidth, -f / cScreenHeight, 1.0); - glTranslatef(0, -cScreenHeight / 2, 0); - end; + glScalef(f / cScreenWidth, -f / cScreenHeight, 1.0); + glTranslatef(0, -cScreenHeight / 2, 0); + end; - cScaleFactor:= f; + cScaleFactor:= f; end; //////////////////////////////////////////////////////////////////////////////// @@ -1226,55 +1226,55 @@ var r: TSDL_Rect; texsurf: PSDL_Surface; begin - if Step = 0 then - begin + if Step = 0 then + begin {$IFDEF SDL_IMAGE_NEWER} - WriteToConsole('Init SDL_image... '); - SDLTry(IMG_Init(IMG_INIT_PNG) <> 0, true); - WriteLnToConsole(msgOK); + WriteToConsole('Init SDL_image... '); + SDLTry(IMG_Init(IMG_INIT_PNG) <> 0, true); + WriteLnToConsole(msgOK); {$ENDIF} - - WriteToConsole(msgLoading + 'progress sprite: '); - texsurf:= LoadImage(Pathz[ptGraphics] + '/Progress', ifCritical or ifTransparent); + + WriteToConsole(msgLoading + 'progress sprite: '); + texsurf:= LoadImage(Pathz[ptGraphics] + '/Progress', ifCritical or ifTransparent); - ProgrTex:= Surface2Tex(texsurf, false); - - squaresize:= texsurf^.w shr 1; - numsquares:= texsurf^.h div squaresize; - SDL_FreeSurface(texsurf); - end; + ProgrTex:= Surface2Tex(texsurf, false); + + squaresize:= texsurf^.w shr 1; + numsquares:= texsurf^.h div squaresize; + SDL_FreeSurface(texsurf); + end; - TryDo(ProgrTex <> nil, 'Error - Progress Texure is nil!', true); + TryDo(ProgrTex <> nil, 'Error - Progress Texure is nil!', true); - glClear(GL_COLOR_BUFFER_BIT); - glEnable(GL_TEXTURE_2D); - if Step < numsquares then r.x:= 0 - else r.x:= squaresize; - - r.y:= (Step mod numsquares) * squaresize; - r.w:= squaresize; - r.h:= squaresize; - - DrawFromRect( -squaresize div 2, (cScreenHeight - squaresize) shr 1, @r, ProgrTex); + glClear(GL_COLOR_BUFFER_BIT); + glEnable(GL_TEXTURE_2D); + if Step < numsquares then r.x:= 0 + else r.x:= squaresize; + + r.y:= (Step mod numsquares) * squaresize; + r.w:= squaresize; + r.h:= squaresize; + + DrawFromRect( -squaresize div 2, (cScreenHeight - squaresize) shr 1, @r, ProgrTex); - glDisable(GL_TEXTURE_2D); - SDL_GL_SwapBuffers(); + glDisable(GL_TEXTURE_2D); + SDL_GL_SwapBuffers(); {$IFDEF SDL13} - SDL_RenderPresent(); + SDL_RenderPresent(); {$ENDIF} - inc(Step); + inc(Step); end; procedure FinishProgress; begin - WriteLnToConsole('Freeing progress surface... '); - FreeTexture(ProgrTex); + WriteLnToConsole('Freeing progress surface... '); + FreeTexture(ProgrTex); {$IFDEF IPHONEOS} - // show overlay buttons - IPH_showControls; + // show overlay buttons + IPH_showControls; {$ENDIF} end; @@ -1347,11 +1347,11 @@ function RenderHelpWindow(caption, subcaption, description, extra: ansistring; extracolor: LongInt; iconsurf: PSDL_Surface; iconrect: PSDL_Rect): PTexture; var tmpsurf: PSDL_SURFACE; - w, h, i, j: LongInt; - font: THWFont; - r, r2: TSDL_Rect; - wa, ha: LongInt; - tmpline, tmpline2, tmpdesc: ansistring; + w, h, i, j: LongInt; + font: THWFont; + r, r2: TSDL_Rect; + wa, ha: LongInt; + tmpline, tmpline2, tmpdesc: ansistring; begin // make sure there is a caption as well as a sub caption - description is optional if caption = '' then caption:= '???'; @@ -1384,25 +1384,25 @@ // get description's dimensions tmpdesc:= description; while tmpdesc <> '' do - begin - tmpline:= tmpdesc; - SplitByChar(tmpline, tmpdesc, '|'); - if tmpline <> '' then - begin - TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(tmpline), i, j); - if w < (i + wa) then w:= i + wa; - inc(h, j + ha) - end - end; + begin + tmpline:= tmpdesc; + SplitByChar(tmpline, tmpdesc, '|'); + if tmpline <> '' then + begin + TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(tmpline), i, j); + if w < (i + wa) then w:= i + wa; + inc(h, j + ha) + end + end; if extra <> '' then - begin - // get extra label's dimensions - TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(extra), i, j); - if w < (i + wa) then w:= i + wa; - inc(h, j + ha); - end; - + begin + // get extra label's dimensions + TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(extra), i, j); + if w < (i + wa) then w:= i + wa; + inc(h, j + ha); + end; + // add borders space inc(w, wa); inc(h, ha + 8); @@ -1425,23 +1425,23 @@ // render all description lines tmpdesc:= description; while tmpdesc <> '' do - begin - tmpline:= tmpdesc; - SplitByChar(tmpline, tmpdesc, '|'); - r2:= r; - if tmpline <> '' then - begin - r:= WriteInRect(tmpsurf, FontBorder + 2, r.y + r.h, $ff707070, font, tmpline); - - // render highlighted caption (if there's a ':') - SplitByChar(tmpline, tmpline2, ':'); - if tmpline2 <> '' then - WriteInRect(tmpsurf, FontBorder + 2, r2.y + r2.h, $ffc7c7c7, font, tmpline + ':'); - end - end; + begin + tmpline:= tmpdesc; + SplitByChar(tmpline, tmpdesc, '|'); + r2:= r; + if tmpline <> '' then + begin + r:= WriteInRect(tmpsurf, FontBorder + 2, r.y + r.h, $ff707070, font, tmpline); + + // render highlighted caption (if there's a ':') + SplitByChar(tmpline, tmpline2, ':'); + if tmpline2 <> '' then + WriteInRect(tmpsurf, FontBorder + 2, r2.y + r2.h, $ffc7c7c7, font, tmpline + ':'); + end + end; if extra <> '' then - r:= WriteInRect(tmpsurf, FontBorder + 2, r.y + r.h, extracolor, font, extra); + r:= WriteInRect(tmpsurf, FontBorder + 2, r.y + r.h, extracolor, font, extra); r.x:= FontBorder + 6; r.y:= FontBorder + 4; @@ -1449,7 +1449,7 @@ r.h:= 32; SDL_FillRect(tmpsurf, @r, $ffffffff); SDL_UpperBlit(iconsurf, iconrect, tmpsurf, @r); - + RenderHelpWindow:= Surface2Tex(tmpsurf, true); SDL_FreeSurface(tmpsurf) end; @@ -1457,16 +1457,16 @@ procedure RenderWeaponTooltip(atype: TAmmoType); {$IFNDEF IPHONEOS} var r: TSDL_Rect; - i: LongInt; - extra: ansistring; - extracolor: LongInt; + i: LongInt; + extra: ansistring; + extracolor: LongInt; begin // don't do anything if the window shouldn't be shown if not cWeaponTooltips then - begin - WeaponTooltipTex:= nil; - exit - end; + begin + WeaponTooltipTex:= nil; + exit + end; // free old texture FreeWeaponTooltip; @@ -1483,20 +1483,20 @@ extracolor:= 0; if (CurrentTeam <> nil) and (Ammoz[atype].SkipTurns >= CurrentTeam^.Clan^.TurnNumber) then // weapon or utility is not yet available - begin - extra:= trmsg[sidNotYetAvailable]; - extracolor:= LongInt($ffc77070); - end + begin + extra:= trmsg[sidNotYetAvailable]; + extracolor:= LongInt($ffc77070); + end else if (Ammoz[atype].Ammo.Propz and ammoprop_NoRoundEndHint) <> 0 then // weapon or utility won't end your turn - begin - extra:= trmsg[sidNoEndTurn]; - extracolor:= LongInt($ff70c770); - end + begin + extra:= trmsg[sidNoEndTurn]; + extracolor:= LongInt($ff70c770); + end else - begin - extra:= ''; - extracolor:= 0; - end; + begin + extra:= ''; + extracolor:= 0; + end; // render window and return the texture WeaponTooltipTex:= RenderHelpWindow(trammo[Ammoz[atype].NameId], trammoc[Ammoz[atype].NameId], trammod[Ammoz[atype].NameId], extra, extracolor, SpritesData[sprAMAmmos].Surface, @r) @@ -1510,7 +1510,7 @@ {$IFNDEF IPHONEOS} // draw the texture if it exists if WeaponTooltipTex <> nil then - DrawTexture(x, y, WeaponTooltipTex) + DrawTexture(x, y, WeaponTooltipTex) {$ENDIF} end; @@ -1519,7 +1519,7 @@ {$IFNDEF IPHONEOS} // free the existing texture (if there's any) if WeaponTooltipTex = nil then - exit; + exit; FreeTexture(WeaponTooltipTex); WeaponTooltipTex:= nil {$ENDIF} diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/uTeams.pas --- a/hedgewars/uTeams.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/uTeams.pas Sat Mar 06 10:59:20 2010 +0000 @@ -22,75 +22,75 @@ interface uses SDLh, uConsts, uKeys, uGears, uRandom, uFloat, uStats, uVisualGears, uCollisions, uLand, {$IFDEF GLES11} - gles11, + gles11, {$ELSE} - GL, + GL, {$ENDIF} - uSound; + uSound; type PHHAmmo = ^THHAmmo; - THHAmmo = array[0..cMaxSlotIndex, 0..cMaxSlotAmmoIndex] of TAmmo; + THHAmmo = array[0..cMaxSlotIndex, 0..cMaxSlotAmmoIndex] of TAmmo; - PHedgehog = ^THedgehog; - PTeam = ^TTeam; - PClan = ^TClan; + PHedgehog = ^THedgehog; + PTeam = ^TTeam; + PClan = ^TClan; - THedgehog = record - Name: string[MAXNAMELEN]; - Gear: PGear; - SpeechGear: PVisualGear; - NameTagTex, - HealthTagTex, - HatTex: PTexture; - Ammo: PHHAmmo; - AmmoStore: Longword; - CurSlot, CurAmmo: LongWord; - Team: PTeam; - MultiShootAttacks: Longword; - visStepPos: LongWord; - BotLevel : LongWord; // 0 - Human player - HatVisibility: GLfloat; - stats: TStatistics; - Hat: shortstring; + THedgehog = record + Name: string[MAXNAMELEN]; + Gear: PGear; + SpeechGear: PVisualGear; + NameTagTex, + HealthTagTex, + HatTex: PTexture; + Ammo: PHHAmmo; + AmmoStore: Longword; + CurSlot, CurAmmo: LongWord; + Team: PTeam; + MultiShootAttacks: Longword; + visStepPos: LongWord; + BotLevel : LongWord; // 0 - Human player + HatVisibility: GLfloat; + stats: TStatistics; + Hat: shortstring; King: boolean; // Flag for a bunch of hedgehog attributes Unplaced: boolean; // Flag for hog placing mode - end; + end; - TTeam = record - Clan: PClan; - TeamName: string[MAXNAMELEN]; - ExtDriven: boolean; - Binds: TBinds; - Hedgehogs: array[0..cMaxHHIndex] of THedgehog; - CurrHedgehog: LongWord; - NameTagTex: PTexture; - CrosshairTex, - GraveTex, - HealthTex, - FlagTex: PTexture; - Flag: shortstring; - GraveName: shortstring; - FortName: shortstring; - TeamHealth: LongInt; - TeamHealthBarWidth, - NewTeamHealthBarWidth: LongInt; - DrawHealthY: LongInt; - AttackBar: LongWord; - HedgehogsNumber: Longword; - hasGone: boolean; - voicepack: PVoicepack; + TTeam = record + Clan: PClan; + TeamName: string[MAXNAMELEN]; + ExtDriven: boolean; + Binds: TBinds; + Hedgehogs: array[0..cMaxHHIndex] of THedgehog; + CurrHedgehog: LongWord; + NameTagTex: PTexture; + CrosshairTex, + GraveTex, + HealthTex, + FlagTex: PTexture; + Flag: shortstring; + GraveName: shortstring; + FortName: shortstring; + TeamHealth: LongInt; + TeamHealthBarWidth, + NewTeamHealthBarWidth: LongInt; + DrawHealthY: LongInt; + AttackBar: LongWord; + HedgehogsNumber: Longword; + hasGone: boolean; + voicepack: PVoicepack; PlayerHash: shortstring; // md5 hash of player name. For temporary enabling of hats as thank you. Hashed for privacy of players - end; + end; - TClan = record - Color: Longword; - Teams: array[0..Pred(cMaxTeams)] of PTeam; - TeamsNumber: Longword; - CurrTeam: LongWord; - ClanHealth: LongInt; - ClanIndex: LongInt; - TurnNumber: LongWord; - end; + TClan = record + Color: Longword; + Teams: array[0..Pred(cMaxTeams)] of PTeam; + TeamsNumber: Longword; + CurrTeam: LongWord; + ClanHealth: LongInt; + ClanIndex: LongInt; + TurnNumber: LongWord; + end; var CurrentTeam: PTeam; PreviousTeam: PTeam; @@ -127,11 +127,11 @@ begin AliveCount:= 0; for t:= 0 to Pred(ClansCount) do - if ClansArray[t]^.ClanHealth > 0 then - begin - inc(AliveCount); - AliveClan:= ClansArray[t] - end; + if ClansArray[t]^.ClanHealth > 0 then + begin + inc(AliveCount); + AliveClan:= ClansArray[t] + end; if (AliveCount > 1) or ((AliveCount = 1) and ((GameFlags and gfOneClanMode) <> 0)) then exit(false); @@ -139,29 +139,29 @@ TurnTimeLeft:= 0; if AliveCount = 0 then - begin // draw - AddCaption(trmsg[sidDraw], cWhiteColor, capgrpGameState); - SendStat(siGameResult, trmsg[sidDraw]); - AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000) - end else // win - with AliveClan^ do - begin - if TeamsNumber = 1 then - s:= Format(shortstring(trmsg[sidWinner]), Teams[0]^.TeamName) // team wins - else - s:= Format(shortstring(trmsg[sidWinner]), Teams[0]^.TeamName); // clan wins + begin // draw + AddCaption(trmsg[sidDraw], cWhiteColor, capgrpGameState); + SendStat(siGameResult, trmsg[sidDraw]); + AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000) + end else // win + with AliveClan^ do + begin + if TeamsNumber = 1 then + s:= Format(shortstring(trmsg[sidWinner]), Teams[0]^.TeamName) // team wins + else + s:= Format(shortstring(trmsg[sidWinner]), Teams[0]^.TeamName); // clan wins - for j:= 0 to Pred(TeamsNumber) do - with Teams[j]^ do - for i:= 0 to cMaxHHIndex do - with Hedgehogs[i] do - if (Gear <> nil) then - Gear^.State:= gstWinner; + for j:= 0 to Pred(TeamsNumber) do + with Teams[j]^ do + for i:= 0 to cMaxHHIndex do + with Hedgehogs[i] do + if (Gear <> nil) then + Gear^.State:= gstWinner; - AddCaption(s, cWhiteColor, capgrpGameState); - SendStat(siGameResult, s); - AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000) - end; + AddCaption(s, cWhiteColor, capgrpGameState); + SendStat(siGameResult, s); + AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000) + end; SendStats end; @@ -175,52 +175,52 @@ if (PreviousTeam <> nil) and PlacingHogs and Unplaced then begin Unplaced:= false; - if Gear <> nil then + if Gear <> nil then begin DeleteCI(Gear); FindPlace(Gear, false, 0, LAND_WIDTH); if Gear <> nil then AddGearCI(Gear) end - end; + end; PreviousTeam:= CurrentTeam; with CurrentHedgehog^ do begin - if Gear <> nil then - begin - MultiShootAttacks:= 0; - Gear^.Message:= 0; - Gear^.Z:= cHHZ; - RemoveGearFromList(Gear); - InsertGearToList(Gear) - end + if Gear <> nil then + begin + MultiShootAttacks:= 0; + Gear^.Message:= 0; + Gear^.Z:= cHHZ; + RemoveGearFromList(Gear); + InsertGearToList(Gear) + end end; c:= CurrentTeam^.Clan^.ClanIndex; repeat - inc(c); - if c = ClansCount then - begin + inc(c); + if c = ClansCount then + begin if not PlacingHogs then inc(TotalRounds); - c:= 0 - end; + c:= 0 + end; - with ClansArray[c]^ do - begin - PrevTeam:= CurrTeam; - repeat - CurrTeam:= Succ(CurrTeam) mod TeamsNumber; - CurrentTeam:= Teams[CurrTeam]; - with CurrentTeam^ do - begin - PrevHH:= CurrHedgehog mod HedgehogsNumber; // prevent infinite loop when CurrHedgehog = 7, but HedgehogsNumber < 8 (team is destroyed before its first turn) - repeat - CurrHedgehog:= Succ(CurrHedgehog) mod HedgehogsNumber; - until (Hedgehogs[CurrHedgehog].Gear <> nil) or (CurrHedgehog = PrevHH) - end - until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) or (PrevTeam = CurrTeam); - end + with ClansArray[c]^ do + begin + PrevTeam:= CurrTeam; + repeat + CurrTeam:= Succ(CurrTeam) mod TeamsNumber; + CurrentTeam:= Teams[CurrTeam]; + with CurrentTeam^ do + begin + PrevHH:= CurrHedgehog mod HedgehogsNumber; // prevent infinite loop when CurrHedgehog = 7, but HedgehogsNumber < 8 (team is destroyed before its first turn) + repeat + CurrHedgehog:= Succ(CurrHedgehog) mod HedgehogsNumber; + until (Hedgehogs[CurrHedgehog].Gear <> nil) or (CurrHedgehog = PrevHH) + end + until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil) or (PrevTeam = CurrTeam); + end until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil); CurrentHedgehog:= @(CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]) @@ -251,17 +251,17 @@ SwitchNotHeldAmmo(CurrentHedgehog^); with CurrentHedgehog^ do - begin - with Gear^ do - begin - Z:= cCurrHHZ; - State:= gstHHDriven; - Active:= true - end; - RemoveGearFromList(Gear); - InsertGearToList(Gear); - FollowGear:= Gear - end; + begin + with Gear^ do + begin + Z:= cCurrHHZ; + State:= gstHHDriven; + Active:= true + end; + RemoveGearFromList(Gear); + InsertGearToList(Gear); + FollowGear:= Gear + end; ResetKbd; @@ -278,9 +278,9 @@ bShowFinger:= true; if (CurrentTeam^.ExtDriven or (CurrentHedgehog^.BotLevel > 0)) then - PlaySound(sndIllGetYou, CurrentTeam^.voicepack) + PlaySound(sndIllGetYou, CurrentTeam^.voicepack) else - PlaySound(sndYesSir, CurrentTeam^.voicepack); + PlaySound(sndYesSir, CurrentTeam^.voicepack); if PlacingHogs then begin @@ -402,21 +402,21 @@ var i: LongInt; begin with team^ do - begin - NewTeamHealthBarWidth:= 0; + begin + NewTeamHealthBarWidth:= 0; - if not hasGone then - for i:= 0 to cMaxHHIndex do - if Hedgehogs[i].Gear <> nil then - inc(NewTeamHealthBarWidth, Hedgehogs[i].Gear^.Health); + if not hasGone then + for i:= 0 to cMaxHHIndex do + if Hedgehogs[i].Gear <> nil then + inc(NewTeamHealthBarWidth, Hedgehogs[i].Gear^.Health); - TeamHealth:= NewTeamHealthBarWidth; - if NewTeamHealthBarWidth > MaxTeamHealth then - begin - MaxTeamHealth:= NewTeamHealthBarWidth; - RecountAllTeamsHealth; - end else NewTeamHealthBarWidth:= (NewTeamHealthBarWidth * cTeamHealthWidth) div MaxTeamHealth - end; + TeamHealth:= NewTeamHealthBarWidth; + if NewTeamHealthBarWidth > MaxTeamHealth then + begin + MaxTeamHealth:= NewTeamHealthBarWidth; + RecountAllTeamsHealth; + end else NewTeamHealthBarWidth:= (NewTeamHealthBarWidth * cTeamHealthWidth) div MaxTeamHealth + end; RecountClanHealth(team^.Clan); @@ -435,15 +435,15 @@ begin t:= 0; while (t < cMaxTeams) - and (TeamsArray[t] <> nil) - and (TeamsArray[t]^.TeamName <> s) do inc(t); + and (TeamsArray[t] <> nil) + and (TeamsArray[t]^.TeamName <> s) do inc(t); if (t = cMaxTeams) or (TeamsArray[t] = nil) then exit; with TeamsArray[t]^ do - begin - AddChatString('** '+ TeamName + ' is gone'); - hasGone:= true - end; + begin + AddChatString('** '+ TeamName + ' is gone'); + hasGone:= true + end; RecountTeamHealth(TeamsArray[t]) end; @@ -452,24 +452,24 @@ var i: LongInt; begin with Team do - for i:= 0 to cMaxHHIndex do - with Hedgehogs[i] do - if Gear <> nil then + for i:= 0 to cMaxHHIndex do + with Hedgehogs[i] do + if Gear <> nil then begin Gear^.Invulnerable:= false; - Gear^.Damage:= Gear^.Health + Gear^.Damage:= Gear^.Health end end; procedure init_uTeams; begin - CurrentTeam:= nil; - PreviousTeam:= nil; - CurrentHedgehog:= nil; - TeamsCount:= 0; - ClansCount:= 0; - LocalClan:= -1; - LocalAmmo:= -1; + CurrentTeam:= nil; + PreviousTeam:= nil; + CurrentHedgehog:= nil; + TeamsCount:= 0; + ClansCount:= 0; + LocalClan:= -1; + LocalAmmo:= -1; end; procedure free_uTeams; diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/uTriggers.pas --- a/hedgewars/uTriggers.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/uTriggers.pas Sat Mar 06 10:59:20 2010 +0000 @@ -147,7 +147,7 @@ procedure init_uTriggers; begin - TriggerList:= nil; + TriggerList:= nil; end; procedure free_uTriggers; diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/uVisualGears.pas --- a/hedgewars/uVisualGears.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/uVisualGears.pas Sat Mar 06 10:59:20 2010 +0000 @@ -22,30 +22,30 @@ interface uses SDLh, uConsts, uFloat, {$IFDEF GLES11} - gles11; + gles11; {$ELSE} - GL; + GL; {$ENDIF} type PVisualGear = ^TVisualGear; - TVGearStepProcedure = procedure (Gear: PVisualGear; Steps: Longword); - TVisualGear = record - NextGear, PrevGear: PVisualGear; - Frame, - FrameTicks: Longword; - X : hwFloat; - Y : hwFloat; - dX: hwFloat; - dY: hwFloat; - mdY: QWord; - Timer: Longword; - Angle, dAngle: real; - Kind: TVisualGearType; - doStep: TVGearStepProcedure; - Tex: PTexture; + TVGearStepProcedure = procedure (Gear: PVisualGear; Steps: Longword); + TVisualGear = record + NextGear, PrevGear: PVisualGear; + Frame, + FrameTicks: Longword; + X : hwFloat; + Y : hwFloat; + dX: hwFloat; + dY: hwFloat; + mdY: QWord; + Timer: Longword; + Angle, dAngle: real; + Kind: TVisualGearType; + doStep: TVGearStepProcedure; + Tex: PTexture; Hedgehog: pointer; Text: shortstring - end; + end; procedure init_uVisualGears; procedure free_uVisualGears; @@ -67,18 +67,18 @@ procedure AddDamageTag(X, Y, Damage, Color: LongWord); var s: shortstring; - Gear: PVisualGear; + Gear: PVisualGear; begin if cAltDamage then - begin - Gear:= AddVisualGear(X, Y, vgtSmallDamageTag); - if Gear <> nil then - with Gear^ do - begin - str(Damage, s); - Tex:= RenderStringTex(s, Color, fntSmall); - end - end + begin + Gear:= AddVisualGear(X, Y, vgtSmallDamageTag); + if Gear <> nil then + with Gear^ do + begin + str(Damage, s); + Tex:= RenderStringTex(s, Color, fntSmall); + end + end end; @@ -86,15 +86,15 @@ procedure doStepFlake(Gear: PVisualGear; Steps: Longword); begin with Gear^ do - begin - inc(FrameTicks, Steps); - if FrameTicks > vobFrameTicks then - begin - dec(FrameTicks, vobFrameTicks); - inc(Frame); - if Frame = vobFramesCount then Frame:= 0 - end - end; + begin + inc(FrameTicks, Steps); + if FrameTicks > vobFrameTicks then + begin + dec(FrameTicks, vobFrameTicks); + inc(Frame); + if Frame = vobFramesCount then Frame:= 0 + end + end; Gear^.X:= Gear^.X + (cWindSpeed * 200 + Gear^.dX) * Steps; Gear^.Y:= Gear^.Y + (Gear^.dY + cGravity * vobFallSpeed) * Steps; @@ -112,14 +112,14 @@ Gear^.X:= Gear^.X + (cWindSpeed * 200 + Gear^.dX) * Steps; for i:= 0 to Steps - 1 do - begin - if hwRound(Gear^.Y) > LAND_HEIGHT-1184 then // TODO - configure in theme - Gear^.dY:= Gear^.dY - _1div50000 - else - Gear^.dY:= Gear^.dY + _1div50000; + begin + if hwRound(Gear^.Y) > LAND_HEIGHT-1184 then // TODO - configure in theme + Gear^.dY:= Gear^.dY - _1div50000 + else + Gear^.dY:= Gear^.dY + _1div50000; - Gear^.Y:= Gear^.Y + Gear^.dY - end; + Gear^.Y:= Gear^.Y + Gear^.dY + end; if hwRound(Gear^.X) < -cScreenWidth - 256 then Gear^.X:= int2hwFloat(cScreenWidth + LAND_WIDTH) else if hwRound(Gear^.X) > cScreenWidth + LAND_WIDTH then Gear^.X:= int2hwFloat(-cScreenWidth - 256) @@ -133,13 +133,13 @@ //Gear^.dY:= Gear^.dY + cGravity; if Gear^.FrameTicks <= Steps then - if Gear^.Frame = 0 then DeleteVisualGear(Gear) - else - begin - dec(Gear^.Frame); - Gear^.FrameTicks:= cExplFrameTicks - end - else dec(Gear^.FrameTicks, Steps) + if Gear^.Frame = 0 then DeleteVisualGear(Gear) + else + begin + dec(Gear^.Frame); + Gear^.FrameTicks:= cExplFrameTicks + end + else dec(Gear^.FrameTicks, Steps) end; procedure doStepFire(Gear: PVisualGear; Steps: Longword); @@ -152,7 +152,7 @@ if Gear^.FrameTicks <= Steps then DeleteVisualGear(Gear) else - dec(Gear^.FrameTicks, Steps) + dec(Gear^.FrameTicks, Steps) end; procedure doStepShell(Gear: PVisualGear; Steps: Longword); @@ -165,9 +165,9 @@ Gear^.Angle:= round(Gear^.Angle + Steps) mod cMaxAngle; if Gear^.FrameTicks <= Steps then - DeleteVisualGear(Gear) + DeleteVisualGear(Gear) else - dec(Gear^.FrameTicks, Steps) + dec(Gear^.FrameTicks, Steps) end; procedure doStepSmallDamage(Gear: PVisualGear; Steps: Longword); @@ -175,20 +175,20 @@ Gear^.Y:= Gear^.Y - _0_02 * Steps; if Gear^.FrameTicks <= Steps then - DeleteVisualGear(Gear) + DeleteVisualGear(Gear) else - dec(Gear^.FrameTicks, Steps) + dec(Gear^.FrameTicks, Steps) end; procedure doStepBubble(Gear: PVisualGear; Steps: Longword); begin - Gear^.X:= Gear^.X + (cWindSpeed * 100 + Gear^.dX) * Steps; - Gear^.Y:= Gear^.Y - cDrownSpeed * Steps; + Gear^.X:= Gear^.X + (cWindSpeed * 100 + Gear^.dX) * Steps; + Gear^.Y:= Gear^.Y - cDrownSpeed * Steps; - if (Gear^.FrameTicks <= Steps) or (hwRound(Gear^.Y) < cWaterLine) then - DeleteVisualGear(Gear) - else - dec(Gear^.FrameTicks, Steps) + if (Gear^.FrameTicks <= Steps) or (hwRound(Gear^.Y) < cWaterLine) then + DeleteVisualGear(Gear) + else + dec(Gear^.FrameTicks, Steps) end; procedure doStepHealth(Gear: PVisualGear; Steps: Longword); @@ -197,134 +197,134 @@ Gear^.Y:= Gear^.Y - Gear^.dY * Steps; if Gear^.FrameTicks <= Steps then - DeleteVisualGear(Gear) + DeleteVisualGear(Gear) else - dec(Gear^.FrameTicks, Steps); + dec(Gear^.FrameTicks, Steps); end; procedure doStepSteam(Gear: PVisualGear; Steps: Longword); begin - Gear^.X:= Gear^.X + (cWindSpeed * 100 + Gear^.dX) * Steps; - Gear^.Y:= Gear^.Y - cDrownSpeed * Steps; + Gear^.X:= Gear^.X + (cWindSpeed * 100 + Gear^.dX) * Steps; + Gear^.Y:= Gear^.Y - cDrownSpeed * Steps; - if Gear^.FrameTicks <= Steps then - if Gear^.Frame = 0 then DeleteVisualGear(Gear) - else - begin - if Random(2) = 0 then dec(Gear^.Frame); - Gear^.FrameTicks:= cExplFrameTicks - end - else dec(Gear^.FrameTicks, Steps) + if Gear^.FrameTicks <= Steps then + if Gear^.Frame = 0 then DeleteVisualGear(Gear) + else + begin + if Random(2) = 0 then dec(Gear^.Frame); + Gear^.FrameTicks:= cExplFrameTicks + end + else dec(Gear^.FrameTicks, Steps) end; procedure doStepSmoke(Gear: PVisualGear; Steps: Longword); begin - Gear^.X:= Gear^.X + (cWindSpeed + Gear^.dX) * Steps; - Gear^.Y:= Gear^.Y - (cDrownSpeed + Gear^.dY) * Steps; + Gear^.X:= Gear^.X + (cWindSpeed + Gear^.dX) * Steps; + Gear^.Y:= Gear^.Y - (cDrownSpeed + Gear^.dY) * Steps; - Gear^.dX := Gear^.dX + (cWindSpeed * _0_3 * Steps); - //Gear^.dY := Gear^.dY - (cDrownSpeed * _0_995); + Gear^.dX := Gear^.dX + (cWindSpeed * _0_3 * Steps); + //Gear^.dY := Gear^.dY - (cDrownSpeed * _0_995); - if Gear^.FrameTicks <= Steps then - if Gear^.Frame = 0 then DeleteVisualGear(Gear) - else - begin - if Random(2) = 0 then dec(Gear^.Frame); - Gear^.FrameTicks:= cExplFrameTicks - end - else dec(Gear^.FrameTicks, Steps) + if Gear^.FrameTicks <= Steps then + if Gear^.Frame = 0 then DeleteVisualGear(Gear) + else + begin + if Random(2) = 0 then dec(Gear^.Frame); + Gear^.FrameTicks:= cExplFrameTicks + end + else dec(Gear^.FrameTicks, Steps) end; procedure doStepDust(Gear: PVisualGear; Steps: Longword); begin - Gear^.X:= Gear^.X + (cWindSpeed + (cWindSpeed * _0_03 * Steps) + Gear^.dX) * Steps; - Gear^.Y:= Gear^.Y - (Gear^.dY) * Steps; + Gear^.X:= Gear^.X + (cWindSpeed + (cWindSpeed * _0_03 * Steps) + Gear^.dX) * Steps; + Gear^.Y:= Gear^.Y - (Gear^.dY) * Steps; - Gear^.dX := Gear^.dX - (Gear^.dX * _0_005 * Steps); - Gear^.dY := Gear^.dY - (cDrownSpeed * _0_001 * Steps); + Gear^.dX := Gear^.dX - (Gear^.dX * _0_005 * Steps); + Gear^.dY := Gear^.dY - (cDrownSpeed * _0_001 * Steps); - if Gear^.FrameTicks <= Steps then - if Gear^.Frame = 0 then DeleteVisualGear(Gear) - else - begin - dec(Gear^.Frame); - Gear^.FrameTicks:= cExplFrameTicks - end - else dec(Gear^.FrameTicks, Steps) + if Gear^.FrameTicks <= Steps then + if Gear^.Frame = 0 then DeleteVisualGear(Gear) + else + begin + dec(Gear^.Frame); + Gear^.FrameTicks:= cExplFrameTicks + end + else dec(Gear^.FrameTicks, Steps) end; //////////////////////////////////////////////////////////////////////////////// const cSorterWorkTime = 640; var thexchar: array[0..cMaxTeams] of - record - dy, ny, dw: LongInt; - team: PTeam; - SortFactor: QWord; - end; + record + dy, ny, dw: LongInt; + team: PTeam; + SortFactor: QWord; + end; currsorter: PVisualGear = nil; procedure doStepTeamHealthSorterWork(Gear: PVisualGear; Steps: Longword); var i, t: LongInt; begin for t:= 1 to Steps do - begin - dec(Gear^.Timer); - if (Gear^.Timer and 15) = 0 then - for i:= 0 to Pred(TeamsCount) do - with thexchar[i] do - begin - {$WARNINGS OFF} - team^.DrawHealthY:= ny + dy * Gear^.Timer div 640; - team^.TeamHealthBarWidth:= team^.NewTeamHealthBarWidth + dw * Gear^.Timer div cSorterWorkTime; - {$WARNINGS ON} - end; + begin + dec(Gear^.Timer); + if (Gear^.Timer and 15) = 0 then + for i:= 0 to Pred(TeamsCount) do + with thexchar[i] do + begin + {$WARNINGS OFF} + team^.DrawHealthY:= ny + dy * Gear^.Timer div 640; + team^.TeamHealthBarWidth:= team^.NewTeamHealthBarWidth + dw * Gear^.Timer div cSorterWorkTime; + {$WARNINGS ON} + end; - if (Gear^.Timer = 0) or (currsorter <> Gear) then - begin - if currsorter = Gear then currsorter:= nil; - DeleteVisualGear(Gear); - exit - end - end + if (Gear^.Timer = 0) or (currsorter <> Gear) then + begin + if currsorter = Gear then currsorter:= nil; + DeleteVisualGear(Gear); + exit + end + end end; procedure doStepTeamHealthSorter(Gear: PVisualGear; Steps: Longword); var i: Longword; - b: boolean; - t: LongInt; + b: boolean; + t: LongInt; begin for t:= 0 to Pred(TeamsCount) do - with thexchar[t] do - begin - dy:= TeamsArray[t]^.DrawHealthY; - dw:= TeamsArray[t]^.TeamHealthBarWidth - TeamsArray[t]^.NewTeamHealthBarWidth; - team:= TeamsArray[t]; - SortFactor:= TeamsArray[t]^.Clan^.ClanHealth; - SortFactor:= (SortFactor shl 3) + TeamsArray[t]^.Clan^.ClanIndex; - SortFactor:= (SortFactor shl 30) + TeamsArray[t]^.TeamHealth; - end; + with thexchar[t] do + begin + dy:= TeamsArray[t]^.DrawHealthY; + dw:= TeamsArray[t]^.TeamHealthBarWidth - TeamsArray[t]^.NewTeamHealthBarWidth; + team:= TeamsArray[t]; + SortFactor:= TeamsArray[t]^.Clan^.ClanHealth; + SortFactor:= (SortFactor shl 3) + TeamsArray[t]^.Clan^.ClanIndex; + SortFactor:= (SortFactor shl 30) + TeamsArray[t]^.TeamHealth; + end; if TeamsCount > 1 then - repeat - b:= true; - for t:= 0 to TeamsCount - 2 do - if (thexchar[t].SortFactor > thexchar[Succ(t)].SortFactor) then - begin - thexchar[cMaxTeams]:= thexchar[t]; - thexchar[t]:= thexchar[Succ(t)]; - thexchar[Succ(t)]:= thexchar[cMaxTeams]; - b:= false - end - until b; + repeat + b:= true; + for t:= 0 to TeamsCount - 2 do + if (thexchar[t].SortFactor > thexchar[Succ(t)].SortFactor) then + begin + thexchar[cMaxTeams]:= thexchar[t]; + thexchar[t]:= thexchar[Succ(t)]; + thexchar[Succ(t)]:= thexchar[cMaxTeams]; + b:= false + end + until b; t:= - 4; for i:= 0 to Pred(TeamsCount) do - with thexchar[i] do - begin - dec(t, team^.HealthTex^.h + 2); - ny:= t; - dy:= dy - ny - end; + with thexchar[i] do + begin + dec(t, team^.HealthTex^.h + 2); + ny:= t; + dy:= dy - ny + end; Gear^.Timer:= cSorterWorkTime; Gear^.doStep:= @doStepTeamHealthSorterWork; @@ -337,17 +337,17 @@ if Gear^.Timer > Steps then dec(Gear^.Timer, Steps) else Gear^.Timer:= 0; if (PHedgehog(Gear^.Hedgehog)^.Gear <> nil) then - begin - Gear^.X:= PHedgehog(Gear^.Hedgehog)^.Gear^.X + int2hwFloat(Gear^.Tex^.w div 2 - Gear^.FrameTicks); - Gear^.Y:= PHedgehog(Gear^.Hedgehog)^.Gear^.Y - int2hwFloat(16 + Gear^.Tex^.h); - end; + begin + Gear^.X:= PHedgehog(Gear^.Hedgehog)^.Gear^.X + int2hwFloat(Gear^.Tex^.w div 2 - Gear^.FrameTicks); + Gear^.Y:= PHedgehog(Gear^.Hedgehog)^.Gear^.Y - int2hwFloat(16 + Gear^.Tex^.h); + end; if Gear^.Timer = 0 then - begin - if PHedgehog(Gear^.Hedgehog)^.SpeechGear = Gear then - PHedgehog(Gear^.Hedgehog)^.SpeechGear:= nil; - DeleteVisualGear(Gear) - end; + begin + if PHedgehog(Gear^.Hedgehog)^.SpeechGear = Gear then + PHedgehog(Gear^.Hedgehog)^.SpeechGear:= nil; + DeleteVisualGear(Gear) + end; end; procedure doStepSpeechBubble(Gear: PVisualGear; Steps: Longword); @@ -374,44 +374,44 @@ // ================================================================== const doStepHandlers: array[TVisualGearType] of TVGearStepProcedure = - ( - @doStepFlake, - @doStepCloud, - @doStepExpl, - @doStepExpl, - @doStepFire, - @doStepSmallDamage, - @doStepTeamHealthSorter, - @doStepSpeechBubble, - @doStepBubble, - @doStepSteam, - @doStepSmoke, - @doStepSmoke, - @doStepHealth, - @doStepShell, - @doStepDust - ); + ( + @doStepFlake, + @doStepCloud, + @doStepExpl, + @doStepExpl, + @doStepFire, + @doStepSmallDamage, + @doStepTeamHealthSorter, + @doStepSpeechBubble, + @doStepBubble, + @doStepSteam, + @doStepSmoke, + @doStepSmoke, + @doStepHealth, + @doStepShell, + @doStepDust + ); function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType): PVisualGear; var gear: PVisualGear; - t: Longword; - sp: hwFloat; + t: Longword; + sp: hwFloat; begin if (GameType = gmtSave) or (fastUntilLag and (GameType = gmtNet)) then // we are scrolling now - if Kind <> vgtCloud then - begin - AddVisualGear:= nil; - exit - end; + if Kind <> vgtCloud then + begin + AddVisualGear:= nil; + exit + end; if cReducedQuality and (Kind <> vgtTeamHealthSorter) and (Kind <> vgtSmallDamageTag) and (Kind <> vgtSpeechBubble) then - begin - AddVisualGear:= nil; - exit - end; + begin + AddVisualGear:= nil; + exit + end; New(gear); FillChar(gear^, sizeof(TVisualGear), 0); @@ -421,96 +421,96 @@ gear^.doStep:= doStepHandlers[Kind]; with gear^ do - case Kind of - vgtFlake: begin - FrameTicks:= random(vobFrameTicks); - Frame:= random(vobFramesCount); - Angle:= random * 360; - dx.isNegative:= random(2) = 0; - dx.QWordValue:= random(100000000); - dy.isNegative:= false; - dy.QWordValue:= random(70000000); - dAngle:= (random(2) * 2 - 1) * (1 + random) * vobVelocity / 1000 - end; - vgtCloud: begin - Frame:= random(4); - dx.isNegative:= random(2) = 0; - dx.QWordValue:= random(214748364); - dy.isNegative:= random(2) = 0; - dy.QWordValue:= 21474836 + random(64424509); - mdY:= dy.QWordValue - end; - vgtExplPart, - vgtExplPart2: begin - t:= random(1024); - sp:= _0_001 * (random(95) + 70); - dx:= AngleSin(t) * sp; - dx.isNegative:= random(2) = 0; - dy:= AngleCos(t) * sp; - dy.isNegative:= random(2) = 0; - Frame:= 7 - random(3); - FrameTicks:= cExplFrameTicks - end; - vgtFire: begin - t:= random(1024); - sp:= _0_001 * (random(85) + 95); - dx:= AngleSin(t) * sp; - dx.isNegative:= random(2) = 0; - dy:= AngleCos(t) * sp; - dy.isNegative:= random(2) = 0; - FrameTicks:= 650 + random(250); - Frame:= random(8) - end; - vgtShell: FrameTicks:= 500; - vgtSmallDamageTag: begin - gear^.FrameTicks:= 1100 - end; - vgtBubble: begin - dx.isNegative:= random(2) = 0; - dx.QWordValue:= random(100000000); - dy:= _0_001 * (random(85) + 95); - dy.isNegative:= false; - FrameTicks:= 250 + random(1751); - Frame:= random(5) - end; - vgtSteam: begin - dx.isNegative:= random(2) = 0; - dx.QWordValue:= random(100000000); - dy:= _0_001 * (random(85) + 95); - dy.isNegative:= false; - Frame:= 7 - random(3); - FrameTicks:= cExplFrameTicks * 2; - end; + case Kind of + vgtFlake: begin + FrameTicks:= random(vobFrameTicks); + Frame:= random(vobFramesCount); + Angle:= random * 360; + dx.isNegative:= random(2) = 0; + dx.QWordValue:= random(100000000); + dy.isNegative:= false; + dy.QWordValue:= random(70000000); + dAngle:= (random(2) * 2 - 1) * (1 + random) * vobVelocity / 1000 + end; + vgtCloud: begin + Frame:= random(4); + dx.isNegative:= random(2) = 0; + dx.QWordValue:= random(214748364); + dy.isNegative:= random(2) = 0; + dy.QWordValue:= 21474836 + random(64424509); + mdY:= dy.QWordValue + end; + vgtExplPart, + vgtExplPart2: begin + t:= random(1024); + sp:= _0_001 * (random(95) + 70); + dx:= AngleSin(t) * sp; + dx.isNegative:= random(2) = 0; + dy:= AngleCos(t) * sp; + dy.isNegative:= random(2) = 0; + Frame:= 7 - random(3); + FrameTicks:= cExplFrameTicks + end; + vgtFire: begin + t:= random(1024); + sp:= _0_001 * (random(85) + 95); + dx:= AngleSin(t) * sp; + dx.isNegative:= random(2) = 0; + dy:= AngleCos(t) * sp; + dy.isNegative:= random(2) = 0; + FrameTicks:= 650 + random(250); + Frame:= random(8) + end; + vgtShell: FrameTicks:= 500; + vgtSmallDamageTag: begin + gear^.FrameTicks:= 1100 + end; + vgtBubble: begin + dx.isNegative:= random(2) = 0; + dx.QWordValue:= random(100000000); + dy:= _0_001 * (random(85) + 95); + dy.isNegative:= false; + FrameTicks:= 250 + random(1751); + Frame:= random(5) + end; + vgtSteam: begin + dx.isNegative:= random(2) = 0; + dx.QWordValue:= random(100000000); + dy:= _0_001 * (random(85) + 95); + dy.isNegative:= false; + Frame:= 7 - random(3); + FrameTicks:= cExplFrameTicks * 2; + end; vgtSmokeWhite, vgtSmoke: begin - dx:= _0_0002 * (random(45) + 10); - dx.isNegative:= random(2) = 0; - dy:= _0_0002 * (random(45) + 10); - dy.isNegative:= false; - Frame:= 7 - random(2); - FrameTicks:= cExplFrameTicks * 2; - end; - vgtHealth: begin - dx:= _0_001 * random(45); - dx.isNegative:= random(2) = 0; - dy:= _0_001 * (random(20) + 25); - Frame:= 0; - FrameTicks:= random(750) + 1250; - end; + dx:= _0_0002 * (random(45) + 10); + dx.isNegative:= random(2) = 0; + dy:= _0_0002 * (random(45) + 10); + dy.isNegative:= false; + Frame:= 7 - random(2); + FrameTicks:= cExplFrameTicks * 2; + end; + vgtHealth: begin + dx:= _0_001 * random(45); + dx.isNegative:= random(2) = 0; + dy:= _0_001 * (random(20) + 25); + Frame:= 0; + FrameTicks:= random(750) + 1250; + end; vgtDust: begin - dx:= _0_005 * (random(15) + 10); - dx.isNegative:= random(2) = 0; - dy:= _0_001 * (random(40) + 20); - Frame:= 7 - random(2); - FrameTicks:= random(20) + 15; - end; - end; + dx:= _0_005 * (random(15) + 10); + dx.isNegative:= random(2) = 0; + dy:= _0_001 * (random(40) + 20); + Frame:= 7 - random(2); + FrameTicks:= random(20) + 15; + end; + end; if VisualGearsList <> nil then - begin - VisualGearsList^.PrevGear:= gear; - gear^.NextGear:= VisualGearsList - end; + begin + VisualGearsList^.PrevGear:= gear; + gear^.NextGear:= VisualGearsList + end; VisualGearsList:= gear; AddVisualGear:= gear; @@ -519,7 +519,7 @@ procedure DeleteVisualGear(Gear: PVisualGear); begin if Gear^.Tex <> nil then - FreeTexture(Gear^.Tex); + FreeTexture(Gear^.Tex); if Gear^.NextGear <> nil then Gear^.NextGear^.PrevGear:= Gear^.PrevGear; if Gear^.PrevGear <> nil then Gear^.PrevGear^.NextGear:= Gear^.NextGear @@ -547,59 +547,59 @@ begin Gear:= VisualGearsList; case Layer of - 0: while Gear <> nil do - begin - case Gear^.Kind of - vgtFlake: if vobVelocity = 0 then - DrawSprite(sprFlake, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame) - else - DrawRotatedF(sprFlake, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle); - vgtCloud: DrawSprite(sprCloud, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame); - end; - Gear:= Gear^.NextGear - end; - 1: while Gear <> nil do - begin - if not cReducedQuality then - case Gear^.Kind of - vgtSmoke: DrawSprite(sprSmoke, hwRound(Gear^.X) + WorldDx - 11, hwRound(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame); - vgtSmokeWhite: DrawSprite(sprSmokeWhite, hwRound(Gear^.X) + WorldDx - 11, hwRound(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame); - vgtDust: DrawSprite(sprDust, hwRound(Gear^.X) + WorldDx - 11, hwRound(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame); - end; - Gear:= Gear^.NextGear - end; - 2: while Gear <> nil do - begin + 0: while Gear <> nil do + begin + case Gear^.Kind of + vgtFlake: if vobVelocity = 0 then + DrawSprite(sprFlake, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame) + else + DrawRotatedF(sprFlake, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle); + vgtCloud: DrawSprite(sprCloud, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame); + end; + Gear:= Gear^.NextGear + end; + 1: while Gear <> nil do + begin + if not cReducedQuality then + case Gear^.Kind of + vgtSmoke: DrawSprite(sprSmoke, hwRound(Gear^.X) + WorldDx - 11, hwRound(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame); + vgtSmokeWhite: DrawSprite(sprSmokeWhite, hwRound(Gear^.X) + WorldDx - 11, hwRound(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame); + vgtDust: DrawSprite(sprDust, hwRound(Gear^.X) + WorldDx - 11, hwRound(Gear^.Y) + WorldDy - 11, 7 - Gear^.Frame); + end; + Gear:= Gear^.NextGear + end; + 2: while Gear <> nil do + begin if not cReducedQuality then case Gear^.Kind of vgtExplPart: DrawSprite(sprExplPart, hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 7 - Gear^.Frame); vgtExplPart2: DrawSprite(sprExplPart2, hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 7 - Gear^.Frame); vgtFire: DrawSprite(sprFlame, hwRound(Gear^.X) + WorldDx - 8, hwRound(Gear^.Y) + WorldDy, (RealTicks div 64 + Gear^.Frame) mod 8); - vgtBubble: DrawSprite(sprBubbles, hwRound(Gear^.X) + WorldDx - 8, hwRound(Gear^.Y) + WorldDy - 8, Gear^.Frame);//(RealTicks div 64 + Gear^.Frame) mod 8); - vgtSteam: DrawSprite(sprExplPart, hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 7 - Gear^.Frame); - vgtHealth: begin - case Gear^.Frame div 10 of - 0:glColor4f(0, 1, 0, Gear^.FrameTicks / 1000); - 1:glColor4f(1, 0, 0, Gear^.FrameTicks / 1000); - end; - DrawSprite(sprHealth, hwRound(Gear^.X) + WorldDx - 8, hwRound(Gear^.Y) + WorldDy - 8, 0); - glColor4f(1, 1, 1, 1); - end; - vgtShell: begin - if Gear^.FrameTicks < 250 then - glColor4f(1, 1, 1, Gear^.FrameTicks / 250); - DrawRotatedF(sprShell, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle); - if Gear^.FrameTicks < 250 then - glColor4f(1, 1, 1, 1); - end; + vgtBubble: DrawSprite(sprBubbles, hwRound(Gear^.X) + WorldDx - 8, hwRound(Gear^.Y) + WorldDy - 8, Gear^.Frame);//(RealTicks div 64 + Gear^.Frame) mod 8); + vgtSteam: DrawSprite(sprExplPart, hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 7 - Gear^.Frame); + vgtHealth: begin + case Gear^.Frame div 10 of + 0:glColor4f(0, 1, 0, Gear^.FrameTicks / 1000); + 1:glColor4f(1, 0, 0, Gear^.FrameTicks / 1000); + end; + DrawSprite(sprHealth, hwRound(Gear^.X) + WorldDx - 8, hwRound(Gear^.Y) + WorldDy - 8, 0); + glColor4f(1, 1, 1, 1); + end; + vgtShell: begin + if Gear^.FrameTicks < 250 then + glColor4f(1, 1, 1, Gear^.FrameTicks / 250); + DrawRotatedF(sprShell, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Frame, 1, Gear^.Angle); + if Gear^.FrameTicks < 250 then + glColor4f(1, 1, 1, 1); + end; end; case Gear^.Kind of vgtSmallDamageTag: DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex); vgtSpeechBubble: if Gear^.Tex <> nil then DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tex); end; - Gear:= Gear^.NextGear - end - end + Gear:= Gear^.NextGear + end + end end; procedure AddClouds; @@ -611,12 +611,12 @@ procedure init_uVisualGears; begin - VisualGearsList:= nil; + VisualGearsList:= nil; end; procedure free_uVisualGears; begin - while VisualGearsList <> nil do DeleteVisualGear(VisualGearsList); + while VisualGearsList <> nil do DeleteVisualGear(VisualGearsList); end; end. diff -r 803b277e4894 -r 3f21a9dc93d0 hedgewars/uWorld.pas --- a/hedgewars/uWorld.pas Sat Mar 06 10:54:24 2010 +0000 +++ b/hedgewars/uWorld.pas Sat Mar 06 10:59:20 2010 +0000 @@ -46,11 +46,11 @@ procedure HideMission; implementation -uses uStore, uMisc, uTeams, uIO, uConsole, uKeys, uLocale, uSound, uAmmos, uVisualGears, uChat, uLandTexture, uLand, +uses uStore, uMisc, uTeams, uIO, uConsole, uKeys, uLocale, uSound, uAmmos, uVisualGears, uChat, uLandTexture, uLand, {$IFDEF GLES11} - gles11; + gles11; {$ELSE} - GL; + GL; {$ENDIF} type TCaptionStr = record @@ -68,9 +68,9 @@ CountTicks: Longword; SoundTimerTicks: Longword; prevPoint: TPoint; - amSel: TAmmoType = amNothing; - missionTex: PTexture; - missionTimer: LongInt; + amSel: TAmmoType = amNothing; + missionTex: PTexture; + missionTimer: LongInt; procedure InitWorld; var i, t: LongInt; @@ -122,18 +122,18 @@ // modified damage modificator? if cDamagePercent <> 100 then - g:= AddGoal(g, gfAny, gidDamageModifier, cDamagePercent); + g:= AddGoal(g, gfAny, gidDamageModifier, cDamagePercent); // modified mine timers? if cMinesTime <> 3000 then - begin - if cMinesTime = 0 then - g:= AddGoal(g, gfMines, gidNoMineTimer) - else if cMinesTime < 0 then - g:= AddGoal(g, gfMines, gidRandomMineTimer) - else - g:= AddGoal(g, gfMines, gidMineTimer, cMinesTime div 1000); - end; + begin + if cMinesTime = 0 then + g:= AddGoal(g, gfMines, gidNoMineTimer) + else if cMinesTime < 0 then + g:= AddGoal(g, gfMines, gidRandomMineTimer) + else + g:= AddGoal(g, gfMines, gidMineTimer, cMinesTime div 1000); + end; // check different game flags g:= AddGoal(g, gfForts, gidForts); // forts? @@ -210,70 +210,70 @@ dec(y, 33); DrawSprite(sprAMSlotName, x, y, 0); for i:= cMaxSlotIndex downto 0 do - if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then - begin - if (cScreenHeight - CursorPoint.Y >= y - 33) and (cScreenHeight - CursorPoint.Y < y) then Slot:= i; - dec(y, 33); - inc(SlotsNum); - DrawSprite(sprAMSlot, x, y, 0); - DrawSprite(sprAMSlotKeys, x + 2, y + 1, i); - t:= 0; + if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then + begin + if (cScreenHeight - CursorPoint.Y >= y - 33) and (cScreenHeight - CursorPoint.Y < y) then Slot:= i; + dec(y, 33); + inc(SlotsNum); + DrawSprite(sprAMSlot, x, y, 0); + DrawSprite(sprAMSlotKeys, x + 2, y + 1, i); + t:= 0; g:= 0; - while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do - begin - if (Ammo^[i, t].AmmoType <> amNothing) then - begin - l:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber; + while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do + begin + if (Ammo^[i, t].AmmoType <> amNothing) then + begin + l:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber; - if l >= 0 then - begin - DrawSprite(sprAMAmmosBW, x + g * 33 + 35, y + 1, LongInt(Ammo^[i, t].AmmoType)-1); + if l >= 0 then + begin + DrawSprite(sprAMAmmosBW, x + g * 33 + 35, y + 1, LongInt(Ammo^[i, t].AmmoType)-1); if l < 100 then DrawSprite(sprTurnsLeft, x + g * 33 + 51, y + 17, l); - end else - DrawSprite(sprAMAmmos, x + g * 33 + 35, y + 1, LongInt(Ammo^[i, t].AmmoType)-1); - if (Slot = i) - and (CursorPoint.X >= x + g * 33 + 35) - and (CursorPoint.X < x + g * 33 + 68) then - begin - if (l < 0) then DrawSprite(sprAMSelection, x + g * 33 + 35, y + 1, 0); - Pos:= t; - end; - inc(g) - end; - inc(t) - end - end; + end else + DrawSprite(sprAMAmmos, x + g * 33 + 35, y + 1, LongInt(Ammo^[i, t].AmmoType)-1); + if (Slot = i) + and (CursorPoint.X >= x + g * 33 + 35) + and (CursorPoint.X < x + g * 33 + 68) then + begin + if (l < 0) then DrawSprite(sprAMSelection, x + g * 33 + 35, y + 1, 0); + Pos:= t; + end; + inc(g) + end; + inc(t) + end + end; dec(y, 1); DrawSprite(sprAMBorders, x, y, 0); if (Pos >= 0) then - begin - if (Ammo^[Slot, Pos].Count > 0) and (Ammo^[Slot, Pos].AmmoType <> amNothing) then - if (amSel <> Ammo^[Slot, Pos].AmmoType) or (WeaponTooltipTex = nil) then - begin - amSel:= Ammo^[Slot, Pos].AmmoType; - RenderWeaponTooltip(amSel) - end; - - DrawTexture(cScreenWidth div 2 - 200 + AMxShift, cScreenHeight - 68, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex); + begin + if (Ammo^[Slot, Pos].Count > 0) and (Ammo^[Slot, Pos].AmmoType <> amNothing) then + if (amSel <> Ammo^[Slot, Pos].AmmoType) or (WeaponTooltipTex = nil) then + begin + amSel:= Ammo^[Slot, Pos].AmmoType; + RenderWeaponTooltip(amSel) + end; + + DrawTexture(cScreenWidth div 2 - 200 + AMxShift, cScreenHeight - 68, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex); - if Ammo^[Slot, Pos].Count < AMMO_INFINITE then - DrawTexture(cScreenWidth div 2 + AMxShift - 35, cScreenHeight - 68, CountTexz[Ammo^[Slot, Pos].Count]); + if Ammo^[Slot, Pos].Count < AMMO_INFINITE then + DrawTexture(cScreenWidth div 2 + AMxShift - 35, cScreenHeight - 68, CountTexz[Ammo^[Slot, Pos].Count]); - if bSelected and (Ammoz[Ammo^[Slot, Pos].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber < 0) then - begin - bShowAmmoMenu:= false; - SetWeapon(Ammo^[Slot, Pos].AmmoType); - bSelected:= false; - FreeWeaponTooltip; - exit - end; - end + if bSelected and (Ammoz[Ammo^[Slot, Pos].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber < 0) then + begin + bShowAmmoMenu:= false; + SetWeapon(Ammo^[Slot, Pos].AmmoType); + bSelected:= false; + FreeWeaponTooltip; + exit + end; + end else - FreeWeaponTooltip; + FreeWeaponTooltip; if (WeaponTooltipTex <> nil) and (AMxShift = 0) then - ShowWeaponTooltip(x - WeaponTooltipTex^.w - 3, y); + ShowWeaponTooltip(x - WeaponTooltipTex^.w - 3, y); bSelected:= false; if AMxShift = 0 then DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8) @@ -296,38 +296,38 @@ // Water r.y:= WorldDy + cWaterLine; if WorldDy < trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine then - begin - if r.y < 0 then r.y:= 0; + begin + if r.y < 0 then r.y:= 0; - glDisable(GL_TEXTURE_2D); - VertexBuffer[0].X:= -lw; - VertexBuffer[0].Y:= r.y; - VertexBuffer[1].X:= lw; - VertexBuffer[1].Y:= r.y; - VertexBuffer[2].X:= lw; - VertexBuffer[2].Y:= lh; - VertexBuffer[3].X:= -lw; - VertexBuffer[3].Y:= lh; + glDisable(GL_TEXTURE_2D); + VertexBuffer[0].X:= -lw; + VertexBuffer[0].Y:= r.y; + VertexBuffer[1].X:= lw; + VertexBuffer[1].Y:= r.y; + VertexBuffer[2].X:= lw; + VertexBuffer[2].Y:= lh; + VertexBuffer[3].X:= -lw; + VertexBuffer[3].Y:= lh; - glEnableClientState (GL_COLOR_ARRAY); - glColorPointer(4, GL_UNSIGNED_BYTE, 0, @WaterColorArray[0]); + glEnableClientState (GL_COLOR_ARRAY); + glColorPointer(4, GL_UNSIGNED_BYTE, 0, @WaterColorArray[0]); - glEnableClientState(GL_VERTEX_ARRAY); - glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); - glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); + glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); - glColor4f(1, 1, 1, 1); // disable coloring - glEnable(GL_TEXTURE_2D) - end + glColor4f(1, 1, 1, 1); // disable coloring + glEnable(GL_TEXTURE_2D) + end end; procedure DrawWaves(Dir, dX, dY: LongInt); var VertexBuffer, TextureBuffer: array [0..3] of TVertex2f; - lw, waves, shift: GLfloat; + lw, waves, shift: GLfloat; begin lw:= cScreenWidth / cScaleFactor; waves:= lw * 2 / cWaveWidth; @@ -365,10 +365,10 @@ {for i:= -1 to cWaterSprCount do - DrawSprite(sprWater, - i * cWaveWidth + ((WorldDx + (RealTicks shr 6) * Dir + dX) mod cWaveWidth) - (cScreenWidth div 2), - cWaterLine + WorldDy + dY, - 0)} + DrawSprite(sprWater, + i * cWaveWidth + ((WorldDx + (RealTicks shr 6) * Dir + dX) mod cWaveWidth) - (cScreenWidth div 2), + cWaterLine + WorldDy + dY, + 0)} end; procedure DrawRepeated(spr, sprL, sprR: TSprite; Shift: LongInt); @@ -376,37 +376,37 @@ begin sw:= round(cScreenWidth / cScaleFactor); if (SpritesData[sprL].Texture = nil) or (SpritesData[sprR].Texture = nil) then - begin - w:= SpritesData[spr].Width; - i:= Shift mod w; - if i > 0 then dec(i, w); - dec(i, w * (sw div w + 1)); - repeat - DrawSprite(spr, i, WorldDy + LAND_HEIGHT - SpritesData[spr].Height, 0); - inc(i, w) - until i > sw - end else - begin - w:= SpritesData[spr].Width; - dec(Shift, w div 2); - DrawSprite(spr, Shift, WorldDy + LAND_HEIGHT - SpritesData[spr].Height, 0); + begin + w:= SpritesData[spr].Width; + i:= Shift mod w; + if i > 0 then dec(i, w); + dec(i, w * (sw div w + 1)); + repeat + DrawSprite(spr, i, WorldDy + LAND_HEIGHT - SpritesData[spr].Height, 0); + inc(i, w) + until i > sw + end else + begin + w:= SpritesData[spr].Width; + dec(Shift, w div 2); + DrawSprite(spr, Shift, WorldDy + LAND_HEIGHT - SpritesData[spr].Height, 0); - sw:= round(cScreenWidth / cScaleFactor); - - i:= Shift - SpritesData[sprL].Width; - while i >= -sw - SpritesData[sprL].Width do - begin - DrawSprite(sprL, i, WorldDy + LAND_HEIGHT - SpritesData[sprL].Height, 0); - dec(i, SpritesData[sprL].Width); - end; - - i:= Shift + w; - while i <= sw do - begin - DrawSprite(sprR, i, WorldDy + LAND_HEIGHT - SpritesData[sprR].Height, 0); - inc(i, SpritesData[sprR].Width) - end - end + sw:= round(cScreenWidth / cScaleFactor); + + i:= Shift - SpritesData[sprL].Width; + while i >= -sw - SpritesData[sprL].Width do + begin + DrawSprite(sprL, i, WorldDy + LAND_HEIGHT - SpritesData[sprL].Height, 0); + dec(i, SpritesData[sprL].Width); + end; + + i:= Shift + w; + while i <= sw do + begin + DrawSprite(sprR, i, WorldDy + LAND_HEIGHT - SpritesData[sprR].Height, 0); + inc(i, SpritesData[sprR].Width) + end + end end; @@ -421,15 +421,15 @@ scale: GLfloat; begin if ZoomValue < zoom then - begin - zoom:= zoom - 0.002 * Lag; - if ZoomValue > zoom then zoom:= ZoomValue - end else + begin + zoom:= zoom - 0.002 * Lag; + if ZoomValue > zoom then zoom:= ZoomValue + end else if ZoomValue > zoom then - begin - zoom:= zoom + 0.002 * Lag; - if ZoomValue < zoom then zoom:= ZoomValue - end; + begin + zoom:= zoom + 0.002 * Lag; + if ZoomValue < zoom then zoom:= ZoomValue + end; // Sky glClear(GL_COLOR_BUFFER_BIT); @@ -460,25 +460,25 @@ // Attack bar if CurrentTeam <> nil then - case AttackBar of + case AttackBar of (* 1: begin - r:= StuffPoz[sPowerBar]; - {$WARNINGS OFF} - r.w:= (CurrentHedgehog^.Gear^.Power * 256) div cPowerDivisor; - {$WARNINGS ON} - DrawSpriteFromRect(r, cScreenWidth - 272, cScreenHeight - 48, 16, 0, Surface); - end;*) - 2: with CurrentHedgehog^ do - begin - tdx:= hwSign(Gear^.dX) * Sin(Gear^.Angle * Pi / cMaxAngle); - tdy:= - Cos(Gear^.Angle * Pi / cMaxAngle); - for i:= (Gear^.Power * 24) div cPowerDivisor downto 0 do - DrawSprite(sprPower, - hwRound(Gear^.X) + round(WorldDx + tdx * (24 + i * 2)) - 16, - hwRound(Gear^.Y) + round(WorldDy + tdy * (24 + i * 2)) - 12, - i) - end - end; + r:= StuffPoz[sPowerBar]; + {$WARNINGS OFF} + r.w:= (CurrentHedgehog^.Gear^.Power * 256) div cPowerDivisor; + {$WARNINGS ON} + DrawSpriteFromRect(r, cScreenWidth - 272, cScreenHeight - 48, 16, 0, Surface); + end;*) + 2: with CurrentHedgehog^ do + begin + tdx:= hwSign(Gear^.dX) * Sin(Gear^.Angle * Pi / cMaxAngle); + tdy:= - Cos(Gear^.Angle * Pi / cMaxAngle); + for i:= (Gear^.Power * 24) div cPowerDivisor downto 0 do + DrawSprite(sprPower, + hwRound(Gear^.X) + round(WorldDx + tdx * (24 + i * 2)) - 16, + hwRound(Gear^.Y) + round(WorldDy + tdy * (24 + i * 2)) - 12, + i) + end + end; DrawVisualGears(1); @@ -497,7 +497,7 @@ {$WARNINGS OFF} // Target if TargetPoint.X <> NoPointX then - DrawRotatedF(sprTargetP, TargetPoint.X + WorldDx, TargetPoint.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360); + DrawRotatedF(sprTargetP, TargetPoint.X + WorldDx, TargetPoint.Y + WorldDy, 0, 0, (RealTicks shr 3) mod 360); {$WARNINGS ON} {$IFDEF IPHONEOS} @@ -533,47 +533,47 @@ {$IFNDEF IPHONEOS} // Timetrial if ((TrainingFlags and tfTimeTrial) <> 0) and (TimeTrialStartTime > 0) then - begin - if TimeTrialStopTime = 0 then i:= RealTicks - TimeTrialStartTime else i:= TimeTrialStopTime - TimeTrialStartTime; - t:= 272; - // right frame - DrawSprite(sprFrame, -cScreenWidth div 2 + t, 8, 1); + begin + if TimeTrialStopTime = 0 then i:= RealTicks - TimeTrialStartTime else i:= TimeTrialStopTime - TimeTrialStartTime; + t:= 272; + // right frame + DrawSprite(sprFrame, -cScreenWidth div 2 + t, 8, 1); dec(t, 32); - // 1 ms + // 1 ms DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, i mod 10); dec(t, 32); - i:= i div 10; - // 10 ms + i:= i div 10; + // 10 ms DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, i mod 10); dec(t, 32); - i:= i div 10; - // 100 ms + i:= i div 10; + // 100 ms DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, i mod 10); - dec(t, 16); - // Point - DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, 11); + dec(t, 16); + // Point + DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, 11); dec(t, 32); - i:= i div 10; - // 1 s + i:= i div 10; + // 1 s DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, i mod 10); dec(t, 32); - i:= i div 10; - // 10s + i:= i div 10; + // 10s DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, i mod 6); - dec(t, 16); - // Point - DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, 10); + dec(t, 16); + // Point + DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, 10); dec(t, 32); - i:= i div 6; - // 1 m + i:= i div 6; + // 1 m DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, i mod 10); dec(t, 32); - i:= i div 10; - // 10 m + i:= i div 10; + // 10 m DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, i mod 10); - // left frame - DrawSprite(sprFrame, -cScreenWidth div 2 + t - 4, 8, 0); - end; + // left frame + DrawSprite(sprFrame, -cScreenWidth div 2 + t - 4, 8, 0); + end; {$ENDIF} // Captions @@ -584,19 +584,19 @@ else offset:= 8; {$ENDIF} - for grp:= Low(TCapGroup) to High(TCapGroup) do - with Captions[grp] do - if Tex <> nil then - begin - DrawCentered(0, offset, Tex); - inc(offset, Tex^.h + 2); - if EndTime <= RealTicks then - begin - FreeTexture(Tex); - Tex:= nil; - EndTime:= 0 - end; - end; + for grp:= Low(TCapGroup) to High(TCapGroup) do + with Captions[grp] do + if Tex <> nil then + begin + DrawCentered(0, offset, Tex); + inc(offset, Tex^.h + 2); + if EndTime <= RealTicks then + begin + FreeTexture(Tex); + Tex:= nil; + EndTime:= 0 + end; + end; // Teams Healths @@ -694,12 +694,12 @@ if isPaused then DrawCentered(0, (cScreenHeight shr 1), PauseTexture); if missionTimer <> 0 then - begin - if missionTimer > 0 then dec(missionTimer, Lag); - if missionTimer < 0 then missionTimer:= 0; // avoid subtracting below 0 - if missionTex <> nil then - DrawCentered(0, min((cScreenHeight shr 1) + 100, cScreenHeight - 48 - missionTex^.h), missionTex); - end; + begin + if missionTimer > 0 then dec(missionTimer, Lag); + if missionTimer < 0 then missionTimer:= 0; // avoid subtracting below 0 + if missionTex <> nil then + DrawCentered(0, min((cScreenHeight shr 1) + 100, cScreenHeight - 48 - missionTex^.h), missionTex); + end; // fps {$IFDEF IPHONEOS} @@ -762,7 +762,7 @@ end; if GameState = gsConfirm then - DrawCentered(0, cScreenHeight div 2, ConfirmTexture); + DrawCentered(0, cScreenHeight div 2, ConfirmTexture); SetScale(zoom); @@ -796,10 +796,10 @@ Captions[Group].Tex:= RenderStringTex(s, Color, fntBig); case Group of - capgrpGameState: Captions[Group].EndTime:= RealTicks + 2200 - else - Captions[Group].EndTime:= RealTicks + 1400 + LongWord(Captions[Group].Tex^.w) * 3; - end; + capgrpGameState: Captions[Group].EndTime:= RealTicks + 2200 + else + Captions[Group].EndTime:= RealTicks + 1400 + LongWord(Captions[Group].Tex^.w) * 3; + end; end; procedure MoveCamera; @@ -807,23 +807,23 @@ var EdgesDist, wdy: LongInt; begin if (not (CurrentTeam^.ExtDriven and isCursorVisible)) and cHasFocus then - begin - SDL_GetMouseState(@CursorPoint.X, @CursorPoint.Y); - CursorPoint.X:= CursorPoint.X - (cScreenWidth shr 1); - CursorPoint.Y:= cScreenHeight - CursorPoint.Y; - end; + begin + SDL_GetMouseState(@CursorPoint.X, @CursorPoint.Y); + CursorPoint.X:= CursorPoint.X - (cScreenWidth shr 1); + CursorPoint.Y:= cScreenHeight - CursorPoint.Y; + end; if (not PlacingHogs) and (FollowGear <> nil) and (not isCursorVisible) and (not fastUntilLag) then - if abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y) > 4 then - begin - FollowGear:= nil; - prevPoint:= CursorPoint; - exit - end - else begin - CursorPoint.x:= (prevPoint.x * 7 + hwRound(FollowGear^.X) + hwSign(FollowGear^.dX) * 100 + WorldDx) div 8; - CursorPoint.y:= (prevPoint.y * 7 + cScreenHeight - (hwRound(FollowGear^.Y) + WorldDy)) div 8; - end; + if abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y) > 4 then + begin + FollowGear:= nil; + prevPoint:= CursorPoint; + exit + end + else begin + CursorPoint.x:= (prevPoint.x * 7 + hwRound(FollowGear^.X) + hwSign(FollowGear^.dX) * 100 + WorldDx) div 8; + CursorPoint.y:= (prevPoint.y * 7 + cScreenHeight - (hwRound(FollowGear^.Y) + WorldDy)) div 8; + end; wdy:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine - cVisibleWater; if WorldDy < wdy then WorldDy:= wdy; @@ -831,24 +831,24 @@ if ((CursorPoint.X = prevPoint.X) and (CursorPoint.Y = prevpoint.Y)) then exit; if AMxShift < 210 then - begin - if CursorPoint.X < cScreenWidth div 2 + AMxShift - 175 then CursorPoint.X:= cScreenWidth div 2 + AMxShift - 175; - if CursorPoint.X > cScreenWidth div 2 + AMxShift - 10 then CursorPoint.X:= cScreenWidth div 2 + AMxShift - 10; - if CursorPoint.Y > 75 + SlotsNum * 33 then CursorPoint.Y:= 75 + SlotsNum * 33; - if CursorPoint.Y < 76 then CursorPoint.Y:= 76; - prevPoint:= CursorPoint; - if cHasFocus then SDL_WarpMouse(CursorPoint.X + cScreenWidth div 2, cScreenHeight - CursorPoint.Y); - exit - end; + begin + if CursorPoint.X < cScreenWidth div 2 + AMxShift - 175 then CursorPoint.X:= cScreenWidth div 2 + AMxShift - 175; + if CursorPoint.X > cScreenWidth div 2 + AMxShift - 10 then CursorPoint.X:= cScreenWidth div 2 + AMxShift - 10; + if CursorPoint.Y > 75 + SlotsNum * 33 then CursorPoint.Y:= 75 + SlotsNum * 33; + if CursorPoint.Y < 76 then CursorPoint.Y:= 76; + prevPoint:= CursorPoint; + if cHasFocus then SDL_WarpMouse(CursorPoint.X + cScreenWidth div 2, cScreenHeight - CursorPoint.Y); + exit + end; if isCursorVisible then - begin - if (not CurrentTeam^.ExtDriven) and (GameTicks >= PrevSentPointTime + cSendCursorPosTime) then - begin - SendIPCXY('P', CursorPoint.X - WorldDx, cScreenHeight - CursorPoint.Y - WorldDy); - PrevSentPointTime:= GameTicks - end; - end; + begin + if (not CurrentTeam^.ExtDriven) and (GameTicks >= PrevSentPointTime + cSendCursorPosTime) then + begin + SendIPCXY('P', CursorPoint.X - WorldDx, cScreenHeight - CursorPoint.Y - WorldDy); + PrevSentPointTime:= GameTicks + end; + end; if isCursorVisible or (FollowGear <> nil) then begin @@ -902,17 +902,17 @@ if missionTex <> nil then FreeTexture(missionTex); if icon > -1 then - begin - r.x:= 0; - r.y:= icon * 32; - missionTex:= RenderHelpWindow(caption, subcaption, text, '', 0, MissionIcons, @r) - end + begin + r.x:= 0; + r.y:= icon * 32; + missionTex:= RenderHelpWindow(caption, subcaption, text, '', 0, MissionIcons, @r) + end else - begin - r.x:= ((-icon - 1) shr 5) * 32; - r.y:= ((-icon - 1) mod 32) * 32; - missionTex:= RenderHelpWindow(caption, subcaption, text, '', 0, SpritesData[sprAMAmmos].Surface, @r) - end; + begin + r.x:= ((-icon - 1) shr 5) * 32; + r.y:= ((-icon - 1) mod 32) * 32; + missionTex:= RenderHelpWindow(caption, subcaption, text, '', 0, SpritesData[sprAMAmmos].Surface, @r) + end; end; procedure HideMission; @@ -922,24 +922,24 @@ procedure init_uWorld; begin - fpsTexture:= nil; - FollowGear:= nil; - WindBarWidth:= 0; - bShowAmmoMenu:= false; - bSelected:= false; - bShowFinger:= false; - Frames:= 0; - WorldDx:= -512; - WorldDy:= -256; + fpsTexture:= nil; + FollowGear:= nil; + WindBarWidth:= 0; + bShowAmmoMenu:= false; + bSelected:= false; + bShowFinger:= false; + Frames:= 0; + WorldDx:= -512; + WorldDy:= -256; - FPS:= 0; - CountTicks:= 0; - SoundTimerTicks:= 0; - prevPoint.X:= 0; - prevPoint.Y:= 0; - missionTimer:= 0; - - FillChar(Captions, sizeof(Captions), 0) + FPS:= 0; + CountTicks:= 0; + SoundTimerTicks:= 0; + prevPoint.X:= 0; + prevPoint.Y:= 0; + missionTimer:= 0; + + FillChar(Captions, sizeof(Captions), 0) end; procedure free_uWorld;