--- a/CMakeLists.txt Sat Jul 31 10:52:43 2010 +0200
+++ b/CMakeLists.txt Sat Jul 31 11:24:53 2010 +0200
@@ -11,10 +11,10 @@
set(version_suffix "-dev") #UNSET THIS VARIABLE AT RELEASE TIME
IF(version_suffix MATCHES "-dev")
set(HW_DEV true)
- IF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.hg)
+ IF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.hg)
FIND_PROGRAM(HGCOMMAND hg)
IF(HGCOMMAND)
- exec_program(${HGCOMMAND}
+ exec_program(${HGCOMMAND}
ARGS identify -in ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE version_suffix
)
@@ -55,16 +55,16 @@
if(APPLE)
set(CMAKE_FIND_FRAMEWORK "FIRST")
-
+
#paths for creating the bundle
set(bundle_name Hedgewars.app)
- set(CMAKE_INSTALL_PREFIX ${bundle_name}/Contents/MacOS/)
+ set(CMAKE_INSTALL_PREFIX ${bundle_name}/Contents/MacOS/)
set(DATA_INSTALL_DIR "../Resources/")
set(target_dir ".")
-
+
#what system are we building for
set(minimum_macosx $ENV{MACOSX_DEPLOYMENT_TARGET})
-
+
#detect on which system are we
EXEC_PROGRAM("/usr/bin/sw_vers" OUTPUT_VARIABLE MACOSX_VERSION_TMP)
STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" MACOSX_VERSION_TMP "${MACOSX_VERSION_TMP}")
@@ -97,9 +97,9 @@
if(current_macosx_version MATCHES "10.6")
set(CMAKE_OSX_ARCHITECTURES "x86_64")
endif()
- ENDIF()
+ ENDIF()
- message(STATUS "Target system: Mac OS X ${minimum_macosx} ${CMAKE_OSX_ARCHITECTURES}")
+ message(STATUS "Target system: Mac OS X ${minimum_macosx} ${CMAKE_OSX_ARCHITECTURES}")
if(minimum_macosx MATCHES "10.4")
set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk/")
@@ -132,10 +132,10 @@
endif (NOT CMAKE_BUILD_TYPE)
if(CMAKE_BUILD_TYPE MATCHES RELEASE OR CMAKE_BUILD_TYPE MATCHES "Release")
- message(STATUS "Building Release")
+ message(STATUS "Building Release")
set(Optz true)
else()
- message(STATUS "Building Debug")
+ message(STATUS "Building Debug")
#set(CMAKE_VERBOSE_MAKEFILE true)
set(Optz false)
endif()
@@ -205,7 +205,7 @@
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Hedgewars ${HEDGEWARS_VERSION}")
if(WIN32 AND NOT UNIX)
- set(CPACK_NSIS_DISPLAY_NAME ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
+ set(CPACK_NSIS_DISPLAY_NAME ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
set(CPACK_NSIS_HELP_LINK "http://www.hedgewars.org/")
set(CPACK_NSIS_URL_INFO_ABOUT "http://www.hedgewars.org/")
set(CPACK_NSIS_CONTACT "unC0Rr@gmail.com")
--- a/QTfrontend/CMakeLists.txt Sat Jul 31 10:52:43 2010 +0200
+++ b/QTfrontend/CMakeLists.txt Sat Jul 31 11:24:53 2010 +0200
@@ -182,7 +182,7 @@
)
-set( HW_LINK_LIBS
+set( HW_LINK_LIBS
${QT_LIBRARIES}
${SDL_LIBRARY}
${SDLMIXER_LIBRARY}
@@ -194,7 +194,7 @@
set(HW_LINK_LIBS ${HW_LINK_LIBS} SDL)
endif()
- set( HW_LINK_LIBS
+ set( HW_LINK_LIBS
${HW_LINK_LIBS}
ole32
oleaut32
--- a/QTfrontend/CocoaInitializer.mm Sat Jul 31 10:52:43 2010 +0200
+++ b/QTfrontend/CocoaInitializer.mm Sat Jul 31 11:24:53 2010 +0200
@@ -8,7 +8,7 @@
#include <Cocoa/Cocoa.h>
#include <QtDebug>
-class CocoaInitializer::Private
+class CocoaInitializer::Private
{
public:
NSAutoreleasePool* autoReleasePool_;
--- a/QTfrontend/InstallController.cpp Sat Jul 31 10:52:43 2010 +0200
+++ b/QTfrontend/InstallController.cpp Sat Jul 31 11:24:53 2010 +0200
@@ -1,6 +1,6 @@
/*
* InstallController.cpp
- *
+ *
*
* Created by Vittorio on 28/09/09.
* Copyright 2009 __MyCompanyName__. All rights reserved.
--- a/QTfrontend/InstallController.h Sat Jul 31 10:52:43 2010 +0200
+++ b/QTfrontend/InstallController.h Sat Jul 31 11:24:53 2010 +0200
@@ -1,6 +1,6 @@
/*
* InstallController.h
- *
+ *
*
* Created by Vittorio on 28/09/09.
* Copyright 2009 __MyCompanyName__. All rights reserved.
@@ -14,8 +14,8 @@
{
public:
virtual ~InstallController();
-
+
virtual void showInstallController() = 0;
};
-#endif
\ No newline at end of file
+#endif
--- a/QTfrontend/M3InstallController.h Sat Jul 31 10:52:43 2010 +0200
+++ b/QTfrontend/M3InstallController.h Sat Jul 31 11:24:53 2010 +0200
@@ -1,10 +1,10 @@
/*****************************************************************
M3InstallController.m
-
+
Created by Martin Pilkington on 02/06/2007.
-
+
Copyright (c) 2006-2009 M Cubed Software
-
+
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
@@ -13,10 +13,10 @@
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
-
+
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -25,7 +25,7 @@
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
-
+
*****************************************************************/
#import <Cocoa/Cocoa.h>
--- a/QTfrontend/M3InstallController.m Sat Jul 31 10:52:43 2010 +0200
+++ b/QTfrontend/M3InstallController.m Sat Jul 31 11:24:53 2010 +0200
@@ -1,10 +1,10 @@
/*****************************************************************
M3InstallController.m
-
+
Created by Martin Pilkington on 02/06/2007.
-
+
Copyright (c) 2006-2009 M Cubed Software
-
+
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
@@ -13,10 +13,10 @@
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
-
+
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -25,7 +25,7 @@
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
-
+
*****************************************************************/
#import "M3InstallController.h"
@@ -40,7 +40,7 @@
NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"];
NSString *title = [NSString stringWithFormat:NSLocalizedString(@"%@ is currently running from a disk image", @"AppName is currently running from a disk image"), appName];
NSString *body = [NSString stringWithFormat:NSLocalizedString(@"Would you like to install %@ in your applications folder before quitting?", @"Would you like to install App Name in your applications folder before quitting?"), appName];
- alert = [[NSAlert alertWithMessageText:title
+ alert = [[NSAlert alertWithMessageText:title
defaultButton:NSLocalizedString(@"Install", @"Install")
alternateButton:NSLocalizedString(@"Don't Install", @"Don't Install")
otherButton:nil
@@ -67,16 +67,16 @@
NSString *appsPath = [[NSString stringWithString:@"/Applications"] stringByAppendingPathComponent:[[[NSBundle mainBundle] bundlePath] lastPathComponent]];
NSString *userAppsPath = [[[NSString stringWithString:@"~/Applications"] stringByAppendingPathComponent:[[[NSBundle mainBundle] bundlePath] lastPathComponent]] stringByExpandingTildeInPath];
NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"];
-
+
//Delete the app that is installed
if ([[NSFileManager defaultManager] fileExistsAtPath:appsPath]) {
[[NSFileManager defaultManager] removeFileAtPath:appsPath handler:nil];
}
//Delete the app that is installed
- if ([[NSFileManager defaultManager] copyPath:[[NSBundle mainBundle] bundlePath] toPath:appsPath
+ if ([[NSFileManager defaultManager] copyPath:[[NSBundle mainBundle] bundlePath] toPath:appsPath
handler:nil]) {
- NSRunAlertPanel([NSString stringWithFormat:NSLocalizedString(@"%@ installed successfully", @"App Name installed successfully"), appName],
- [NSString stringWithFormat:NSLocalizedString(@"%@ was installed in /Applications", @"App Name was installed in /Applications"), appName],
+ NSRunAlertPanel([NSString stringWithFormat:NSLocalizedString(@"%@ installed successfully", @"App Name installed successfully"), appName],
+ [NSString stringWithFormat:NSLocalizedString(@"%@ was installed in /Applications", @"App Name was installed in /Applications"), appName],
NSLocalizedString(@"Quit", @"Quit"), nil, nil);
} else {
if ([[NSFileManager defaultManager] fileExistsAtPath:userAppsPath]) {
@@ -84,11 +84,11 @@
}
if ([[NSFileManager defaultManager] copyPath:[[NSBundle mainBundle] bundlePath] toPath:userAppsPath
handler:nil]) {
- NSRunAlertPanel([NSString stringWithFormat:NSLocalizedString(@"%@ installed successfully", @"AppName installed successfully"), appName],
- [NSString stringWithFormat:NSLocalizedString(@"%@ was installed in %@", @"App Name was installed in %@"), appName, [[NSString stringWithString:@"~/Applications"] stringByExpandingTildeInPath]],
+ NSRunAlertPanel([NSString stringWithFormat:NSLocalizedString(@"%@ installed successfully", @"AppName installed successfully"), appName],
+ [NSString stringWithFormat:NSLocalizedString(@"%@ was installed in %@", @"App Name was installed in %@"), appName, [[NSString stringWithString:@"~/Applications"] stringByExpandingTildeInPath]],
NSLocalizedString(@"Quit", @"Quit"), nil, nil);
} else {
- NSRunAlertPanel([NSString stringWithFormat:NSLocalizedString(@"Could not install %@", @"Could not install App Name"), appName],
+ NSRunAlertPanel([NSString stringWithFormat:NSLocalizedString(@"Could not install %@", @"Could not install App Name"), appName],
NSLocalizedString(@"An error occurred when installing", @"An error occurred when installing"), NSLocalizedString(@"Quit", @"Quit"), nil, nil);
}
}
--- a/QTfrontend/M3Panel.h Sat Jul 31 10:52:43 2010 +0200
+++ b/QTfrontend/M3Panel.h Sat Jul 31 11:24:53 2010 +0200
@@ -1,6 +1,6 @@
/*
* M3Panel.h
- *
+ *
*
* Created by Vittorio on 28/09/09.
* Copyright 2009 __MyCompanyName__. All rights reserved.
@@ -17,9 +17,9 @@
public:
M3Panel(void);
~M3Panel();
-
+
void showInstallController();
-
+
private:
class Private;
Private* c;
--- a/QTfrontend/M3Panel.mm Sat Jul 31 10:52:43 2010 +0200
+++ b/QTfrontend/M3Panel.mm Sat Jul 31 11:24:53 2010 +0200
@@ -1,6 +1,6 @@
/*
* M3Panel.cpp
- *
+ *
*
* Created by Vittorio on 28/09/09.
* Copyright 2009 __MyCompanyName__. All rights reserved.
@@ -21,10 +21,10 @@
M3Panel::M3Panel(void)
{
c = new Private;
-
+
c->install = [[M3InstallController alloc] init];
[c->install retain];
-
+
}
M3Panel::~M3Panel()
--- a/QTfrontend/NSWorkspace_RBAdditions.m Sat Jul 31 10:52:43 2010 +0200
+++ b/QTfrontend/NSWorkspace_RBAdditions.m Sat Jul 31 11:24:53 2010 +0200
@@ -107,7 +107,7 @@
}
NSString* cls = [(NSString*)IOObjectCopyClass(nextParent) autorelease];
if (![cls isEqualToString:@"IOPCIDevice"]) {
-
+
// Uncomment the following line to have the device tree dumped to the console.
// NSLog(@"=================================> %@:%@\n",cls,props);
@@ -207,7 +207,7 @@
}
}
//Don't need this for disk images, gets around warnings for some deprecated functions
-
+
/* else {
// For a network volume, get the volume reference number and use to get the server URL.
FSRef ref;
--- a/QTfrontend/SDLs.cpp Sat Jul 31 10:52:43 2010 +0200
+++ b/QTfrontend/SDLs.cpp Sat Jul 31 11:24:53 2010 +0200
@@ -35,7 +35,7 @@
{
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK);
-
+
musicInitialized = 0;
music = NULL;
if(SDL_NumJoysticks())
@@ -86,7 +86,7 @@
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");
@@ -102,7 +102,7 @@
{
// 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());
@@ -119,33 +119,33 @@
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][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][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][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][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][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';
@@ -167,7 +167,7 @@
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);
--- a/QTfrontend/SDLs.h Sat Jul 31 10:52:43 2010 +0200
+++ b/QTfrontend/SDLs.h Sat Jul 31 11:24:53 2010 +0200
@@ -32,7 +32,7 @@
private:
Mix_Music *music;
- int musicInitialized;
+ int musicInitialized;
public:
SDLInteraction();
@@ -41,7 +41,7 @@
void addGameControllerKeys() const;
void StartMusic();
void StopMusic();
- void SDLMusicInit();
+ void SDLMusicInit();
};
--- a/QTfrontend/chatwidget.cpp Sat Jul 31 10:52:43 2010 +0200
+++ b/QTfrontend/chatwidget.cpp Sat Jul 31 11:24:53 2010 +0200
@@ -106,7 +106,7 @@
chatNicks->insertAction(0, acFollow);
chatNicks->insertAction(0, acIgnore);
chatNicks->insertAction(0, acFriend);
-
+
showReady = false;
}
@@ -209,7 +209,7 @@
QString color("");
bool isFriend = friendsList.contains(parts[0], Qt::CaseInsensitive);
-
+
if (str.startsWith("\x03"))
color = QString("#c0c0c0");
else if (str.startsWith("\x02"))
--- a/QTfrontend/gamecfgwidget.cpp Sat Jul 31 10:52:43 2010 +0200
+++ b/QTfrontend/gamecfgwidget.cpp Sat Jul 31 11:24:53 2010 +0200
@@ -53,7 +53,7 @@
GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Game scheme"), GBoxOptions), 0, 0);
QPixmap pmEdit(":/res/edit.png");
-
+
QPushButton * goToSchemePage = new QPushButton(GBoxOptions);
goToSchemePage->setToolTip(tr("Edit schemes"));
goToSchemePage->setIconSize(pmEdit.size());
--- a/QTfrontend/hwform.cpp Sat Jul 31 10:52:43 2010 +0200
+++ b/QTfrontend/hwform.cpp Sat Jul 31 11:24:53 2010 +0200
@@ -85,7 +85,7 @@
setMinimumSize(760, 580);
CustomizePalettes();
-
+
ui.pageOptions->CBResolution->addItems(sdli.getResolutions());
config = new GameUIConfig(this, cfgdir->absolutePath() + "/hedgewars.ini");
@@ -100,7 +100,7 @@
updater = new SparkleAutoUpdater(SPARKLE_APPCAST_URL);
if(updater && config->isAutoUpdateEnabled())
updater->checkForUpdates();
-#endif
+#endif
#endif
UpdateTeamsLists();
--- a/QTfrontend/hwform.h Sat Jul 31 10:52:43 2010 +0200
+++ b/QTfrontend/hwform.h Sat Jul 31 11:24:53 2010 +0200
@@ -155,11 +155,11 @@
QStack<quint8> PagesStack;
QTime eggTimer;
BGWidget * wBackground;
-
+
#ifdef __APPLE__
InstallController * panel;
#endif
-
+
void OnPageShown(quint8 id, quint8 lastid=0);
};
--- a/QTfrontend/main.cpp Sat Jul 31 10:52:43 2010 +0200
+++ b/QTfrontend/main.cpp Sat Jul 31 11:24:53 2010 +0200
@@ -47,7 +47,7 @@
return true;
}
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[]) {
QApplication app(argc, argv);
QStringList arguments = app.arguments();
--- a/QTfrontend/newnetclient.cpp Sat Jul 31 10:52:43 2010 +0200
+++ b/QTfrontend/newnetclient.cpp Sat Jul 31 11:24:53 2010 +0200
@@ -305,7 +305,7 @@
if(tmp[0] == "MOTD_NEW") emit serverMessageNew(tmp[1]);
else if(tmp[0] == "MOTD_OLD") emit serverMessageOld(tmp[1]);
else if(tmp[0] == "LATEST_PROTO") emit latestProtocolVar(tmp[1].toInt());
-
+
tmp.removeFirst();
tmp.removeFirst();
}
@@ -472,13 +472,13 @@
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 below\nor pick another nickname in game config:").arg(mynick), QLineEdit::Password, passLength==0?NULL:QString(passLength,'\0'), &ok);
-
+
if (!ok) {
Disconnect();
emit Disconnected();
return;
}
-
+
if (!passLength || password!=QString(passLength, '\0')) {
hash = QCryptographicHash::hash(password.toLatin1(), QCryptographicHash::Md5).toHex();
config->setValue("net/passwordhash", hash);
@@ -750,5 +750,5 @@
void HWNewNet::askServerVars()
{
- RawSendNet(QString("GET_SERVER_VAR"));
+ RawSendNet(QString("GET_SERVER_VAR"));
}
--- a/QTfrontend/newnetclient.h Sat Jul 31 10:52:43 2010 +0200
+++ b/QTfrontend/newnetclient.h Sat Jul 31 11:24:53 2010 +0200
@@ -48,7 +48,7 @@
QString getNick();
QString getRoom();
QString getHost();
-
+
private:
GameUIConfig* config;
GameCFGWidget* m_pGameCFGWidget;
--- a/QTfrontend/pages.cpp Sat Jul 31 10:52:43 2010 +0200
+++ b/QTfrontend/pages.cpp Sat Jul 31 11:24:53 2010 +0200
@@ -119,7 +119,7 @@
Tips << tr("You should never install Hedgewars on computers you don't own (school, university, work, etc.). Please ask the responsible person instead!", "Tips");
Tips << tr("Hedgewars can be perfect for short games during breaks. Just ensure you don't add too many hedgehogs or use an huge map. Reducing time and health might help as well.", "Tips");
Tips << tr("No hedgehogs were harmed in making this game.", "Tips");
-
+
if(isDevBuild)
mainNote->setText(QLabel::tr("This development build is 'work in progress' and may not be compatible with other versions of the game. Some features might be broken or incomplete. Use at your own risk!"));
@@ -369,7 +369,7 @@
Mix_Chunk *sound;
QDir tmpdir;
mySdli->SDLMusicInit();
-
+
tmpdir.cd(datadir->absolutePath());
tmpdir.cd("Sounds/voices");
tmpdir.cd(CBVoicepack->currentText());
@@ -947,7 +947,7 @@
CBSelect->addItems(tmpdir.entryList(QStringList("*.lua")).replaceInStrings(QRegExp("^(.*)\\.lua"), "\\1"));
pageLayout->addWidget(CBSelect, 1, 1);
-
+
BtnStartTrain = new QPushButton(this);
BtnStartTrain->setFont(*font14);
BtnStartTrain->setText(QPushButton::tr("Go!"));
@@ -1063,7 +1063,7 @@
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"))
{
@@ -1102,13 +1102,13 @@
else
{
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)));
}
-
+
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
item->setToolTip(tr("Games may be played on precreated or randomized maps."));
roomsList->setItem(r, 4, item);
@@ -1506,7 +1506,7 @@
// 0
pbAsk = addButton(tr("Fetch data"), pageLayout, 0, 0, 1, 3);
connect(pbAsk, SIGNAL(clicked()), this, SIGNAL(askServerVars()));
-
+
// 1
QLabel * lblSMN = new QLabel(this);
lblSMN->setText(tr("Server message for latest version:"));
@@ -1540,10 +1540,10 @@
pageLayout->addWidget(tb, 4, 1, 1, 2);
connect(leServerMessageNew, SIGNAL(textEdited(const QString &)), tb, SLOT(setHtml(const QString &)));
connect(leServerMessageOld, SIGNAL(textEdited(const QString &)), tb, SLOT(setHtml(const QString &)));
-
+
// 5
pbClearAccountsCache = addButton(tr("Clear Accounts Cache"), pageLayout, 5, 0);
-
+
// 6
pbSetSM = addButton(tr("Set data"), pageLayout, 6, 0, 1, 3);
--- a/QTfrontend/selectWeapon.cpp Sat Jul 31 10:52:43 2010 +0200
+++ b/QTfrontend/selectWeapon.cpp Sat Jul 31 11:24:53 2010 +0200
@@ -131,11 +131,11 @@
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);
--- a/QTfrontend/tcpBase.cpp Sat Jul 31 10:52:43 2010 +0200
+++ b/QTfrontend/tcpBase.cpp Sat Jul 31 11:24:53 2010 +0200
@@ -72,7 +72,7 @@
process = new QProcess;
connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(StartProcessError(QProcess::ProcessError)));
QStringList arguments=setArguments();
-
+
// redirect everything written on stdout/stderr
if(isDevBuild)
process->setProcessChannelMode(QProcess::ForwardedChannels);
--- a/QTfrontend/team.cpp Sat Jul 31 10:52:43 2010 +0200
+++ b/QTfrontend/team.cpp Sat Jul 31 11:24:53 2010 +0200
@@ -73,7 +73,7 @@
Hedgehogs[i].Hat=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 (Hedgehogs[i].Hat.length() == 0) Hedgehogs[i].Hat = "NoHat";
+ if (Hedgehogs[i].Hat.length() == 0) Hedgehogs[i].Hat = "NoHat";
}
Rounds = 0;
Wins = 0;
--- a/QTfrontend/xfire.cpp Sat Jul 31 10:52:43 2010 +0200
+++ b/QTfrontend/xfire.cpp Sat Jul 31 11:24:53 2010 +0200
@@ -34,10 +34,10 @@
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];
@@ -45,7 +45,7 @@
strcpy(keys[i], "");
strcpy(values[i], "");
}
-
+
strcpy(keys[XFIRE_NICKNAME], "Nickname");
strcpy(keys[XFIRE_ROOM], "Room");
strcpy(keys[XFIRE_SERVER], "Server");
@@ -58,7 +58,7 @@
{
if(!use_xfire)
return;
-
+
for(int i = 0; i < XFIRE_KEY_COUNT; i++)
{
delete [] keys[i];
--- a/hedgewars/CMakeLists.txt Sat Jul 31 10:52:43 2010 +0200
+++ b/hedgewars/CMakeLists.txt Sat Jul 31 11:24:53 2010 +0200
@@ -31,7 +31,7 @@
endif()
endif()
-#SOURCE AND PROGRAMS SECTION
+#SOURCE AND PROGRAMS SECTION
set(fpc_tryexe fpc)
set(hwengine_project ${hedgewars_SOURCE_DIR}/hedgewars/hwengine.pas)
--- a/hedgewars/PascalExports.pas Sat Jul 31 10:52:43 2010 +0200
+++ b/hedgewars/PascalExports.pas Sat Jul 31 11:24:53 2010 +0200
@@ -190,7 +190,7 @@
CurAmmo:= CurrentHedgehog^.CurAmmo;
// this most likely won't work in network game
if (CurrentHedgehog^.Ammo^[CurSlot, CurAmmo].AmmoType = amPiano) then
- case snd of
+ case snd of
0: PlaySound(sndPiano0);
1: PlaySound(sndPiano1);
2: PlaySound(sndPiano2);
@@ -227,7 +227,7 @@
function HW_isWeaponSwitch: boolean cdecl; export;
begin
if CurAmmoGear <> nil then
- exit(CurAmmoGear^.AmmoType = amSwitch)
+ exit(CurAmmoGear^.AmmoType = amSwitch)
else
exit(false)
end;
--- a/hedgewars/SDLMain.m Sat Jul 31 10:52:43 2010 +0200
+++ b/hedgewars/SDLMain.m Sat Jul 31 11:24:53 2010 +0200
@@ -50,7 +50,7 @@
dict = (const NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
if (dict)
appName = [dict objectForKey: @"CFBundleName"];
-
+
if (![appName length])
appName = [[NSProcessInfo processInfo] processName];
@@ -131,10 +131,10 @@
NSMenuItem *menuItem;
NSString *title;
NSString *appName;
-
+
appName = getApplicationName();
appleMenu = [[NSMenu alloc] initWithTitle:@""];
-
+
/* Add menu items */
title = [@"About " stringByAppendingString:appName];
[appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
@@ -154,7 +154,7 @@
title = [@"Quit " stringByAppendingString:appName];
[appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
-
+
/* Put menu into the menubar */
menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
[menuItem setSubmenu:appleMenu];
@@ -176,17 +176,17 @@
NSMenuItem *menuItem;
windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
-
+
/* "Minimize" item */
menuItem = [[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
[windowMenu addItem:menuItem];
[menuItem release];
-
+
/* Put menu into the menubar */
windowMenuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
[windowMenuItem setSubmenu:windowMenu];
[[NSApp mainMenu] addItem:windowMenuItem];
-
+
/* Tell the application object that this is now the window menu */
[NSApp setWindowsMenu:windowMenu];
@@ -203,7 +203,7 @@
/* Ensure the application object is initialised */
[SDLApplication sharedApplication];
-
+
#ifdef SDL_USE_CPS
{
CPSProcessSerNum PSN;
@@ -223,10 +223,10 @@
/* Create SDLMain and make it the app delegate */
sdlMain = [[SDLMain alloc] init];
[NSApp setDelegate:sdlMain];
-
+
/* Start the main event loop */
[NSApp run];
-
+
[sdlMain release];
[pool release];
}
@@ -319,27 +319,27 @@
bufferSize = selfLen + aStringLen - aRange.length;
buffer = (unichar *)NSAllocateMemoryPages(bufferSize*sizeof(unichar));
-
+
/* Get first part into buffer */
localRange.location = 0;
localRange.length = aRange.location;
[self getCharacters:buffer range:localRange];
-
+
/* Get middle part into buffer */
localRange.location = 0;
localRange.length = aStringLen;
[aString getCharacters:(buffer+aRange.location) range:localRange];
-
+
/* Get last part into buffer */
localRange.location = aRange.location + aRange.length;
localRange.length = selfLen - localRange.location;
[self getCharacters:(buffer+aRange.location+aStringLen) range:localRange];
-
+
/* Build output string */
result = [NSString stringWithCharacters:buffer length:bufferSize];
-
+
NSDeallocateMemoryPages(buffer, bufferSize);
-
+
return result;
}
--- a/hedgewars/SDLh.pas Sat Jul 31 10:52:43 2010 +0200
+++ b/hedgewars/SDLh.pas Sat Jul 31 11:24:53 2010 +0200
@@ -96,7 +96,7 @@
SDL_SWSURFACE = $00000000;
SDL_HWSURFACE = $00000001;
SDL_SRCALPHA = $00010000;
-
+
SDL_INIT_TIMER = $00000001;
SDL_INIT_AUDIO = $00000010;
SDL_INIT_VIDEO = $00000020;
@@ -156,7 +156,7 @@
SDL_VIDEORESIZE = 16; // TODO: outdated? no longer in SDL 1.3?
{$ENDIF}
{*end SDL_Event binding*}
-
+
{$IFDEF SDL13}
SDL_ASYNCBLIT = $08000000;
SDL_ANYFORMAT = $10000000;
@@ -209,12 +209,12 @@
SDL_WINDOW_INPUT_FOCUS = $00000200; //*< window has input focus */
SDL_WINDOW_MOUSE_FOCUS = $00000400; //*< window has mouse focus */
SDL_WINDOW_FOREIGN = $00000800; //*< window not created by SDL */
-
+
// SDL_WindowEventID (enum)
SDL_WINDOWEVENT_NONE = 0; //*< Never used
SDL_WINDOWEVENT_SHOWN = 1; //*< Window has been shown
SDL_WINDOWEVENT_HIDDEN = 2; //*< Window has been hidden
- SDL_WINDOWEVENT_EXPOSED = 3; //*< Window has been exposed and should be redrawn
+ SDL_WINDOWEVENT_EXPOSED = 3; //*< Window has been exposed and should be redrawn
SDL_WINDOWEVENT_MOVED = 4; //*< Window has been moved to data1, data2
SDL_WINDOWEVENT_RESIZED = 5; //*< Window size changed to data1xdata2
SDL_WINDOWEVENT_MINIMIZED = 6; //*< Window has been minimized
@@ -233,7 +233,7 @@
MIX_INIT_MOD = $00000002;
MIX_INIT_MP3 = $00000004;
MIX_INIT_OGG = $00000008;
-
+
{* SDL_TTF *}
TTF_STYLE_NORMAL = 0;
TTF_STYLE_BOLD = 1;
@@ -259,7 +259,7 @@
/////////////////////// TYPE DEFINITIONS ///////////////////////
/////////////////////////////////////////////////////////////////
-type
+type
PSDL_Rect = ^TSDL_Rect;
TSDL_Rect = record
{$IFDEF SDL13}
@@ -357,9 +357,9 @@
{* SDL_Event type definition *}
{$IFDEF SDL13}
- PSDL_Window = pointer;
+ PSDL_Window = pointer;
PSDL_Texture = pointer;
-
+
TSDL_WindowEvent = record
type_: LongInt;
windowID: LongInt;
@@ -367,7 +367,7 @@
padding1, padding2, padding3: byte;
data1, data2: LongInt;
end;
-
+
TSDL_KeySym = record
scancode,
sym,
@@ -407,7 +407,7 @@
padding1, padding2: byte;
x, y, z, xrel, yrel : LongInt;
pressure, pressure_max, pressure_min,
- rotation, tilt, cursor: LongInt;
+ rotation, tilt, cursor: LongInt;
{$ELSE}
type_: byte;
x, y, xrel, yrel : word;
@@ -450,7 +450,7 @@
x, y: LongInt;
padding1, padding2, padding3: byte;
end;
-
+
// implement SDL_ProximityEvent
{$ENDIF}
@@ -466,9 +466,9 @@
value: LongInt;
{$ELSE}
value: word;
-{$ENDIF}
+{$ENDIF}
end;
-
+
TSDL_JoyBallEvent = record
which: Byte;
ball: Byte;
@@ -491,7 +491,7 @@
hat: Byte;
value: Byte;
end;
-
+
TSDL_JoyButtonEvent = record
{$IFDEF SDL13}
type_: LongInt;
@@ -586,7 +586,7 @@
);
{$IFDEF SDL13}
- TSDL_ArrayByteOrder = ( // array component order, low byte -> high byte
+ TSDL_ArrayByteOrder = ( // array component order, low byte -> high byte
SDL_ARRAYORDER_NONE,
SDL_ARRAYORDER_RGB,
SDL_ARRAYORDER_RGBA,
@@ -702,8 +702,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_DestroyRenderer(window: PSDL_Window): LongInt; cdecl; external SDLLibName;
function SDL_DestroyWindow(window: PSDL_Window): LongInt; cdecl; external SDLLibName;
--- a/hedgewars/adler32.pas Sat Jul 31 10:52:43 2010 +0200
+++ b/hedgewars/adler32.pas Sat Jul 31 11:24:53 2010 +0200
@@ -75,7 +75,7 @@
procedure Adler32Update(var adler: longint; Msg: pointer; Len: longint);
//-update Adler32 with Msg data
const
- BASE = 65521; // max. prime < 65536
+ BASE = 65521; // max. prime < 65536
NMAX = 5552; // max. n with 255n(n+1)/2 + (n+1)(BASE-1) < 2^32
type
LH = packed record
--- a/hedgewars/hwengine.pas Sat Jul 31 10:52:43 2010 +0200
+++ b/hedgewars/hwengine.pas Sat Jul 31 11:24:53 2010 +0200
@@ -29,9 +29,9 @@
program hwengine;
{$ENDIF}
-uses SDLh, uMisc, uConsole, uGame, uConsts, uLand, uAmmos, uVisualGears, uGears, uStore, uWorld, uKeys, uSound,
+uses SDLh, uMisc, uConsole, uGame, uConsts, uLand, uAmmos, uVisualGears, uGears, uStore, uWorld, uKeys, uSound,
uScript, uTeams, uStats, uIO, uLocale, uChat, uAI, uAIMisc, uRandom, uLandTexture, uCollisions, sysutils;
-
+
var isTerminated: boolean = false;
alsoShutdownFrontend: boolean = false;
@@ -137,7 +137,7 @@
end;
///////////////////
-procedure MainLoop;
+procedure MainLoop;
var PrevTime, CurrTime: Longword;
event: TSDL_Event;
begin
@@ -181,7 +181,7 @@
begin
DoTimer(CurrTime - PrevTime);
PrevTime:= CurrTime
- end
+ end
else SDL_Delay(1);
IPCCheckSock();
end;
@@ -229,7 +229,7 @@
val(gameArgs[6], cScreenHeight);
val(gameArgs[7], cScreenWidth);
recordFileName:= gameArgs[8];
-
+
val(gameArgs[9], cReducedQuality);
{$ENDIF}
@@ -243,7 +243,7 @@
for p:= Succ(Low(TPathType)) to High(TPathType) do
if p <> ptMapCurrent then Pathz[p]:= PathPrefix + '/' + Pathz[p];
-
+
WriteToConsole('Init SDL... ');
SDLTry(SDL_Init(SDL_INIT_VIDEO) >= 0, true);
WriteLnToConsole(msgOK);
@@ -276,7 +276,7 @@
if cLocaleFName <> 'en.txt' then
begin
// Try two letter locale first before trying specific locale overrides
- if (Length(cLocaleFName) > 6) and (Copy(cLocaleFName,1,2)+'.txt' <> 'en.txt') then
+ if (Length(cLocaleFName) > 6) and (Copy(cLocaleFName,1,2)+'.txt' <> 'en.txt') then
LoadLocale(Pathz[ptLocale] + '/' + Copy(cLocaleFName,1,2)+'.txt');
LoadLocale(Pathz[ptLocale] + '/' + cLocaleFName);
end;
@@ -321,7 +321,7 @@
uLand.initModule;
uIO.initModule;
-
+
if complete then
begin
uAI.initModule;
@@ -340,7 +340,7 @@
//uLandTemplates does not need initialization
uLandTexture.initModule;
//uLocale does not need initialization
- uRandom.initModule;
+ uRandom.initModule;
uScript.initModule;
uSound.initModule;
uStats.initModule;
@@ -380,7 +380,7 @@
//uAIActions does not need to be freed
uAI.freeModule; //stub
end;
-
+
uIO.freeModule; //stub
uLand.freeModule;
@@ -461,7 +461,7 @@
if GameType = gmtLandPreview then GenLandPreview()
else if GameType = gmtSyntax then DisplayUsage()
else Game();
-
+
if GameType = gmtSyntax then
ExitCode:= 1
else
--- a/hedgewars/options.inc Sat Jul 31 10:52:43 2010 +0200
+++ b/hedgewars/options.inc Sat Jul 31 11:24:53 2010 +0200
@@ -25,7 +25,7 @@
{$MODE OBJFPC}
{$MACRO ON}
-{$DEFINE GLunit:=GL,GLext}
+{$DEFINE GLunit:=GL,GLext}
{$IFDEF IPHONEOS}
{$DEFINE SDL13}
--- a/hedgewars/uAIAmmoTests.pas Sat Jul 31 10:52:43 2010 +0200
+++ b/hedgewars/uAIAmmoTests.pas Sat Jul 31 11:24:53 2010 +0200
@@ -689,7 +689,7 @@
FillBonuses(true, [gtCase]);
if bonuses.Count = 0 then begin
if Me^.Health <= 100 then begin
- maxTop := Targ.Y - cHHRadius * 2;
+ maxTop := Targ.Y - cHHRadius * 2;
while not TestColl(Targ.X, maxTop, cHHRadius) and (maxTop > topY + cHHRadius * 2 + 1) do
dec(maxTop, cHHRadius*2);
if not TestColl(Targ.X, maxTop + cHHRadius, cHHRadius) then begin
@@ -701,7 +701,7 @@
end
else begin
failNum := 0;
- repeat
+ repeat
i := random(bonuses.Count);
inc(failNum);
until not TestColl(bonuses.ar[i].X, bonuses.ar[i].Y - cHHRadius - bonuses.ar[i].Radius, cHHRadius) or (failNum = bonuses.Count*2);
--- a/hedgewars/uAIMisc.pas Sat Jul 31 10:52:43 2010 +0200
+++ b/hedgewars/uAIMisc.pas Sat Jul 31 11:24:53 2010 +0200
@@ -76,7 +76,7 @@
var friendlyfactor: LongInt = 300;
KnownExplosion: record
X, Y, Radius: LongInt
- end = (X: 0; Y: 0; Radius: 0);
+ end = (X: 0; Y: 0; Radius: 0);
procedure FillTargets;
var i, t: Longword;
@@ -195,7 +195,7 @@
MeX:= hwRound(Me^.X);
MeY:= hwRound(Me^.Y);
// We are still inside the hog. Skip radius test
- if ((((x-MeX)*(x-MeX)) + ((y-MeY)*(y-MeY))) < 256) and
+ if ((((x-MeX)*(x-MeX)) + ((y-MeY)*(y-MeY))) < 256) and
((Land[y, x] and $FF00) = 0) then exit(false);
end;
exit(TestColl(x, y, r))
--- a/hedgewars/uAmmos.pas Sat Jul 31 10:52:43 2010 +0200
+++ b/hedgewars/uAmmos.pas Sat Jul 31 11:24:53 2010 +0200
@@ -71,11 +71,11 @@
Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]].Count:= cnts[a];
Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]].InitialCount:= cnts[a];
- if ((GameFlags and gfPlaceHog) <> 0) and (a = amTeleport) then
+ if ((GameFlags and gfPlaceHog) <> 0) and (a = amTeleport) then
Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]].Count:= AMMO_INFINITE;
inc(mi[Ammoz[a].Slot])
end
- else if (TotalRounds < 0) and ((GameFlags and gfPlaceHog) <> 0) and (a = amTeleport) then
+ else if (TotalRounds < 0) and ((GameFlags and gfPlaceHog) <> 0) and (a = amTeleport) then
begin
TryDo(mi[Ammoz[a].Slot] <= cMaxSlotAmmoIndex, 'Ammo slot overflow', true);
Ammo^[Ammoz[a].Slot, mi[Ammoz[a].Slot]]:= Ammoz[a].Ammo;
@@ -99,7 +99,7 @@
// FIXME - TEMPORARY hardcoded check on shoppa pending creation of crate *type* probability editor
substr:= Copy(ammoLoadout,1,15);
-if (substr = '000000990000009') or
+if (substr = '000000990000009') or
(substr = '000000990000000') then
shoppa:= true;
@@ -137,11 +137,11 @@
end;
ammos[a]:= cnt;
- if ((GameFlags and gfKing) <> 0) and ((GameFlags and gfPlaceHog) = 0) and (Ammoz[a].SkipTurns = 0) and (a <> amTeleport) and (a <> amSkip) then
+ if ((GameFlags and gfKing) <> 0) and ((GameFlags and gfPlaceHog) = 0) and (Ammoz[a].SkipTurns = 0) and (a <> amTeleport) and (a <> amSkip) then
Ammoz[a].SkipTurns:= 1;
if ((GameFlags and gfPlaceHog) <> 0) and
- (a <> amTeleport) and (a <> amSkip) and
+ (a <> amTeleport) and (a <> amSkip) and
(Ammoz[a].SkipTurns < 10000) then inc(Ammoz[a].SkipTurns,10000)
end else
ammos[a]:= AMMO_INFINITE
@@ -353,7 +353,7 @@
begin
for a:= 0 to cMaxSlotAmmoIndex do
with StoresList[i]^[slot, a] do
- if (Propz and ammoprop_NotBorder) <> 0 then
+ if (Propz and ammoprop_NotBorder) <> 0 then
begin
Count:= 0;
InitialCount:= 0
--- a/hedgewars/uCollisions.pas Sat Jul 31 10:52:43 2010 +0200
+++ b/hedgewars/uCollisions.pas Sat Jul 31 11:24:53 2010 +0200
@@ -387,7 +387,7 @@
for i:= 0 to 8 do
begin
// using mx,my as temporary value buffer here
-
+
jfr:= 8+li+1;
jto:= 8+li-1;
--- a/hedgewars/uConsole.pas Sat Jul 31 10:52:43 2010 +0200
+++ b/hedgewars/uConsole.pas Sat Jul 31 11:24:53 2010 +0200
@@ -92,7 +92,7 @@
{$IFDEF DEBUGFILE}AddFileLog('Console write: ' + s);{$ENDIF}
Write(s);
done:= false;
-
+
while not done do
begin
Len:= cLineWidth - Length(ConsoleLines[CurrLine].s);
@@ -204,14 +204,14 @@
CurrLine:= 0;
Variables:= nil;
isDeveloperMode:= true;
-
+
// initConsole
cLineWidth:= cScreenWidth div 10;
if cLineWidth > 255 then
cLineWidth:= 255;
- for i:= 0 to Pred(cLinesCount) do
+ 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 );
--- a/hedgewars/uConsts.pas Sat Jul 31 10:52:43 2010 +0200
+++ b/hedgewars/uConsts.pas Sat Jul 31 11:24:53 2010 +0200
@@ -33,7 +33,7 @@
HwColor4f = record
r, g, b, a: byte
end;
-
+
TGameState = (gsLandGen, gsStart, gsGame, gsChat, gsConfirm, gsExit);
TGameType = (gmtLocal, gmtDemo, gmtNet, gmtSave, gmtLandPreview, gmtSyntax);
@@ -71,11 +71,11 @@
sprAmTeleport, sprSplash, sprDroplet, sprBirdy, sprHandCake, sprHandConstruction,
sprHandGrenade, sprHandMelon, sprHandMortar, sprHandSkip, sprHandCluster,
sprHandDynamite, sprHandHellish, sprHandMine, sprHandSeduction, sprHandVamp,
- sprBigExplosion, sprSmokeRing, sprBeeTrace, sprEgg, sprTargetBee, sprHandBee,
+ sprBigExplosion, sprSmokeRing, sprBeeTrace, sprEgg, sprTargetBee, sprHandBee,
sprFeather, sprPiano, sprHandSineGun, sprPortalGun, sprPortal,
sprCheese, sprHandCheese, sprHandFlamethrower, sprChunk
);
-
+
// Gears that interact with other Gears and/or Land
TGearType = (gtAmmo_Bomb, gtHedgehog, gtAmmo_Grenade, gtGrave, gtBee, // 4
gtShotgunShot, gtPickHammer, gtRope, gtMine, gtCase, // 9
@@ -154,7 +154,7 @@
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;
+ InitialCount: LongWord;
NumPerTurn: LongWord;
Timer: LongWord;
Pos: LongWord;
@@ -256,13 +256,13 @@
cPowerDivisor = 1500;
MAXNAMELEN = 192;
-
+
// some opengl headers do not have these macros
GL_BGR = $80E0;
GL_BGRA = $80E1;
GL_CLAMP_TO_EDGE = $812F;
GL_TEXTURE_PRIORITY = $8066;
-
+
cSendCursorPosTime : LongWord = 50;
cVisibleWater : LongInt = 128;
cCursorEdgesDist : LongInt = 100;
@@ -321,7 +321,7 @@
tfSpawnTargets = $00000004;
tfIgnoreDelays = $00000008;
tfTargetRespawn = $00000010;
-
+
gfAny = $FFFFFFFF;
gfForts = $00000001;
gfMultiWeapon = $00000002;
@@ -400,7 +400,7 @@
ammoprop_Utility = $00001000;
ammoprop_Effect = $00002000;
ammoprop_NoRoundEndHint=$10000000;
-
+
AMMO_INFINITE = 100;
EXPLAllDamageInRadius = $00000001;
@@ -424,11 +424,11 @@
htName = $02;
htHealth = $04;
htTransparent = $08;
-
+
cHHFileName = 'Hedgehog';
cCHFileName = 'Crosshair';
cThemeCFGFilename = 'theme.cfg';
-
+
FontBorder = 2;
cPathz: array[TPathType] of shortstring = (
'', // ptNone
@@ -451,7 +451,7 @@
'Graphics/Hats', // ptHats
'Graphics/Flags' // ptFlags
);
-
+
var PathPrefix: shortstring = './';
Pathz: array[TPathType] of shortstring;
CountTexz: array[1..Pred(AMMO_INFINITE)] of PTexture;
@@ -722,7 +722,7 @@
Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprJetpack
(FileName: 'Health'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpHigh; getDimensions: false; getImageDimensions: true),// sprHealth
- (FileName: 'amMolotov'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil;
+ (FileName: 'amMolotov'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil;
Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),//sprHandMolotov
(FileName: 'Molotov'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprMolotov
@@ -2103,7 +2103,7 @@
PosSprite: sprWater;
ejectX: 0;
ejectY: 0),
-
+
// SineGun
(NameId: sidSineGun;
NameTex: nil;
@@ -2180,7 +2180,7 @@
colorkey: 0;
alpha : 255
);
-
+
procedure initModule;
procedure freeModule;
@@ -2210,7 +2210,7 @@
LAND_HEIGHT_MASK:= $FFFFF800
end;
-{$IFDEF IPHONEOS}
+{$IFDEF IPHONEOS}
if isPhone() then
cMaxCaptions:= 3
else
--- a/hedgewars/uGears.pas Sat Jul 31 10:52:43 2010 +0200
+++ b/hedgewars/uGears.pas Sat Jul 31 11:24:53 2010 +0200
@@ -22,7 +22,7 @@
interface
uses SDLh, uConsts, uFloat, Math;
-
+
type
PGear = ^TGear;
TGearStepProcedure = procedure (Gear: PGear);
@@ -77,7 +77,7 @@
PlacingHogs: boolean; // a convenience flag to indicate placement of hogs is still in progress
StepSoundTimer: LongInt;
StepSoundChannel: LongInt;
-
+
procedure initModule;
procedure freeModule;
function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
@@ -113,7 +113,7 @@
end;
rounded: array[0..MAXROPEPOINTS + 2] of TVertex2f;
end;
-
+
procedure DeleteGear(Gear: PGear); forward;
procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord); forward;
procedure doMakeExplosion(X, Y, Radius: LongInt; Mask, Tint: LongWord); forward;
@@ -214,7 +214,7 @@
ptmp:= tmp;
tmp:= tmp^.NextGear
end;
-
+
if ptmp <> tmp then
begin
Gear^.NextGear:= ptmp^.NextGear;
@@ -471,7 +471,7 @@
gtJetpack: begin
gear^.Health:= 2000;
end;
- gtMolotov: begin
+ gtMolotov: begin
gear^.Radius:= 6;
end;
gtBirdy: begin
@@ -480,7 +480,7 @@
gear^.Health := 2000;
gear^.FlightTime := 2;
end;
- gtEgg: begin
+ gtEgg: begin
gear^.Radius:= 4;
gear^.Elasticity:= _0_6;
gear^.Friction:= _0_96;
@@ -652,9 +652,9 @@
flag:= false;
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
- (team^.Hedgehogs[i].Gear^.Health > team^.Hedgehogs[i].Gear^.Damage)
+ if (team^.Hedgehogs[i].Gear <> nil) and
+ (not team^.Hedgehogs[i].King) and
+ (team^.Hedgehogs[i].Gear^.Health > team^.Hedgehogs[i].Gear^.Damage)
then flag:= true;
if not flag then inc(tmp, min(5, max(0,Gear^.Health - 1 - Gear^.Damage)))
end;
@@ -794,10 +794,10 @@
// reset to default zoom
//ZoomValue:= ZoomDefault;
with CurrentHedgehog^ do
- if (Gear <> nil)
+ if (Gear <> nil)
and ((Gear^.State and gstAttacked) = 0)
and (MultiShootAttacks > 0) then OnUsedAmmo(CurrentHedgehog^);
-
+
EndTurnCleanup;
FreeActionsList; // could send -left, -right and similar commands, so should be called before /nextturn
@@ -1318,9 +1318,9 @@
begin
t:= CheckGearsCollision(Ammo);
// Just to avoid hogs on rope dodging fire.
-if (CurAmmoGear <> nil) and (CurAmmoGear^.Kind = gtRope) and
- (CurrentHedgehog^.Gear <> nil) and (CurrentHedgehog^.Gear^.CollisionIndex = -1) and
- (sqr(hwRound(Ammo^.X) - hwRound(CurrentHedgehog^.Gear^.X)) + sqr(hwRound(Ammo^.Y) - hwRound(CurrentHedgehog^.Gear^.Y)) <= sqr(cHHRadius + Ammo^.Radius)) then
+if (CurAmmoGear <> nil) and (CurAmmoGear^.Kind = gtRope) and
+ (CurrentHedgehog^.Gear <> nil) and (CurrentHedgehog^.Gear^.CollisionIndex = -1) and
+ (sqr(hwRound(Ammo^.X) - hwRound(CurrentHedgehog^.Gear^.X)) + sqr(hwRound(Ammo^.Y) - hwRound(CurrentHedgehog^.Gear^.Y)) <= sqr(cHHRadius + Ammo^.Radius)) then
begin
t^.ar[t^.Count]:= CurrentHedgehog^.Gear;
inc(t^.Count)
@@ -1336,7 +1336,7 @@
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,
@@ -1374,7 +1374,7 @@
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
@@ -1538,19 +1538,19 @@
// FIXME - shoppa is TEMPORARY REMOVE WHEN CRATE PROBABILITY ALLOWS DISABLING OF HEALTH CRATES
// Preserving health crate distribution of 35% until that happens
if (aTot+uTot) <> 0 then
- if not shoppa and ((GameFlags and gfInvulnerable) = 0) then
+ if not shoppa and ((GameFlags and gfInvulnerable) = 0) then
begin
h:= 3500;
t:= GetRandom(10000);
a:= 6500*aTot div (aTot+uTot)
end
- else
+ else
begin
t:= GetRandom(aTot+uTot);
h:= 0
end;
-
+
if t<h then
begin
FollowGear:= AddGear(0, 0, gtCase, 0, _0, _0, 0);
@@ -1653,12 +1653,12 @@
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 (CountNonZeroz(x, y+1, Gear^.Radius - 1, Gear^.Radius+1) > Gear^.Radius))
+ and (CountNonZeroz(x, y+1, Gear^.Radius - 1, Gear^.Radius+1) > Gear^.Radius))
or
((Gear^.Kind <> gtExplosives)
and (y < LAND_HEIGHT)
@@ -1742,7 +1742,7 @@
SpeechType:= 1;
TrainingTargetGear:= nil;
skipFlag:= false;
-
+
AllInactive:= false;
PrvInactive:= false;
end;
--- a/hedgewars/uKeys.pas Sat Jul 31 10:52:43 2010 +0200
+++ b/hedgewars/uKeys.pas Sat Jul 31 11:24:53 2010 +0200
@@ -71,16 +71,16 @@
rightKey: boolean;
leftKey: boolean;
preciseKey: boolean;
-
+
backspaceKey: boolean;
spaceKey: boolean;
enterKey: boolean;
tabKey: boolean;
-
+
chatAction: boolean;
pauseAction: boolean;
-
-{$IFDEF IPHONEOS}
+
+{$IFDEF IPHONEOS}
procedure setiPhoneBinds;
{$ENDIF}
{$ENDIF}
@@ -90,7 +90,7 @@
var tkbd, tkbdn: TKeyboardState;
KeyNames: array [0..cKeyMaxIndex] of string[15];
-
+
function KeyNameToCode(name: shortstring): word;
var code: Word;
begin
@@ -247,7 +247,7 @@
inc(k, 1);
end;
end;
-
+
for t:= 0 to cKeyMaxIndex do
tkbd[i]:= tkbdn[i]
end;
@@ -386,7 +386,7 @@
tkbdn[44]:= ord(chatAction);
tkbdn[55]:= ord(pauseAction);
-
+
// set to false the keys that only need one stoke
leftClick:= false;
middleClick:= false;
@@ -395,7 +395,7 @@
tabKey:= false;
enterKey:= false;
backspaceKey:= false;
-
+
chatAction:= false;
pauseAction:= false;
end;
@@ -408,7 +408,7 @@
end;
var Controller: array [0..5] of PSDL_Joystick;
-
+
procedure ControllerInit;
var i, j: Integer;
begin
@@ -442,12 +442,12 @@
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;
@@ -465,7 +465,7 @@
// enable event generation/controller updating
SDL_JoystickEventState(1);
end
-else
+else
WriteLnToConsole('Not using any game controller');
end;
@@ -500,7 +500,7 @@
coeff:= 5;
{$IFDEF HWLIBRARY}
// this function is called by HW_allKeysUp so be careful
-
+
// mouse emulation
leftClick:= false;
middleClick:= false;
--- a/hedgewars/uLand.pas Sat Jul 31 10:52:43 2010 +0200
+++ b/hedgewars/uLand.pas Sat Jul 31 11:24:53 2010 +0200
@@ -23,7 +23,7 @@
uses SDLh, uLandTemplates, uFloat, uConsts, GLunit;
type
- TLandArray = packed array of array of LongWord;
+ TLandArray = packed array of array of LongWord;
TCollisionArray = packed array of array of Word;
TPreview = packed array[0..127, 0..31] of byte;
TDirtyTag = packed array of array of byte;
@@ -31,9 +31,9 @@
var Land: TCollisionArray;
LandPixels: TLandArray;
LandDirty: TDirtyTag;
- hasBorder: boolean;
- hasGirders: boolean;
- isMap: boolean;
+ hasBorder: boolean;
+ hasGirders: boolean;
+ isMap: boolean;
playHeight, playWidth, leftX, rightX, topY, MaxHedgehogs: Longword; // idea is that a template can specify height/width. Or, a map, a height/width by the dimensions of the image. If the map has pixels near top of image, it triggers border.
LandBackSurface: PSDL_Surface;
digest: shortstring;
@@ -1156,7 +1156,7 @@
if SDL_MustLock(tmpsurf) then
SDL_UnlockSurface(tmpsurf);
end;
- if (tmpsurf <> nil) then
+ if (tmpsurf <> nil) then
SDL_FreeSurface(tmpsurf);
tmpsurf:= nil;
end;
@@ -1208,11 +1208,11 @@
LoadThemeConfig;
isMap:= false;
-
+
// is this not needed any more? let's hope setlength sets also 0s
//if ((GameFlags and gfForts) <> 0) or (Pathz[ptMapCurrent] <> '') then
// FillChar(Land,SizeOf(TCollisionArray),0);*)
-
+
if (GameFlags and gfForts) = 0 then
if Pathz[ptMapCurrent] <> '' then
LoadMap
--- a/hedgewars/uLandGraphics.pas Sat Jul 31 10:52:43 2010 +0200
+++ b/hedgewars/uLandGraphics.pas Sat Jul 31 11:24:53 2010 +0200
@@ -230,7 +230,7 @@
inc(cnt);
if (cReducedQuality and rqBlurryLand) = 0 then
LandPixels[t, i]:= LandBackPixel(i, t)
- else
+ else
LandPixels[t div 2, i div 2]:= LandBackPixel(i, t)
end
else
@@ -248,7 +248,7 @@
inc(cnt);
if (cReducedQuality and rqBlurryLand) = 0 then
LandPixels[t, i]:= LandBackPixel(i, t)
- else
+ else
LandPixels[t div 2, i div 2]:= LandBackPixel(i, t)
end
else
@@ -284,7 +284,7 @@
if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
begin
if (cReducedQuality and rqBlurryLand) = 0 then
- LandPixels[t, i]:= cExplosionBorderColor
+ LandPixels[t, i]:= cExplosionBorderColor
else
LandPixels[t div 2, i div 2]:= cExplosionBorderColor;
Land[t, i]:= Land[t, i] or lfDamaged;
@@ -313,7 +313,7 @@
if ((Land[t, i] and lfBasic) <> 0) or ((Land[t, i] and lfObject) <> 0) then
begin
if (cReducedQuality and rqBlurryLand) = 0 then
- LandPixels[t, i]:= cExplosionBorderColor
+ LandPixels[t, i]:= cExplosionBorderColor
else
LandPixels[t div 2, i div 2]:= cExplosionBorderColor;
@@ -413,7 +413,7 @@
LandPixels[ty, tx]:= LandBackPixel(tx, ty)
else
LandPixels[ty div 2, tx div 2]:= LandBackPixel(tx, ty)
- else
+ else
if (Land[ty, tx] and lfObject) <> 0 then
if (cReducedQuality and rqBlurryLand) = 0 then
LandPixels[ty, tx]:= 0
@@ -473,7 +473,7 @@
ty:= hwRound(Y);
if ((ty and LAND_HEIGHT_MASK) = 0) and
((tx and LAND_WIDTH_MASK) = 0) and
- (((Land[ty, tx] and lfBasic) <> 0) or
+ (((Land[ty, tx] and lfBasic) <> 0) or
((Land[ty, tx] and lfObject) <> 0)) then
begin
Land[ty, tx]:= Land[ty, tx] or lfDamaged;
@@ -499,7 +499,7 @@
ty:= hwRound(Y);
if ((ty and LAND_HEIGHT_MASK) = 0) and
((tx and LAND_WIDTH_MASK) = 0) and
- (((Land[ty, tx] and lfBasic) <> 0) or
+ (((Land[ty, tx] and lfBasic) <> 0) or
((Land[ty, tx] and lfObject) <> 0)) then
begin
Land[ty, tx]:= Land[ty, tx] or lfDamaged;
@@ -525,7 +525,7 @@
LandPixels[ty, tx]:= LandBackPixel(tx, ty)
else
LandPixels[ty div 2, tx div 2]:= LandBackPixel(tx, ty)
- else
+ else
if (Land[ty, tx] and lfObject) <> 0 then
if (cReducedQuality and rqBlurryLand) = 0 then
LandPixels[ty, tx]:= 0
@@ -543,7 +543,7 @@
ty:= hwRound(Y);
if ((ty and LAND_HEIGHT_MASK) = 0) and
((tx and LAND_WIDTH_MASK) = 0) and
- (((Land[ty, tx] and lfBasic) <> 0) or
+ (((Land[ty, tx] and lfBasic) <> 0) or
((Land[ty, tx] and lfObject) <> 0)) then
begin
Land[ty, tx]:= Land[ty, tx] or lfDamaged;
@@ -570,7 +570,7 @@
ty:= hwRound(Y);
if ((ty and LAND_HEIGHT_MASK) = 0) and
((tx and LAND_WIDTH_MASK) = 0) and
- (((Land[ty, tx] and lfBasic) <> 0) or
+ (((Land[ty, tx] and lfBasic) <> 0) or
((Land[ty, tx] and lfObject) <> 0)) then
begin
Land[ty, tx]:= Land[ty, tx] or lfDamaged;
@@ -688,13 +688,13 @@
if c < 4 then // 0-3 neighbours
begin
if (cReducedQuality and rqBlurryLand) = 0 then
- if (Land[Y, X] and lfBasic) <> 0 then
- LandPixels[Y, X]:= LandBackPixel(X, Y)
+ if (Land[Y, X] and lfBasic) <> 0 then
+ LandPixels[Y, X]:= LandBackPixel(X, Y)
else
LandPixels[Y, X]:= 0
else
- if (Land[Y, X] and lfBasic) <> 0 then
- LandPixels[Y div 2, X div 2]:= LandBackPixel(X, Y)
+ if (Land[Y, X] and lfBasic) <> 0 then
+ LandPixels[Y div 2, X div 2]:= LandBackPixel(X, Y)
else
LandPixels[Y div 2, X div 2]:= 0;
--- a/hedgewars/uLandObjects.pas Sat Jul 31 10:52:43 2010 +0200
+++ b/hedgewars/uLandObjects.pas Sat Jul 31 11:24:53 2010 +0200
@@ -94,7 +94,7 @@
if LandPixels[(cpY + y) div 2, (cpX + x) div 2] = 0 then
LandPixels[(cpY + y) div 2, (cpX + x) div 2]:= p^[x];
- if ((Land[cpY + y, cpX + x] and $FF00) = 0) and ((p^[x] and AMask) <> 0) then
+ if ((Land[cpY + y, cpX + x] and $FF00) = 0) and ((p^[x] and AMask) <> 0) then
Land[cpY + y, cpX + x]:= lfObject
end;
p:= @(p^[Image^.pitch shr 2])
@@ -470,16 +470,16 @@
if ThemeObjects.Count = 0 then exit;
WriteLnToConsole('Adding theme objects...');
- for i:=0 to ThemeObjects.Count do
+ 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;
@@ -493,16 +493,16 @@
if SprayObjects.Count = 0 then exit;
WriteLnToConsole('Adding spray objects...');
- for i:=0 to SprayObjects.Count do
+ 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;
--- a/hedgewars/uLandTexture.pas Sat Jul 31 10:52:43 2010 +0200
+++ b/hedgewars/uLandTexture.pas Sat Jul 31 11:24:53 2010 +0200
@@ -42,7 +42,7 @@
tmpPixels: array [0..TEXSIZE - 1, 0..TEXSIZE - 1] of LongWord;
LANDTEXARW: LongWord;
LANDTEXARH: LongWord;
-
+
function Pixels(x, y: Longword): Pointer;
var ty: Longword;
begin
@@ -101,7 +101,7 @@
begin
shouldUpdate:= false;
glBindTexture(GL_TEXTURE_2D, tex^.id);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEXSIZE, TEXSIZE, 0, GL_RGBA, GL_UNSIGNED_BYTE, Pixels(x,y));
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, TEXSIZE, TEXSIZE, 0, GL_RGBA, GL_UNSIGNED_BYTE, Pixels(x,y));
end
end;
@@ -132,10 +132,10 @@
LANDTEXARW:= (LAND_WIDTH div TEXSIZE) div 2;
LANDTEXARH:= (LAND_HEIGHT div TEXSIZE) div 2;
end;
-
+
SetLength(LandTextures, LANDTEXARW, LANDTEXARH);
end;
-
+
procedure freeModule;
var x, y: LongInt;
begin
--- a/hedgewars/uMisc.pas Sat Jul 31 10:52:43 2010 +0200
+++ b/hedgewars/uMisc.pas Sat Jul 31 11:24:53 2010 +0200
@@ -70,7 +70,7 @@
TimeTrialStartTime: Longword;
TimeTrialStopTime : Longword;
-
+
// init flags
cScreenWidth : LongInt = 1024;
cScreenHeight : LongInt = 768;
@@ -89,7 +89,7 @@
cReducedQuality : LongInt = rqNone;
//userNick is in uChat
recordFileName : shortstring = '';
-
+
cCaseFactor : Longword;
cLandAdditions : Longword;
cExplosives : Longword;
@@ -518,11 +518,11 @@
begin
if tex <> nil then
begin
- if tex^.NextTexture <> nil then
+ if tex^.NextTexture <> nil then
tex^.NextTexture^.PrevTexture:= tex^.PrevTexture;
- if tex^.PrevTexture <> nil then
+ if tex^.PrevTexture <> nil then
tex^.PrevTexture^.NextTexture:= tex^.NextTexture
- else
+ else
TextureList:= tex^.NextTexture;
glDeleteTextures(1, @tex^.id);
Dispose(tex);
@@ -682,7 +682,7 @@
cDamageModifier := _1;
TargetPoint := cTargetPointRef;
TextureList := nil;
-
+
// int, longint longword and byte
CursorMovementX := 0;
CursorMovementY := 0;
@@ -719,7 +719,7 @@
cCaseFactor := 5; {0..9}
cLandAdditions := 4;
cExplosives := 2;
-
+
GameState := Low(TGameState);
GameType := gmtLocal;
zoom := cDefaultZoomLevel;
@@ -746,10 +746,10 @@
cInactDelay := 1250;
ScreenFade := sfNone;
-
+
{$IFDEF SDL13}
SDLwindow := nil;
-{$ENDIF}
+{$ENDIF}
{$IFDEF DEBUGFILE}
{$I-}
{$IFDEF IPHONEOS}
--- a/hedgewars/uSHA.pas Sat Jul 31 10:52:43 2010 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,166 +0,0 @@
-(*
- * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2010 Andrey Korotaev <unC0Rr@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *)
-
-{$INCLUDE "options.inc"}
-
-unit uSHA;
-interface
-uses SDLh;
-
-type TSHA1Context = packed record
- H: array[0..4] of LongWord;
- Length, CurrLength: Int64;
- Buf: array[0..63] of byte;
- end;
- TSHA1Digest = array[0..4] of LongWord;
-
-procedure SHA1Init(var Context: TSHA1Context);
-procedure SHA1Update(var Context: TSHA1Context; Buf: PByteArray; Length: LongWord);
-procedure SHA1UpdateLongwords(var Context: TSHA1Context; Buf: PLongwordArray; Length: LongWord);
-function SHA1Final(Context: TSHA1Context): TSHA1Digest;
-
-implementation
-
-function rol(x: LongWord; y: Byte): LongWord;
-begin
- rol:= (X shl y) or (X shr (32 - y))
-end;
-
-function Ft(t, b, c, d: LongWord): LongWord;
-begin
-case t of
- 0..19: Ft := (b and c) or ((not b) and d);
- 20..39: Ft := b xor c xor d;
- 40..59: Ft := (b and c) or (b and d) or (c and d);
- else Ft := b xor c xor d;
- end;
-end;
-
-function Kt(t: Byte): LongWord;
-begin
- case t of
- 0..19: Kt := $5A827999;
- 20..39: Kt := $6ED9EBA1;
- 40..59: Kt := $8F1BBCDC;
- else
- Kt := $CA62C1D6
- end;
-end;
-
-
-procedure SHA1Hash(var Context: TSHA1Context);
-var S: array[0..4 ] of LongWord;
- W: array[0..79] of LongWord;
- i, t: LongWord;
-begin
-{$HINTS OFF}
-move(Context.H, S, sizeof(S));
-{$HINTS ON}
-for i:= 0 to 15 do
- SDLNet_Write32(PLongWordArray(@Context.Buf)^[i], @W[i]);
-
-for i := 16 to 79 do
- W[i] := rol(W[i - 3] xor W[i - 8] xor W[i - 14] xor W[i - 16], 1);
-
-for i := 0 to 79 do
- begin
- t:= rol(S[0], 5) + Ft(i, S[1], S[2], S[3]) + S[4] + W[i] + Kt(i);
- S[4]:= S[3];
- S[3]:= S[2];
- S[2]:= rol(S[1], 30);
- S[1]:= S[0];
- S[0]:= t
- end;
-
-for i := 0 to 4 do
- Context.H[i]:= Context.H[i] + S[i]
-end;
-
-procedure SHA1Init(var Context: TSHA1Context);
-begin
- with Context do
- begin
- Length := 0;
- CurrLength:= 0;
- H[0]:= $67452301;
- H[1]:= $EFCDAB89;
- H[2]:= $98BADCFE;
- H[3]:= $10325476;
- H[4]:= $C3D2E1F0
- end
-end;
-
-procedure SHA1Update(var Context: TSHA1Context; Buf: PByteArray; Length: LongWord);
-var i: Longword;
-begin
-for i:= 0 to Pred(Length) do
- begin
- Context.Buf[Context.CurrLength]:= Buf^[i];
- inc(Context.CurrLength);
- if Context.CurrLength = 64 then
- begin
- SHA1Hash(Context);
- inc(Context.Length, 512);
- Context.CurrLength:= 0
- end
- end
-end;
-
-procedure SHA1UpdateLongwords(var Context: TSHA1Context; Buf: PLongwordArray; Length: LongWord);
-var i: Longword;
-begin
- for i:= 0 to Pred(Length div 4) do
- begin
- SDLNet_Write32(Buf^[i], @Context.Buf[Context.CurrLength]);
- inc(Context.CurrLength, 4);
- if Context.CurrLength = 64 then
- begin
- SHA1Hash(Context);
- inc(Context.Length, 512);
- Context.CurrLength:= 0
- end
- end
-end;
-
-function SHA1Final(Context: TSHA1Context): TSHA1Digest;
-var i: LongWord;
-begin
- Context.Length:= Context.Length + Context.CurrLength shl 3;
- Context.Buf[Context.CurrLength]:= $80;
- inc(Context.CurrLength);
-
- if Context.CurrLength > 56 then
- begin
- FillChar(Context.Buf[Context.CurrLength], 64 - Context.CurrLength, 0);
- Context.CurrLength:= 64;
- SHA1Hash(Context);
- Context.CurrLength:=0
- end;
-
- FillChar(Context.Buf[Context.CurrLength], 56 - Context.CurrLength, 0);
-
- for i:= 56 to 63 do
- Context.Buf[i] := (Context.Length shr ((63 - i) * 8)) and $FF;
- SHA1Hash(Context);
- for i:= 0 to 4 do
- SHA1Final[i]:= Context.H[i];
-
- FillChar(Context, sizeof(Context), 0)
-end;
-
-end.
--- a/hedgewars/uScript.pas Sat Jul 31 10:52:43 2010 +0200
+++ b/hedgewars/uScript.pas Sat Jul 31 11:24:53 2010 +0200
@@ -52,14 +52,14 @@
uTeams,
uKeys,
uChat;
-
+
var luaState : Plua_State;
ScriptAmmoLoadout : shortstring;
ScriptAmmoProbability : shortstring;
ScriptAmmoDelay : shortstring;
ScriptAmmoReinforcement : shortstring;
ScriptLoaded : boolean;
-
+
procedure ScriptPrepareAmmoStore; forward;
procedure ScriptApplyAmmoStore; forward;
procedure ScriptSetAmmo(ammo : TAmmoType; count, propability, delay, reinforcement: Byte); forward;
@@ -596,7 +596,7 @@
if ScriptGetString('Map') <> '' then
ParseCommand('map ' + ScriptGetString('Map'), true);
if ScriptGetString('Theme') <> '' then
- ParseCommand('theme ' + ScriptGetString('Theme'), true);
+ ParseCommand('theme ' + ScriptGetString('Theme'), true);
if ScriptExists('onAmmoStoreInit') then
begin
@@ -792,7 +792,7 @@
// register ammo types
for am:= Low(TAmmoType) to High(TAmmoType) do
ScriptSetInteger(EnumToStr(am), ord(am));
-
+
// register functions
lua_register(luaState, 'AddGear', @lc_addgear);
lua_register(luaState, 'WriteLnToConsole', @lc_writelntoconsole);
--- a/hedgewars/uSound.pas Sat Jul 31 10:52:43 2010 +0200
+++ b/hedgewars/uSound.pas Sat Jul 31 11:24:53 2010 +0200
@@ -123,7 +123,7 @@
// make sure all instances of sdl_mixer are unloaded before continuing
while Mix_Init(0) <> 0 do
Mix_Quit();
-{$ENDIF}
+{$ENDIF}
Mix_CloseAudio();
end;
@@ -136,17 +136,17 @@
if not isSoundEnabled then exit;
defVoicepack:= AskForVoicepack('Default');
-
+
for t:= 0 to cMaxTeams do
if voicepacks[t].name <> '' then
for i:= Low(TSound) to High(TSound) do
voicepacks[t].chunks[i]:= nil;
-
+
for i:= Low(TSound) to High(TSound) do
begin
defVoicepack^.chunks[i]:= nil;
// preload all the big sound files (>32k) that would otherwise lockup the game
- if (i in [sndBeeWater, sndBee, sndCake, sndHellishImpact1, sndHellish, sndHomerun, sndMolotov, sndMortar, sndRideOfTheValkyries, sndYoohoo])
+ if (i in [sndBeeWater, sndBee, sndCake, sndHellishImpact1, sndHellish, sndHomerun, sndMolotov, sndMortar, sndRideOfTheValkyries, sndYoohoo])
and (Soundz[i].Path <> ptVoices) and (Soundz[i].FileName <> '') then
begin
s:= Pathz[Soundz[i].Path] + '/' + Soundz[i].FileName;
--- a/hedgewars/uStats.pas Sat Jul 31 10:52:43 2010 +0200
+++ b/hedgewars/uStats.pas Sat Jul 31 11:24:53 2010 +0200
@@ -226,7 +226,7 @@
TotalRounds:= -1;
FinishedTurnsTotal:= -1;
end;
-
+
procedure freeModule;
begin
--- a/hedgewars/uStore.pas Sat Jul 31 10:52:43 2010 +0200
+++ b/hedgewars/uStore.pas Sat Jul 31 11:24:53 2010 +0200
@@ -39,7 +39,7 @@
rotationQt: GLfloat;
wScreen: LongInt;
hScreen: LongInt;
-
+
procedure initModule;
procedure freeModule;
@@ -235,13 +235,13 @@
r.h:= 19;
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);
@@ -249,7 +249,7 @@
copyToXY(flagsurf, texsurf, 2, 2);
SDL_FreeSurface(flagsurf);
flagsurf:= nil;
-
+
// restore black border pixels inside the flag
PLongwordArray(texsurf^.pixels)^[32 * 2 + 2]:= cNearBlackColor;
PLongwordArray(texsurf^.pixels)^[32 * 2 + 23]:= cNearBlackColor;
@@ -1123,7 +1123,7 @@
// initialized here because when initModule is called cScreenWidth/Height are not yet set
if (uStore.wScreen = 0) and (uStore.hScreen = 0) then
begin
- uStore.wScreen:= cScreenWidth;
+ uStore.wScreen:= cScreenWidth;
uStore.hScreen:= cScreenHeight;
end;
@@ -1214,8 +1214,8 @@
glDisable(GL_DITHER);
// enable common states by default as they save a lot
glEnable(GL_TEXTURE_2D);
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
end;
procedure SetScale(f: GLfloat);
@@ -1248,7 +1248,7 @@
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);
@@ -1262,11 +1262,11 @@
glClear(GL_COLOR_BUFFER_BIT);
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, (hScreen - squaresize) shr 1, @r, ProgrTex);
SDL_GL_SwapBuffers();
@@ -1421,7 +1421,7 @@
if w < (i + wa) then w:= i + wa;
inc(h, j + ha);
end;
-
+
// add borders space
inc(w, wa);
inc(h, ha + 8);
@@ -1451,7 +1451,7 @@
if tmpline <> '' then
begin
r:= WriteInRect(tmpsurf, FontBorder + 2, r.y + r.h, $ff707070, font, tmpline);
-
+
// render highlighted caption (if there's a ':')
tmpline2:= '';
SplitByChar(tmpline, tmpline2, ':');
@@ -1469,7 +1469,7 @@
r.h:= 32;
SDL_FillRect(tmpsurf, @r, $ffffffff);
SDL_UpperBlit(iconsurf, iconrect, tmpsurf, @r);
-
+
RenderHelpWindow:= Surface2Tex(tmpsurf, true);
SDL_FreeSurface(tmpsurf)
end;
@@ -1511,7 +1511,7 @@
extra:= trmsg[sidNoEndTurn];
extracolor:= LongInt($ff70c770);
end
-else
+else
begin
extra:= '';
extracolor:= 0;
@@ -1548,9 +1548,9 @@
cGPUVendor:= gvUnknown;
{$ENDIF}
// really initalized in storeLoad
- uStore.wScreen:= 0;
+ uStore.wScreen:= 0;
uStore.hScreen:= 0;
-
+
cScaleFactor:= 2.0;
SupportNPOTT:= false;
Step:= 0;
--- a/hedgewars/uTeams.pas Sat Jul 31 10:52:43 2010 +0200
+++ b/hedgewars/uTeams.pas Sat Jul 31 11:24:53 2010 +0200
@@ -172,7 +172,7 @@
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);
@@ -232,7 +232,7 @@
PlacingHogs:= false;
for t:= 0 to Pred(TeamsCount) do
for i:= 0 to cMaxHHIndex do
- if (TeamsArray[t]^.Hedgehogs[i].Gear <> nil) and (TeamsArray[t]^.Hedgehogs[i].Unplaced) then
+ if (TeamsArray[t]^.Hedgehogs[i].Gear <> nil) and (TeamsArray[t]^.Hedgehogs[i].Unplaced) then
PlacingHogs:= true;
if not PlacingHogs then // Reset various things I mucked with
--- a/hedgewars/uVisualGears.pas Sat Jul 31 10:52:43 2010 +0200
+++ b/hedgewars/uVisualGears.pas Sat Jul 31 11:24:53 2010 +0200
@@ -227,7 +227,7 @@
alpha:= 1.0;
scale:= 1.0
end;
- vgtSmokeWhite,
+ vgtSmokeWhite,
vgtSmoke: begin
dx:= 0.0002 * (random(45) + 10);
dy:= 0.0002 * (random(45) + 10);
--- a/hedgewars/uWorld.pas Sat Jul 31 10:52:43 2010 +0200
+++ b/hedgewars/uWorld.pas Sat Jul 31 11:24:53 2010 +0200
@@ -38,7 +38,7 @@
cntTicks: LongWord;
{$ENDIF}
cOffsetY: LongInt;
-
+
procedure initModule;
procedure freeModule;
@@ -281,7 +281,7 @@
DrawSprite(sprAMBorderVertical, x + AMWidth - AMxOffset, y, 1);
inc(y, AMSlotSize);
end;
-
+
DrawSprite(sprAMCorners, x - BORDERSIZE, y, 2);
for i:= 0 to cMaxSlotAmmoIndex do
DrawSprite(sprAMBorderHorizontal, x + i * AMSlotSize, y, 1);
@@ -339,7 +339,7 @@
DrawSprite(sprAMSlot, x + g * AMSlotSize, y, 1);
DrawSprite(sprAMBorderVertical, x + AMWidth - AMxOffset, y, 1);
end;
-
+
dec(y, BORDERSIZE);
DrawSprite(sprAMCorners, x - BORDERSIZE, y, 0);
for i:= 0 to cMaxSlotAmmoIndex + 1 do
@@ -355,7 +355,7 @@
amSel:= Ammo^[Slot, Pos].AmmoType;
RenderWeaponTooltip(amSel)
end;
-
+
{$IFDEF IPHONEOS}
DrawTexture(cScreenWidth div 2 - (AMWidth - 10) + AMxShift, AMyOffset - 25, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex);
@@ -402,7 +402,7 @@
lw:= cScreenWidth / cScaleFactor;
lh:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 + 16;
-
+
// Water
r.y:= OffsetY + WorldDy + cWaterLine;
if WorldDy < trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine then
@@ -509,14 +509,14 @@
rh:= SpritesData[sprR].Height * SpritesData[spr].Texture^.Scale;
dec(Shift, w div 2);
DrawTexture(Shift, WorldDy + LAND_HEIGHT + OffsetY - h, SpritesData[spr].Texture, SpritesData[spr].Texture^.Scale);
-
+
i:= Shift - lw;
while i >= -sw - lw do
begin
DrawTexture(i, WorldDy + LAND_HEIGHT + OffsetY - lh, SpritesData[sprL].Texture, SpritesData[sprL].Texture^.Scale);
dec(i, lw);
end;
-
+
i:= Shift + w;
while i <= sw do
begin
@@ -542,10 +542,10 @@
if ZoomValue < zoom then
begin
zoom:= zoom - 0.002 * Lag;
- if ZoomValue > zoom then
+ if ZoomValue > zoom then
zoom:= ZoomValue
- end
- else
+ end
+ else
if ZoomValue > zoom then
begin
zoom:= zoom + 0.002 * Lag;
@@ -580,11 +580,11 @@
end;
DrawVisualGears(0);
-
+
if (cReducedQuality and rq2DWater) = 0 then
begin
// Waves
- DrawWater(255, SkyOffset);
+ DrawWater(255, SkyOffset);
DrawWaves( 1, 0 - WorldDx div 32, - cWaveHeight + offsetY div 35, 64);
DrawWaves( -1, 25 + WorldDx div 25, - cWaveHeight + offsetY div 38, 48);
DrawWaves( 1, 75 - WorldDx div 19, - cWaveHeight + offsetY div 45, 32);
@@ -694,7 +694,7 @@
DrawSprite(sprFrame, -cScreenWidth div 2 + t, 8, 1);
dec(t, 32);
// 1 ms
- DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, i mod 10);
+ DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, i mod 10);
dec(t, 32);
i:= i div 10;
// 10 ms
@@ -757,16 +757,16 @@
with TeamsArray[t]^ do
begin
highlight:= bShowFinger and (CurrentTeam = TeamsArray[t]) and ((RealTicks mod 1000) < 500);
-
+
if highlight then
Tint(Clan^.Color);
// draw name
DrawTexture(-NameTagTex^.w - 16, cScreenHeight + DrawHealthY, NameTagTex);
-
+
// draw flag
DrawTexture(-14, cScreenHeight + DrawHealthY, FlagTex);
-
+
// draw health bar
r.x:= 0;
r.y:= 0;
@@ -876,11 +876,11 @@
s:= inttostr(t) + ':' + s;
if t < 10 then s:= '0' + s;
s:= inttostr(i div 60) + ':' + s;
-
+
if timeTexture <> nil then
FreeTexture(timeTexture);
timeTexture:= nil;
-
+
tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), cWhiteColorChannels);
tmpSurface:= doSurfaceConversion(tmpSurface);
timeTexture:= Surface2Tex(tmpSurface, false);
@@ -946,7 +946,7 @@
sfToBlack, sfFromBlack: Tint(0, 0, 0, ScreenFadeValue * 255 div 1000);
sfToWhite, sfFromWhite: Tint($FF, $FF, $FF, ScreenFadeValue * 255 div 1000);
end;
-
+
VertexBuffer[0].X:= -cScreenWidth;
VertexBuffer[0].Y:= cScreenHeight;
VertexBuffer[1].X:= -cScreenWidth;
@@ -955,7 +955,7 @@
VertexBuffer[2].Y:= 0;
VertexBuffer[3].X:= cScreenWidth;
VertexBuffer[3].Y:= cScreenHeight;
-
+
glDisable(GL_TEXTURE_2D);
glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
@@ -991,7 +991,7 @@
procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup);
begin
//if Group in [capgrpGameState] then WriteLnToConsole(s);
- if Captions[Group].Tex <> nil then
+ if Captions[Group].Tex <> nil then
FreeTexture(Captions[Group].Tex);
Captions[Group].Tex:= nil;
@@ -1117,7 +1117,7 @@
if time = 0 then time:= 5000;
missionTimer:= time;
-if missionTex <> nil then
+if missionTex <> nil then
FreeTexture(missionTex);
missionTex:= nil;
@@ -1159,7 +1159,7 @@
Frames:= 0;
WorldDx:= -512;
WorldDy:= -256;
-
+
FPS:= 0;
CountTicks:= 0;
SoundTimerTicks:= 0;
@@ -1168,7 +1168,7 @@
missionTimer:= 0;
missionTex:= nil;
cOffsetY:= 0;
-
+
FillChar(Captions, sizeof(Captions), 0)
end;
--- a/misc/liblua/CMakeLists.txt Sat Jul 31 10:52:43 2010 +0200
+++ b/misc/liblua/CMakeLists.txt Sat Jul 31 11:24:53 2010 +0200
@@ -1,9 +1,9 @@
-file(GLOB lua_src *.c *.h)
+file(GLOB lua_src *.c *.h)
set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH})
IF(APPLE)
-# set(CMAKE_OSX_ARCHITECTURES "x86_64;i386;ppc7400")
-
+# set(CMAKE_OSX_ARCHITECTURES "x86_64;i386;ppc7400")
+
set(build_type STATIC)
add_definitions(-DLUA_USE_LINUX)
add_library (lua ${build_type} ${lua_src})
--- a/misc/liblua/lapi.c Sat Jul 31 10:52:43 2010 +0200
+++ b/misc/liblua/lapi.c Sat Jul 31 11:24:53 2010 +0200
@@ -211,7 +211,7 @@
api_checkvalidindex(L, o);
if (idx == LUA_ENVIRONINDEX) {
Closure *func = curr_func(L);
- api_check(L, ttistable(L->top - 1));
+ api_check(L, ttistable(L->top - 1));
func->c.env = hvalue(L->top - 1);
luaC_barrier(L, func, L->top - 1);
}
@@ -771,7 +771,7 @@
#define checkresults(L,na,nr) \
api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)))
-
+
LUA_API void lua_call (lua_State *L, int nargs, int nresults) {
StkId func;
--- a/misc/liblua/ldblib.c Sat Jul 31 10:52:43 2010 +0200
+++ b/misc/liblua/ldblib.c Sat Jul 31 11:24:53 2010 +0200
@@ -138,7 +138,7 @@
treatstackoption(L, L1, "func");
return 1; /* return table */
}
-
+
static int db_getlocal (lua_State *L) {
int arg;
--- a/misc/liblua/ldebug.c Sat Jul 31 10:52:43 2010 +0200
+++ b/misc/liblua/ldebug.c Sat Jul 31 11:24:53 2010 +0200
@@ -184,7 +184,7 @@
int i;
for (i=0; i<f->l.p->sizelineinfo; i++)
setbvalue(luaH_setnum(L, t, lineinfo[i]), 1);
- sethvalue(L, L->top, t);
+ sethvalue(L, L->top, t);
}
incr_top(L);
}
--- a/misc/liblua/ldo.c Sat Jul 31 10:52:43 2010 +0200
+++ b/misc/liblua/ldo.c Sat Jul 31 11:24:53 2010 +0200
@@ -365,7 +365,7 @@
** The arguments are on the stack, right after the function.
** When returns, all the results are on the stack, starting at the original
** function position.
-*/
+*/
void luaD_call (lua_State *L, StkId func, int nResults) {
if (++L->nCcalls >= LUAI_MAXCCALLS) {
if (L->nCcalls == LUAI_MAXCCALLS)
--- a/misc/liblua/lgc.c Sat Jul 31 10:52:43 2010 +0200
+++ b/misc/liblua/lgc.c Sat Jul 31 11:24:53 2010 +0200
@@ -310,7 +310,7 @@
traverseproto(g, p);
return sizeof(Proto) + sizeof(Instruction) * p->sizecode +
sizeof(Proto *) * p->sizep +
- sizeof(TValue) * p->sizek +
+ sizeof(TValue) * p->sizek +
sizeof(int) * p->sizelineinfo +
sizeof(LocVar) * p->sizelocvars +
sizeof(TString *) * p->sizeupvalues;
@@ -697,7 +697,7 @@
GCObject *o = obj2gco(uv);
o->gch.next = g->rootgc; /* link upvalue into `rootgc' list */
g->rootgc = o;
- if (isgray(o)) {
+ if (isgray(o)) {
if (g->gcstate == GCSpropagate) {
gray2black(o); /* closed upvalues need barrier */
luaC_barrier(L, uv, uv->v);
--- a/misc/liblua/llimits.h Sat Jul 31 10:52:43 2010 +0200
+++ b/misc/liblua/llimits.h Sat Jul 31 11:24:53 2010 +0200
@@ -107,7 +107,7 @@
#ifndef lua_lock
-#define lua_lock(L) ((void) 0)
+#define lua_lock(L) ((void) 0)
#define lua_unlock(L) ((void) 0)
#endif
@@ -118,7 +118,7 @@
/*
** macro to control inclusion of some hard tests on stack reallocation
-*/
+*/
#ifndef HARDSTACKTESTS
#define condhardstacktests(x) ((void)0)
#else
--- a/misc/liblua/loadlib.c Sat Jul 31 10:52:43 2010 +0200
+++ b/misc/liblua/loadlib.c Sat Jul 31 11:24:53 2010 +0200
@@ -502,7 +502,7 @@
** 'module' function
** =======================================================
*/
-
+
static void setfenv (lua_State *L) {
lua_Debug ar;
@@ -632,7 +632,7 @@
lua_setfield(L, -2, "__gc");
/* create `package' table */
luaL_register(L, LUA_LOADLIBNAME, pk_funcs);
-#if defined(LUA_COMPAT_LOADLIB)
+#if defined(LUA_COMPAT_LOADLIB)
lua_getfield(L, -1, "loadlib");
lua_setfield(L, LUA_GLOBALSINDEX, "loadlib");
#endif
--- a/misc/liblua/lobject.h Sat Jul 31 10:52:43 2010 +0200
+++ b/misc/liblua/lobject.h Sat Jul 31 11:24:53 2010 +0200
@@ -337,7 +337,7 @@
typedef struct Table {
CommonHeader;
- lu_byte flags; /* 1<<p means tagmethod(p) is not present */
+ lu_byte flags; /* 1<<p means tagmethod(p) is not present */
lu_byte lsizenode; /* log2 of size of `node' array */
struct Table *metatable;
TValue *array; /* array part */
--- a/misc/liblua/lopcodes.h Sat Jul 31 10:52:43 2010 +0200
+++ b/misc/liblua/lopcodes.h Sat Jul 31 11:24:53 2010 +0200
@@ -186,8 +186,8 @@
OP_LT,/* A B C if ((RK(B) < RK(C)) ~= A) then pc++ */
OP_LE,/* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */
-OP_TEST,/* A C if not (R(A) <=> C) then pc++ */
-OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */
+OP_TEST,/* A C if not (R(A) <=> C) then pc++ */
+OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */
OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */
OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */
@@ -197,8 +197,8 @@
if R(A) <?= R(A+1) then { pc+=sBx; R(A+3)=R(A) }*/
OP_FORPREP,/* A sBx R(A)-=R(A+2); pc+=sBx */
-OP_TFORLOOP,/* A C R(A+3), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2));
- if R(A+3) ~= nil then R(A+2)=R(A+3) else pc++ */
+OP_TFORLOOP,/* A C R(A+3), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2));
+ if R(A+3) ~= nil then R(A+2)=R(A+3) else pc++ */
OP_SETLIST,/* A B C R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B */
OP_CLOSE,/* A close all variables in the stack up to (>=) R(A)*/
@@ -240,7 +240,7 @@
** bits 4-5: B arg mode
** bit 6: instruction set register A
** bit 7: operator is a test
-*/
+*/
enum OpArgMask {
OpArgN, /* argument is not used */
--- a/misc/liblua/lstate.c Sat Jul 31 10:52:43 2010 +0200
+++ b/misc/liblua/lstate.c Sat Jul 31 11:24:53 2010 +0200
@@ -36,7 +36,7 @@
lua_State l;
global_State g;
} LG;
-
+
static void stack_init (lua_State *L1, lua_State *L) {
--- a/misc/liblua/lstrlib.c Sat Jul 31 10:52:43 2010 +0200
+++ b/misc/liblua/lstrlib.c Sat Jul 31 11:24:53 2010 +0200
@@ -636,7 +636,7 @@
lua_pushlstring(L, s, e - s); /* keep original text */
}
else if (!lua_isstring(L, -1))
- luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1));
+ luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1));
luaL_addvalue(b); /* add result to accumulator */
}
--- a/misc/liblua/ltable.c Sat Jul 31 10:52:43 2010 +0200
+++ b/misc/liblua/ltable.c Sat Jul 31 11:24:53 2010 +0200
@@ -48,7 +48,7 @@
#define hashpow2(t,n) (gnode(t, lmod((n), sizenode(t))))
-
+
#define hashstr(t,str) hashpow2(t, (str)->tsv.hash)
#define hashboolean(t,p) hashpow2(t, p)
@@ -302,7 +302,7 @@
if (nasize > oldasize) /* array part must grow? */
setarrayvector(L, t, nasize);
/* create new hash part with appropriate size */
- setnodevector(L, t, nhsize);
+ setnodevector(L, t, nhsize);
if (nasize < oldasize) { /* array part must shrink? */
t->sizearray = nasize;
/* re-insert elements from vanishing slice */
@@ -390,11 +390,11 @@
/*
-** inserts a new key into a hash table; first, check whether key's main
-** position is free. If not, check whether colliding node is in its main
-** position or not: if it is not, move colliding node to an empty place and
-** put new key in its main position; otherwise (colliding node is in its main
-** position), new key goes to an empty position.
+** inserts a new key into a hash table; first, check whether key's main
+** position is free. If not, check whether colliding node is in its main
+** position or not: if it is not, move colliding node to an empty place and
+** put new key in its main position; otherwise (colliding node is in its main
+** position), new key goes to an empty position.
*/
static TValue *newkey (lua_State *L, Table *t, const TValue *key) {
Node *mp = mainposition(t, key);
--- a/misc/liblua/lua.h Sat Jul 31 10:52:43 2010 +0200
+++ b/misc/liblua/lua.h Sat Jul 31 11:24:53 2010 +0200
@@ -245,7 +245,7 @@
-/*
+/*
** ===============================================================
** some useful macros
** ===============================================================
--- a/misc/liblua/lualib.h Sat Jul 31 10:52:43 2010 +0200
+++ b/misc/liblua/lualib.h Sat Jul 31 11:24:53 2010 +0200
@@ -41,7 +41,7 @@
/* open all previous libraries */
-LUALIB_API void (luaL_openlibs) (lua_State *L);
+LUALIB_API void (luaL_openlibs) (lua_State *L);
--- a/misc/liblua/lvm.c Sat Jul 31 10:52:43 2010 +0200
+++ b/misc/liblua/lvm.c Sat Jul 31 11:24:53 2010 +0200
@@ -125,7 +125,7 @@
callTMres(L, val, tm, t, key);
return;
}
- t = tm; /* else repeat with `tm' */
+ t = tm; /* else repeat with `tm' */
}
luaG_runerror(L, "loop in gettable");
}
@@ -152,7 +152,7 @@
callTM(L, tm, t, key, val);
return;
}
- t = tm; /* else repeat with `tm' */
+ t = tm; /* else repeat with `tm' */
}
luaG_runerror(L, "loop in settable");
}
--- a/misc/libopenalbridge/commands.c Sat Jul 31 10:52:43 2010 +0200
+++ b/misc/libopenalbridge/commands.c Sat Jul 31 11:24:53 2010 +0200
@@ -34,26 +34,26 @@
ALfloat SourceVelocity[] = { 0.0, 0.0, 0.0 };
ALint state;
int i, j;
-
+
if (openal_ready() == AL_TRUE && index < cache_size) {
// check if sound has already a source
if (the_sounds[index].source_index != -1) {
// it has a source, check it's not playing
alGetSourcei(Sources[the_sounds[index].source_index], AL_SOURCE_STATE, &state);
- if (state != AL_PLAYING && state != AL_PAUSED) {
+ if (state != AL_PLAYING && state != AL_PAUSED) {
// it is not being played, so we can use it safely
- needsSource = AL_FALSE;
+ needsSource = AL_FALSE;
}
// else it is being played, so we have to allocate a new source for this buffer
}
-
+
if (needsSource) {
#ifdef DEBUG
fprintf(stderr,"(Bridge Debug) - looking for a source for sound %d\n", index);
#endif
for (i = 0; i < sources_number; i++) {
// let's iterate on Sources until we find a source that is not playing
- alGetSourcei(Sources[i], AL_SOURCE_STATE, &state);
+ alGetSourcei(Sources[i], AL_SOURCE_STATE, &state);
if (state != AL_PLAYING && state != AL_PAUSED) {
// let's iterate on the_sounds until we find the sound using that source
for (j = 0; j < cache_size; j++) {
@@ -66,11 +66,11 @@
break;
}
}
-
+
if (i == sources_number) {
// this means all sources are busy
}
-
+
// set source properties that it will use when it's in playback
alSourcei (Sources[i], AL_BUFFER, the_sounds[index].buffer);
alSourcef (Sources[i], AL_PITCH, 1.0f);
@@ -78,16 +78,16 @@
alSourcefv(Sources[i], AL_POSITION, SourcePosition);
alSourcefv(Sources[i], AL_VELOCITY, SourceVelocity);
alSourcei (Sources[i], AL_LOOPING, 0);
-
+
if (AL_NO_ERROR != alGetError()) {
fprintf(stderr,"(Bridge ERROR) - failed to set Source properties\n");
return;
}
the_sounds[index].source_index = i;
}
-
+
alSourcePlay(Sources[the_sounds[index].source_index]);
-
+
if (AL_NO_ERROR != alGetError()) {
fprintf(stderr,"(Bridge Warning) - failed to play sound %d\n", index);
return;
--- a/misc/libopenalbridge/commands.h Sat Jul 31 10:52:43 2010 +0200
+++ b/misc/libopenalbridge/commands.h Sat Jul 31 11:24:53 2010 +0200
@@ -22,34 +22,34 @@
#ifdef __CPLUSPLUS
extern "C" {
#endif
-
+
// play, pause, stop a single sound source
void openal_pausesound (unsigned int index);
void openal_stopsound (unsigned int index);
-
+
// play a sound and set whether it should loop or not (0/1)
void openal_playsound (unsigned int index);
-
+
void openal_freesound (unsigned int index);
-
+
// set or unset the looping property for a sound source
void openal_toggleloop (unsigned int index);
-
+
// set position and volume of a sound source
void openal_setposition (unsigned int index, float x, float y, float z);
void openal_setvolume (unsigned int index, float gain);
-
+
// set volume for all sounds (gain interval is [0-1])
void openal_setglobalvolume (float gain);
-
+
// mute or unmute all sounds
void openal_togglemute (void);
-
+
// fade effect,
void openal_fade (unsigned int index, unsigned short int quantity, al_fade_t direction);
-
+
#ifdef __CPLUSPLUS
}
#endif
-#endif /*_OALB_COMMANDS_H*/
\ No newline at end of file
+#endif /*_OALB_COMMANDS_H*/
--- a/misc/libopenalbridge/openalbridge.c Sat Jul 31 10:52:43 2010 +0200
+++ b/misc/libopenalbridge/openalbridge.c Sat Jul 31 11:24:53 2010 +0200
@@ -38,20 +38,20 @@
ALCcontext *context;
ALCdevice *device;
int i;
-
- // reuse old context and resize the existing
+
+ // reuse old context and resize the existing
if (openal_ready() == AL_TRUE) {
fprintf(stderr,"(Bridge Info) - already initialized\n");
instances_number++;
return AL_TRUE;
}
-
+
cache_pointer = 0;
instances_number++;
-
+
// initial memory size
cache_size = 50;
-
+
// open hardware device if present
device = alcOpenDevice(NULL);
sources_number = 16;
@@ -81,7 +81,7 @@
Sources = (ALuint *)Malloc (sizeof(ALuint) * sources_number);
alGenSources(sources_number, Sources);
-
+
// set the listener gain, position (on xyz axes), velocity (one value for each axe) and orientation
// Position, Velocity and Orientation of the listener
ALfloat ListenerPos[] = {0.0, 0.0, 0.0};
@@ -112,7 +112,7 @@
ALCcontext *context;
ALCdevice *device;
int i;
-
+
if (instances_number == 0) {
fprintf(stderr,"(Bridge Warning) - OpenAL not initialized\n");
return;
@@ -123,7 +123,7 @@
// release memory only when last session ends
return;
}
-
+
for (i = 0; i < cache_size; i++) {
openal_unloadfile(i);
}
@@ -148,7 +148,7 @@
ALboolean openal_ready (void) {
- if (instances_number >= 1)
+ if (instances_number >= 1)
return AL_TRUE;
else
return AL_FALSE;
@@ -164,12 +164,12 @@
int len, i, index = -1;
char *data;
FILE *fp;
-
+
if (openal_ready() == AL_FALSE) {
fprintf(stderr,"(Bridge Warning) - not initialized\n");
return -1;
}
-
+
// if this sound is already loaded return the index from the_sounds
len = strlen(filename);
for (i = 0; i < cache_size; i++) {
@@ -182,19 +182,19 @@
// if we don't have memory available search for a free element
if (cache_pointer >= cache_size)
if (the_sounds[i].is_used == AL_FALSE)
- index = i;
+ index = i;
}
if (index == -1 && cache_pointer >= cache_size) {
fprintf(stderr,"(Bridge Info) - No free spots found; doubling cache size\n", filename);
cache_size *= 2;
the_sounds = (al_sound_t *)Realloc (the_sounds, sizeof(al_sound_t) * cache_size);
- for (i = cache_size - 50; i < cache_size; i++)
+ for (i = cache_size - 50; i < cache_size; i++)
the_sounds[i] = new_sound_el();
- } else
+ } else
index = ++cache_pointer;
-
-
+
+
// detect the file format, as written in the first 4 bytes of the header
fp = Fopen (filename, "rb");
if (fp == NULL) {
@@ -231,13 +231,13 @@
// alGenBuffers happens here
sound_data = init_sound_el(filename);
-
+
if (AL_NO_ERROR != alGetError()) {
fprintf(stderr,"(Bridge ERROR) - Failed to allocate memory for buffer %d\n", index);
free(data);
return -5;
}
-
+
// copy pcm data in one buffer and free it
alBufferData(sound_data.buffer, format, data, bitsize, freq);
free(data);
@@ -246,7 +246,7 @@
fprintf(stderr,"(Bridge ERROR) - Failed to write data to buffer %d\n", index);
return -8;
}
-
+
// clear any AL errors beforehand
alGetError();
@@ -265,9 +265,9 @@
alGetSourcei (Sources[the_sounds[index].source_index], AL_SOURCE_STATE, &state);
if (state == AL_PLAYING || state == AL_PAUSED)
openal_stopsound(index);
-
- // free memory and
+
+ // free memory and
alDeleteBuffers (1, &the_sounds[index].buffer);
the_sounds[index] = new_sound_el();
}
-}
\ No newline at end of file
+}
--- a/misc/libopenalbridge/openalbridge.h Sat Jul 31 10:52:43 2010 +0200
+++ b/misc/libopenalbridge/openalbridge.h Sat Jul 31 11:24:53 2010 +0200
@@ -40,9 +40,9 @@
// unloads data from memory and marks a free spot
void openal_unloadfile (unsigned int index);
-
+
/******* other functions continue in commands.h *******/
-
+
#ifdef __CPLUSPLUS
}
#endif
--- a/misc/libopenalbridge/tester.c Sat Jul 31 10:52:43 2010 +0200
+++ b/misc/libopenalbridge/tester.c Sat Jul 31 11:24:53 2010 +0200
@@ -2,10 +2,10 @@
#include "openalbridge.h"
int main (int argc, int **argv) {
-
+
openal_init();
-
+
openal_close();
-
+
return 0;
-}
\ No newline at end of file
+}
--- a/misc/libopenalbridge/wrappers.c Sat Jul 31 10:52:43 2010 +0200
+++ b/misc/libopenalbridge/wrappers.c Sat Jul 31 11:24:53 2010 +0200
@@ -57,7 +57,7 @@
al_sound_t new_sound_el (void) {
al_sound_t sound;
-
+
sound.filename = NULL;
sound.buffer = -1;
sound.source_index = -1;
@@ -68,7 +68,7 @@
al_sound_t init_sound_el (const char *str) {
al_sound_t sound;
-
+
sound.filename = str;
sound.source_index = -1;
sound.is_used = AL_TRUE;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/misc/uSHA.pas Sat Jul 31 11:24:53 2010 +0200
@@ -0,0 +1,166 @@
+(*
+ * Hedgewars, a free turn based strategy game
+ * Copyright (c) 2004-2010 Andrey Korotaev <unC0Rr@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *)
+
+{$INCLUDE "options.inc"}
+
+unit uSHA;
+interface
+uses SDLh;
+
+type TSHA1Context = packed record
+ H: array[0..4] of LongWord;
+ Length, CurrLength: Int64;
+ Buf: array[0..63] of byte;
+ end;
+ TSHA1Digest = array[0..4] of LongWord;
+
+procedure SHA1Init(var Context: TSHA1Context);
+procedure SHA1Update(var Context: TSHA1Context; Buf: PByteArray; Length: LongWord);
+procedure SHA1UpdateLongwords(var Context: TSHA1Context; Buf: PLongwordArray; Length: LongWord);
+function SHA1Final(Context: TSHA1Context): TSHA1Digest;
+
+implementation
+
+function rol(x: LongWord; y: Byte): LongWord;
+begin
+ rol:= (X shl y) or (X shr (32 - y))
+end;
+
+function Ft(t, b, c, d: LongWord): LongWord;
+begin
+case t of
+ 0..19: Ft := (b and c) or ((not b) and d);
+ 20..39: Ft := b xor c xor d;
+ 40..59: Ft := (b and c) or (b and d) or (c and d);
+ else Ft := b xor c xor d;
+ end;
+end;
+
+function Kt(t: Byte): LongWord;
+begin
+ case t of
+ 0..19: Kt := $5A827999;
+ 20..39: Kt := $6ED9EBA1;
+ 40..59: Kt := $8F1BBCDC;
+ else
+ Kt := $CA62C1D6
+ end;
+end;
+
+
+procedure SHA1Hash(var Context: TSHA1Context);
+var S: array[0..4 ] of LongWord;
+ W: array[0..79] of LongWord;
+ i, t: LongWord;
+begin
+{$HINTS OFF}
+move(Context.H, S, sizeof(S));
+{$HINTS ON}
+for i:= 0 to 15 do
+ SDLNet_Write32(PLongWordArray(@Context.Buf)^[i], @W[i]);
+
+for i := 16 to 79 do
+ W[i] := rol(W[i - 3] xor W[i - 8] xor W[i - 14] xor W[i - 16], 1);
+
+for i := 0 to 79 do
+ begin
+ t:= rol(S[0], 5) + Ft(i, S[1], S[2], S[3]) + S[4] + W[i] + Kt(i);
+ S[4]:= S[3];
+ S[3]:= S[2];
+ S[2]:= rol(S[1], 30);
+ S[1]:= S[0];
+ S[0]:= t
+ end;
+
+for i := 0 to 4 do
+ Context.H[i]:= Context.H[i] + S[i]
+end;
+
+procedure SHA1Init(var Context: TSHA1Context);
+begin
+ with Context do
+ begin
+ Length := 0;
+ CurrLength:= 0;
+ H[0]:= $67452301;
+ H[1]:= $EFCDAB89;
+ H[2]:= $98BADCFE;
+ H[3]:= $10325476;
+ H[4]:= $C3D2E1F0
+ end
+end;
+
+procedure SHA1Update(var Context: TSHA1Context; Buf: PByteArray; Length: LongWord);
+var i: Longword;
+begin
+for i:= 0 to Pred(Length) do
+ begin
+ Context.Buf[Context.CurrLength]:= Buf^[i];
+ inc(Context.CurrLength);
+ if Context.CurrLength = 64 then
+ begin
+ SHA1Hash(Context);
+ inc(Context.Length, 512);
+ Context.CurrLength:= 0
+ end
+ end
+end;
+
+procedure SHA1UpdateLongwords(var Context: TSHA1Context; Buf: PLongwordArray; Length: LongWord);
+var i: Longword;
+begin
+ for i:= 0 to Pred(Length div 4) do
+ begin
+ SDLNet_Write32(Buf^[i], @Context.Buf[Context.CurrLength]);
+ inc(Context.CurrLength, 4);
+ if Context.CurrLength = 64 then
+ begin
+ SHA1Hash(Context);
+ inc(Context.Length, 512);
+ Context.CurrLength:= 0
+ end
+ end
+end;
+
+function SHA1Final(Context: TSHA1Context): TSHA1Digest;
+var i: LongWord;
+begin
+ Context.Length:= Context.Length + Context.CurrLength shl 3;
+ Context.Buf[Context.CurrLength]:= $80;
+ inc(Context.CurrLength);
+
+ if Context.CurrLength > 56 then
+ begin
+ FillChar(Context.Buf[Context.CurrLength], 64 - Context.CurrLength, 0);
+ Context.CurrLength:= 64;
+ SHA1Hash(Context);
+ Context.CurrLength:=0
+ end;
+
+ FillChar(Context.Buf[Context.CurrLength], 56 - Context.CurrLength, 0);
+
+ for i:= 56 to 63 do
+ Context.Buf[i] := (Context.Length shr ((63 - i) * 8)) and $FF;
+ SHA1Hash(Context);
+ for i:= 0 to 4 do
+ SHA1Final[i]:= Context.H[i];
+
+ FillChar(Context, sizeof(Context), 0)
+end;
+
+end.
--- a/misc/wrapper.c Sat Jul 31 10:52:43 2010 +0200
+++ b/misc/wrapper.c Sat Jul 31 11:24:53 2010 +0200
@@ -12,9 +12,9 @@
extern void Game (const char **);
int SDL_main (int argc, const char **argv) {
-
+
const char **gameArgs = (const char**) malloc(sizeof(char *) * 9);
-
+
gameArgs[0] = "wrapper"; //UserNick
gameArgs[1] = "0"; //ipcPort
gameArgs[2] = "0"; //isSoundEnabled
@@ -24,9 +24,9 @@
gameArgs[6] = "768"; //cScreenHeight
gameArgs[7] = "1024"; //cScreenHeight
gameArgs[8] = "Save.hws"; //recordFileName
-
+
Game(gameArgs);
free(gameArgs);
-
+
return 0;
}
--- a/misc/xfire/xfiregameclient.cpp Sat Jul 31 10:52:43 2010 +0200
+++ b/misc/xfire/xfiregameclient.cpp Sat Jul 31 11:24:53 2010 +0200
@@ -29,7 +29,7 @@
#ifdef Module32Next
#undef Module32Next
-#endif
+#endif
int XfireIsLoaded()
@@ -99,7 +99,7 @@
if (snapshot_handle != INVALID_HANDLE_VALUE)
{
MODULEENTRY32 module_entry;
- module_entry.dwSize = sizeof(MODULEENTRY32);
+ module_entry.dwSize = sizeof(MODULEENTRY32);
BOOL result = Module32First(snapshot_handle, &module_entry);
char module_name[] = "xfire_toucan";
--- a/project_files/HedgewarsMobile/Classes/CommodityFunctions.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/CommodityFunctions.m Sat Jul 31 11:24:53 2010 +0200
@@ -14,16 +14,16 @@
void createTeamNamed (NSString *nameWithoutExt) {
NSString *teamsDirectory = TEAMS_DIRECTORY();
-
+
if (![[NSFileManager defaultManager] fileExistsAtPath: teamsDirectory]) {
- [[NSFileManager defaultManager] createDirectoryAtPath:teamsDirectory
- withIntermediateDirectories:NO
- attributes:nil
+ [[NSFileManager defaultManager] createDirectoryAtPath:teamsDirectory
+ withIntermediateDirectories:NO
+ attributes:nil
error:NULL];
}
-
+
NSMutableArray *hedgehogs = [[NSMutableArray alloc] initWithCapacity: MAX_HOGS];
-
+
for (int i = 0; i < MAX_HOGS; i++) {
NSString *hogName = [[NSString alloc] initWithFormat:@"hedgehog %d",i];
NSDictionary *hog = [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:0],@"level",
@@ -32,12 +32,12 @@
[hedgehogs addObject:hog];
[hog release];
}
-
+
NSDictionary *theTeam = [[NSDictionary alloc] initWithObjectsAndKeys:@"0",@"hash",
@"Statue",@"grave", @"Plane",@"fort", @"Default",@"voicepack",
@"hedgewars",@"flag", hedgehogs,@"hedgehogs", nil];
[hedgehogs release];
-
+
NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", teamsDirectory, nameWithoutExt];
[theTeam writeToFile:teamFile atomically:YES];
@@ -49,21 +49,21 @@
NSString *weaponsDirectory = WEAPONS_DIRECTORY();
if (![[NSFileManager defaultManager] fileExistsAtPath: weaponsDirectory]) {
- [[NSFileManager defaultManager] createDirectoryAtPath:weaponsDirectory
- withIntermediateDirectories:NO
- attributes:nil
+ [[NSFileManager defaultManager] createDirectoryAtPath:weaponsDirectory
+ withIntermediateDirectories:NO
+ attributes:nil
error:NULL];
}
-
+
NSDictionary *theWeapon = [[NSDictionary alloc] initWithObjectsAndKeys:
[NSNumber numberWithInt:CURRENT_AMMOSIZE],@"version",
@"9391929422199121032235111001201000000211110111",@"ammostore_initialqt",
@"0405040541600655546554464776576666666155510111",@"ammostore_probability",
@"0000000000000205500000040007004000000000200000",@"ammostore_delay",
@"1311110312111111123114111111111111111211111111",@"ammostore_crate", nil];
-
+
NSString *weaponFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", weaponsDirectory, nameWithoutExt];
-
+
[theWeapon writeToFile:weaponFile atomically:YES];
[weaponFile release];
[theWeapon release];
@@ -71,14 +71,14 @@
void createSchemeNamed (NSString *nameWithoutExt) {
NSString *schemesDirectory = SCHEMES_DIRECTORY();
-
+
if (![[NSFileManager defaultManager] fileExistsAtPath: schemesDirectory]) {
- [[NSFileManager defaultManager] createDirectoryAtPath:schemesDirectory
- withIntermediateDirectories:NO
- attributes:nil
+ [[NSFileManager defaultManager] createDirectoryAtPath:schemesDirectory
+ withIntermediateDirectories:NO
+ attributes:nil
error:NULL];
}
-
+
NSArray *theScheme = [[NSArray alloc] initWithObjects:
[NSNumber numberWithBool:NO], //fortmode
[NSNumber numberWithBool:NO], //divideteam
@@ -107,7 +107,7 @@
[NSNumber numberWithInt:0], //dudmines
[NSNumber numberWithInt:2], //explosives
nil];
-
+
NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@.plist", schemesDirectory, nameWithoutExt];
[theScheme writeToFile:schemeFile atomically:YES];
@@ -117,7 +117,7 @@
BOOL rotationManager (UIInterfaceOrientation interfaceOrientation) {
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight) ||
- (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
+ (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
NSInteger randomPort () {
@@ -140,17 +140,17 @@
mach_port_t host_port;
mach_msg_type_number_t host_size;
vm_size_t pagesize;
-
+
host_port = mach_host_self();
host_size = sizeof(vm_statistics_data_t) / sizeof(integer_t);
- host_page_size(host_port, &pagesize);
-
+ host_page_size(host_port, &pagesize);
+
vm_statistics_data_t vm_stat;
-
+
if (host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vm_stat, &host_size) != KERN_SUCCESS)
DLog(@"Failed to fetch vm statistics");
-
- /* Stats in bytes */
+
+ /* Stats in bytes */
natural_t mem_used = (vm_stat.active_count + vm_stat.inactive_count + vm_stat.wire_count) * pagesize;
natural_t mem_free = vm_stat.free_count * pagesize;
natural_t mem_total = mem_used + mem_free;
@@ -164,12 +164,12 @@
NSString *modelType () {
size_t size;
// set 'oldp' parameter to NULL to get the size of the data returned so we can allocate appropriate amount of space
- sysctlbyname("hw.machine", NULL, &size, NULL, 0);
+ sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *name = (char *)malloc(sizeof(char) * size);
// get the platform name
sysctlbyname("hw.machine", name, &size, NULL, 0);
NSString *modelId = [NSString stringWithUTF8String:name];
free(name);
-
+
return modelId;
-}
\ No newline at end of file
+}
--- a/project_files/HedgewarsMobile/Classes/DetailViewController.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/DetailViewController.m Sat Jul 31 11:24:53 2010 +0200
@@ -30,24 +30,24 @@
self.title = NSLocalizedString(@"Settings",@"");
// allocate controllers and store them into the array
- NSArray *array= [[NSArray alloc] initWithObjects:NSLocalizedString(@"General",@""),
+ NSArray *array= [[NSArray alloc] initWithObjects:NSLocalizedString(@"General",@""),
NSLocalizedString(@"Teams",@""),
NSLocalizedString(@"Weapons",@""),
NSLocalizedString(@"Schemes",@""),
nil];
self.controllerNames = array;
[array release];
-
+
// on ipad make the general setting the first view, on iphone add the "Done" button on top left
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
-
+
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(112, 112, 480, 320)];
label.text = @"Press the buttons on the left";
label.font = [UIFont systemFontOfSize:20];
label.textAlignment = UITextAlignmentCenter;
[self.view addSubview:label];
[label release];
-
+
//[self.navigationController pushViewController:nextController animated:NO];
} else {
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
@@ -62,7 +62,7 @@
#pragma mark -
#pragma mark Table view data source
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
- // don't display
+ // don't display
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
return 0;
else
@@ -75,19 +75,19 @@
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
-
+
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
- cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
+ cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier] autorelease];
}
-
+
NSInteger row = [indexPath row];
-
+
cell.textLabel.text = [controllerNames objectAtIndex:row];
cell.imageView.image = [UIImage imageNamed:@"Icon.png"];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
-
+
return cell;
}
@@ -96,7 +96,7 @@
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSInteger row = [indexPath row];
UIViewController *nextController = nil;
-
+
switch (row) {
case 0:
if (nil == generalSettingsViewController)
@@ -119,7 +119,7 @@
nextController = schemeSettingsViewController;
break;
}
-
+
nextController.title = [controllerNames objectAtIndex:row];
[self.navigationController pushViewController:nextController animated:YES];
}
@@ -137,7 +137,7 @@
}
// Called when the master view controller is about to be hidden
--(void) splitViewController: (UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController
+-(void) splitViewController: (UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController
withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController: (UIPopoverController*)pc {
/* barButtonItem.title = @"Master View";
@@ -154,7 +154,7 @@
}
// Called when the master view controller is about to appear
--(void) splitViewController: (UISplitViewController*)svc willShowViewController:(UIViewController *)aViewController
+-(void) splitViewController: (UISplitViewController*)svc willShowViewController:(UIViewController *)aViewController
invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem {
/*UIToolbar *toolbar = self.parentViewController.navigationController.toolbar;
--- a/project_files/HedgewarsMobile/Classes/EditableCellView.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/EditableCellView.m Sat Jul 31 11:24:53 2010 +0200
@@ -15,7 +15,7 @@
-(id) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) {
delegate = nil;
-
+
textField = [[UITextField alloc] initWithFrame:CGRectZero];
textField.backgroundColor = [UIColor clearColor];
textField.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]];
@@ -25,17 +25,17 @@
textField.returnKeyType = UIReturnKeyDone;
textField.adjustsFontSizeToFitWidth = YES;
[textField addTarget:self action:@selector(save:) forControlEvents:UIControlEventEditingDidEndOnExit];
-
+
[self.contentView addSubview:textField];
//[textField release];
-
+
titleLabel = [[UILabel alloc] init];
titleLabel.textAlignment = UITextAlignmentLeft;
titleLabel.backgroundColor = [UIColor clearColor];
titleLabel.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]];
[self.contentView addSubview:titleLabel];
//[titleLabel release];
-
+
minimumCharacters = 1;
maximumCharacters = 64;
oldValue = nil;
@@ -48,12 +48,12 @@
CGRect contentRect = self.contentView.bounds;
CGFloat boundsX = contentRect.origin.x;
-
+
int offset = 0;
int skew = 0;
if (self.imageView != nil)
offset += self.imageView.frame.size.width;
-
+
if ([self.titleLabel.text length] == 0)
titleLabel.frame = CGRectZero;
else {
@@ -94,16 +94,16 @@
-(void) textFieldDidBeginEditing:(UITextField *)aTextField{
// don't interact with table below
((UITableView*)[self superview]).scrollEnabled = NO;
-
+
self.oldValue = self.textField.text;
-
+
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Cancel",@"")
style:UIBarButtonItemStylePlain
target:self
action:@selector(cancel:)];
[(UITableViewController *)delegate navigationItem].leftBarButtonItem = cancelButton;
[cancelButton release];
-
+
UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Save",@"")
style:UIBarButtonItemStyleDone
target:self
@@ -116,18 +116,18 @@
use method below instead that allows some more interaction
// don't accept 0-length strings
-(BOOL) textFieldShouldEndEditing:(UITextField *)aTextField {
- return ([aTextField.text length] > 0);
+ return ([aTextField.text length] > 0);
}
*/
-(BOOL) textFieldShouldReturn:(UITextField *)aTextField {
- return ([aTextField.text length] >= self.minimumCharacters);
+ return ([aTextField.text length] >= self.minimumCharacters);
}
// the textfield has been modified, tell the delegate to do something
-(void) textFieldDidEndEditing:(UITextField *)aTextField{
((UITableView*)[self superview]).scrollEnabled = YES;
-
+
[(UITableViewController *)delegate navigationItem].rightBarButtonItem = [(UITableViewController *)delegate navigationItem].backBarButtonItem;
[(UITableViewController *)delegate navigationItem].leftBarButtonItem = nil;
}
@@ -149,11 +149,11 @@
-(void) save:(id) sender {
if (delegate == nil || ![delegate respondsToSelector:@selector(saveTextFieldValue:withTag:)])
return;
-
+
// don't save if the textfield is invalid
if (![self textFieldShouldReturn:textField])
return;
-
+
[delegate saveTextFieldValue:self.textField.text withTag:self.tag];
[self.textField resignFirstResponder];
self.oldValue = nil;
--- a/project_files/HedgewarsMobile/Classes/FlagsViewController.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/FlagsViewController.m Sat Jul 31 11:24:53 2010 +0200
@@ -24,7 +24,7 @@
[super viewDidLoad];
self.flagArray = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:FLAGS_DIRECTORY() error:NULL];
-
+
self.title = NSLocalizedString(@"Set team flag",@"");
}
@@ -47,22 +47,22 @@
// Customize the appearance of table view cells.
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-
+
static NSString *CellIdentifier = @"Cell";
-
+
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
-
+
NSString *flag = [flagArray objectAtIndex:[indexPath row]];
-
+
NSString *flagFile = [[NSString alloc] initWithFormat:@"%@/%@", FLAGS_DIRECTORY(), flag];
UIImage *flagSprite = [[UIImage alloc] initWithContentsOfFile:flagFile];
[flagFile release];
cell.imageView.image = flagSprite;
[flagSprite release];
-
+
cell.textLabel.text = [flag stringByDeletingPathExtension];
if ([cell.textLabel.text isEqualToString:[self.teamDictionary objectForKey:@"flag"]]) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
@@ -70,7 +70,7 @@
} else {
cell.accessoryType = UITableViewCellAccessoryNone;
}
-
+
return cell;
}
@@ -80,7 +80,7 @@
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
int newRow = [indexPath row];
int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1;
-
+
if (newRow != oldRow) {
// if the two selected rows differ update data on the hog dictionary and reload table content
[self.teamDictionary setValue:[[flagArray objectAtIndex:newRow] stringByDeletingPathExtension] forKey:@"flag"];
--- a/project_files/HedgewarsMobile/Classes/FortsViewController.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/FortsViewController.m Sat Jul 31 11:24:53 2010 +0200
@@ -32,11 +32,11 @@
NSString *currentName = [directoryContents objectAtIndex:i];
NSString *correctName = [currentName substringToIndex:([currentName length] - 5)];
[filteredContents addObject:correctName];
- }
+ }
}
self.fortArray = filteredContents;
[filteredContents release];
-
+
/*
// this creates a scaled down version of the image
NSMutableArray *spriteArray = [[NSMutableArray alloc] initWithCapacity:[fortArray count]];
@@ -50,10 +50,10 @@
self.fortSprites = spriteArray;
[spriteArray release];
*/
-
+
// statically set row height instead of using delegate method for performance reasons
self.tableView.rowHeight = 200;
-
+
self.title = NSLocalizedString(@"Choose team fort",@"");
}
@@ -78,16 +78,16 @@
// Customize the appearance of table view cells.
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
-
+
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:CellIdentifier] autorelease];
}
-
+
NSString *fortName = [fortArray objectAtIndex:[indexPath row]];
cell.textLabel.text = fortName;
-
+
// this creates a scaled down version of the image
// TODO: create preview files, scaling is way too slow!
NSString *fortFile = [[NSString alloc] initWithFormat:@"%@/%@L.png", FORTS_DIRECTORY(), fortName];
@@ -95,7 +95,7 @@
[fortFile release];
cell.imageView.image = [fortSprite scaleToSize:CGSizeMake(196,196)];
[fortSprite release];
-
+
cell.detailTextLabel.text = @"Insert funny description here";
if ([cell.textLabel.text isEqualToString:[self.teamDictionary objectForKey:@"fort"]]) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
@@ -103,7 +103,7 @@
} else {
cell.accessoryType = UITableViewCellAccessoryNone;
}
-
+
return cell;
}
@@ -113,14 +113,14 @@
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
int newRow = [indexPath row];
int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1;
-
+
if (newRow != oldRow) {
// if the two selected rows differ update data on the hog dictionary and reload table content
[self.teamDictionary setValue:[fortArray objectAtIndex:newRow] forKey:@"fort"];
// tell our boss to write this new stuff on disk
[[NSNotificationCenter defaultCenter] postNotificationName:@"setWriteNeedTeams" object:nil];
-
+
UITableViewCell *newCell = [aTableView cellForRowAtIndexPath:indexPath];
newCell.accessoryType = UITableViewCellAccessoryCheckmark;
UITableViewCell *oldCell = [aTableView cellForRowAtIndexPath:lastIndexPath];
--- a/project_files/HedgewarsMobile/Classes/GameConfigViewController.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/GameConfigViewController.m Sat Jul 31 11:24:53 2010 +0200
@@ -43,7 +43,7 @@
[alert release];
} else {
[[self parentViewController] dismissModalViewControllerAnimated:YES];
-
+
}
break;
case 1:
@@ -83,9 +83,9 @@
activeController = schemeWeaponConfigViewController;
break;
}
-
+
// this message is compulsory otherwise the table won't be loaded at all
- [activeController viewWillAppear:NO];
+ [activeController viewWillAppear:NO];
[self.view addSubview:activeController.view];
}
@@ -103,7 +103,7 @@
[alert release];
return;
}
-
+
// play only if there is more than one team
if ([teamConfigViewController.listOfSelectedTeams count] < 2) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Too few teams playing",@"")
@@ -115,7 +115,7 @@
[alert release];
return;
}
-
+
// play if there's room for enough hogs in the selected map
int hogs = 0;
for (NSDictionary *teamData in teamConfigViewController.listOfSelectedTeams)
@@ -131,7 +131,7 @@
[alert release];
return;
}
-
+
if ([schemeWeaponConfigViewController.selectedScheme length] == 0 || [schemeWeaponConfigViewController.selectedWeapon length] == 0 ) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Missing detail",@"")
message:NSLocalizedString(@"Select one Scheme and one Weapon for this game",@"")
@@ -142,7 +142,7 @@
[alert release];
return;
}
-
+
// create the configuration file that is going to be sent to engine
NSDictionary *gameDictionary = [NSDictionary dictionaryWithObjectsAndKeys:mapConfigViewController.seedCommand,@"seed_command",
mapConfigViewController.templateFilterCommand,@"templatefilter_command",
@@ -154,28 +154,28 @@
schemeWeaponConfigViewController.selectedScheme,@"scheme",
schemeWeaponConfigViewController.selectedWeapon,@"weapon",
nil];
-
+
// finally launch game and remove this controller
DLog(@"sending config %@", gameDictionary);
-
+
if ([[gameDictionary allKeys] count] == 9) {
[[SDLUIKitDelegate sharedAppDelegate] startSDLgame:gameDictionary];
} else {
DLog(@"gameconfig data not complete!!\nmapConfigViewController = %@\nteamConfigViewController = %@\nschemeWeaponConfigViewController = %@\n",
mapConfigViewController, teamConfigViewController, schemeWeaponConfigViewController);
[self.parentViewController dismissModalViewControllerAnimated:YES];
-
+
// present an alert to the user, with an image on the ipad (too big for the iphone)
NSString *msg = NSLocalizedString(@"Something went wrong with your configuration. Please try again.",@"");
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
msg = [msg stringByAppendingString:@"\n\n\n\n\n\n\n\n"]; // this makes space for the image
-
+
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Whoops"
message:msg
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
-
+
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
UIImageView *deniedImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:@"denied.png"]];
deniedImg.frame = CGRectMake(25, 80, 240, 160);
@@ -190,7 +190,7 @@
-(void) viewDidLoad {
self.view.backgroundColor = [UIColor blackColor];
-
+
CGRect screen = [[UIScreen mainScreen] bounds];
self.view.frame = CGRectMake(0, 0, screen.size.height, screen.size.width);
@@ -220,9 +220,9 @@
[self.view addSubview:schemeWeaponConfigViewController.view];
}
activeController = mapConfigViewController;
-
+
[self.view addSubview:mapConfigViewController.view];
-
+
[super viewDidLoad];
}
@@ -231,7 +231,7 @@
[teamConfigViewController viewWillAppear:animated];
[schemeWeaponConfigViewController viewWillAppear:animated];
// ADD other controllers here
-
+
[super viewWillAppear:animated];
}
@@ -243,12 +243,12 @@
}
-(void) didReceiveMemoryWarning {
- if (activeController.view.superview == nil)
+ if (activeController.view.superview == nil)
activeController = nil;
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
- if (mapConfigViewController.view.superview == nil)
+ if (mapConfigViewController.view.superview == nil)
mapConfigViewController = nil;
if (teamConfigViewController.view.superview == nil)
teamConfigViewController = nil;
--- a/project_files/HedgewarsMobile/Classes/GameSetup.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/GameSetup.m Sat Jul 31 11:24:53 2010 +0200
@@ -21,14 +21,14 @@
-(id) initWithDictionary:(NSDictionary *)gameDictionary {
if (self = [super init]) {
ipcPort = randomPort();
-
+
// should check they exist and throw and exection if not
NSDictionary *dictSett = [[NSDictionary alloc] initWithContentsOfFile:SETTINGS_FILE()];
self.systemSettings = dictSett;
[dictSett release];
-
+
self.gameConfig = gameDictionary;
- }
+ }
return self;
}
@@ -47,46 +47,46 @@
addhh <level> <health> <hedgehog name>
<level> is 0 for human, 1-5 for bots (5 is the most stupid)
*/
-
+
NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@", TEAMS_DIRECTORY(), teamName];
NSDictionary *teamData = [[NSDictionary alloc] initWithContentsOfFile:teamFile];
[teamFile release];
-
- NSString *teamHashColorAndName = [[NSString alloc] initWithFormat:@"eaddteam %@ %@ %@",
+
+ NSString *teamHashColorAndName = [[NSString alloc] initWithFormat:@"eaddteam %@ %@ %@",
[teamData objectForKey:@"hash"], [teamColor stringValue], [teamName stringByDeletingPathExtension]];
[self sendToEngine: teamHashColorAndName];
[teamHashColorAndName release];
-
+
NSString *grave = [[NSString alloc] initWithFormat:@"egrave %@", [teamData objectForKey:@"grave"]];
[self sendToEngine: grave];
[grave release];
-
+
NSString *fort = [[NSString alloc] initWithFormat:@"efort %@", [teamData objectForKey:@"fort"]];
[self sendToEngine: fort];
[fort release];
-
+
NSString *voicepack = [[NSString alloc] initWithFormat:@"evoicepack %@", [teamData objectForKey:@"voicepack"]];
[self sendToEngine: voicepack];
[voicepack release];
-
+
NSString *flag = [[NSString alloc] initWithFormat:@"eflag %@", [teamData objectForKey:@"flag"]];
[self sendToEngine: flag];
[flag release];
-
+
NSArray *hogs = [teamData objectForKey:@"hedgehogs"];
for (int i = 0; i < numberOfPlayingHogs; i++) {
NSDictionary *hog = [hogs objectAtIndex:i];
-
- NSString *hogLevelHealthAndName = [[NSString alloc] initWithFormat:@"eaddhh %@ %d %@",
+
+ NSString *hogLevelHealthAndName = [[NSString alloc] initWithFormat:@"eaddhh %@ %d %@",
[hog objectForKey:@"level"], initialHealth, [hog objectForKey:@"hogname"]];
[self sendToEngine: hogLevelHealthAndName];
[hogLevelHealthAndName release];
-
+
NSString *hogHat = [[NSString alloc] initWithFormat:@"ehat %@", [hog objectForKey:@"hat"]];
[self sendToEngine: hogHat];
[hogHat release];
}
-
+
[teamData release];
}
@@ -96,34 +96,34 @@
NSDictionary *ammoData = [[NSDictionary alloc] initWithContentsOfFile:weaponPath];
[weaponPath release];
NSString *update = @"";
-
+
// if we're loading an older version of ammos fill the engine message with 0s
int diff = CURRENT_AMMOSIZE - [[ammoData objectForKey:@"version"] intValue];
if (diff != 0)
update = [NSString stringWithCharacters:(const unichar*)"0000000000000000000000000000000000" length:diff];
-
+
NSString *ammloadt = [[NSString alloc] initWithFormat:@"eammloadt %@%@", [ammoData objectForKey:@"ammostore_initialqt"], update];
[self sendToEngine: ammloadt];
[ammloadt release];
-
+
NSString *ammprob = [[NSString alloc] initWithFormat:@"eammprob %@%@", [ammoData objectForKey:@"ammostore_probability"], update];
[self sendToEngine: ammprob];
[ammprob release];
-
+
NSString *ammdelay = [[NSString alloc] initWithFormat:@"eammdelay %@%@", [ammoData objectForKey:@"ammostore_delay"], update];
[self sendToEngine: ammdelay];
[ammdelay release];
-
+
NSString *ammreinf = [[NSString alloc] initWithFormat:@"eammreinf %@%@", [ammoData objectForKey:@"ammostore_crate"], update];
[self sendToEngine: ammreinf];
[ammreinf release];
-
+
// sent twice so it applies to both teams
NSString *ammstore = [[NSString alloc] initWithString:@"eammstore"];
for (int i = 0; i < numberOfTeams; i++)
[self sendToEngine: ammstore];
[ammstore release];
-
+
[ammoData release];
}
@@ -138,76 +138,76 @@
if ([[scheme objectAtIndex:i++] boolValue])
result |= 0x01;
if ([[scheme objectAtIndex:i++] boolValue])
- result |= 0x10;
+ result |= 0x10;
if ([[scheme objectAtIndex:i++] boolValue])
result |= 0x04;
if ([[scheme objectAtIndex:i++] boolValue])
- result |= 0x08;
+ result |= 0x08;
if ([[scheme objectAtIndex:i++] boolValue])
result |= 0x20;
if ([[scheme objectAtIndex:i++] boolValue])
- result |= 0x40;
+ result |= 0x40;
if ([[scheme objectAtIndex:i++] boolValue])
result |= 0x80;
if ([[scheme objectAtIndex:i++] boolValue])
- result |= 0x100;
+ result |= 0x100;
if ([[scheme objectAtIndex:i++] boolValue])
result |= 0x200;
if ([[scheme objectAtIndex:i++] boolValue])
- result |= 0x400;
+ result |= 0x400;
if ([[scheme objectAtIndex:i++] boolValue])
result |= 0x800;
if ([[scheme objectAtIndex:i++] boolValue])
- result |= 0x2000;
+ result |= 0x2000;
if ([[scheme objectAtIndex:i++] boolValue])
result |= 0x4000;
if ([[scheme objectAtIndex:i++] boolValue])
- result |= 0x8000;
+ result |= 0x8000;
if ([[scheme objectAtIndex:i++] boolValue])
result |= 0x10000;
if ([[scheme objectAtIndex:i++] boolValue])
result |= 0x20000;
if ([[scheme objectAtIndex:i++] boolValue])
- result |= 0x80000;
+ result |= 0x80000;
NSString *flags = [[NSString alloc] initWithFormat:@"e$gmflags %d",result];
[self sendToEngine:flags];
[flags release];
-
+
NSString *dmgMod = [[NSString alloc] initWithFormat:@"e$damagepct %d",[[scheme objectAtIndex:i++] intValue]];
[self sendToEngine:dmgMod];
[dmgMod release];
-
+
NSString *turnTime = [[NSString alloc] initWithFormat:@"e$turntime %d",[[scheme objectAtIndex:i++] intValue] * 1000];
[self sendToEngine:turnTime];
[turnTime release];
-
+
result = [[scheme objectAtIndex:i++] intValue]; // initial health
-
+
NSString *sdTime = [[NSString alloc] initWithFormat:@"e$sd_turns %d",[[scheme objectAtIndex:i++] intValue]];
[self sendToEngine:sdTime];
[sdTime release];
-
+
NSString *crateDrops = [[NSString alloc] initWithFormat:@"e$casefreq %d",[[scheme objectAtIndex:i++] intValue]];
[self sendToEngine:crateDrops];
[crateDrops release];
-
+
NSString *minesTime = [[NSString alloc] initWithFormat:@"e$minestime %d",[[scheme objectAtIndex:i++] intValue] * 1000];
[self sendToEngine:minesTime];
[minesTime release];
-
+
NSString *minesNumber = [[NSString alloc] initWithFormat:@"e$landadds %d",[[scheme objectAtIndex:i++] intValue]];
[self sendToEngine:minesNumber];
[minesNumber release];
-
+
NSString *dudMines = [[NSString alloc] initWithFormat:@"e$minedudpct %d",[[scheme objectAtIndex:i++] intValue]];
[self sendToEngine:dudMines];
[dudMines release];
-
+
NSString *explosives = [[NSString alloc] initWithFormat:@"e$explosives %d",[[scheme objectAtIndex:i++] intValue]];
[self sendToEngine:explosives];
[explosives release];
-
+
[scheme release];
return result;
}
@@ -223,7 +223,7 @@
// wrapper that computes the length of the message and then sends the command string
-(int) sendToEngine: (NSString *)string {
uint8_t length = [string length];
-
+
SDLNet_TCP_Send(csd, &length , 1);
return SDLNet_TCP_Send(csd, [string UTF8String], length);
}
@@ -238,7 +238,7 @@
char buffer[BUFFER_SIZE];
uint8_t msgSize;
uint16_t gameTicks;
-
+
clientQuit = NO;
csd = NULL;
@@ -246,24 +246,24 @@
DLog(@"SDLNet_Init: %s", SDLNet_GetError());
clientQuit = YES;
}
-
+
// Resolving the host using NULL make network interface to listen
if (SDLNet_ResolveHost(&ip, NULL, ipcPort) < 0 && !clientQuit) {
DLog(@"SDLNet_ResolveHost: %s\n", SDLNet_GetError());
clientQuit = YES;
}
-
- // Open a connection with the IP provided (listen on the host's port)
+
+ // Open a connection with the IP provided (listen on the host's port)
if (!(sd = SDLNet_TCP_Open(&ip)) && !clientQuit) {
DLog(@"SDLNet_TCP_Open: %s %\n", SDLNet_GetError(), ipcPort);
clientQuit = YES;
}
-
+
DLog(@"Waiting for a client on port %d", ipcPort);
- while (csd == NULL)
+ while (csd == NULL)
csd = SDLNet_TCP_Accept(sd);
SDLNet_TCP_Close(sd);
-
+
while (!clientQuit) {
msgSize = 0;
memset(buffer, 0, BUFFER_SIZE);
@@ -271,41 +271,41 @@
clientQuit = YES;
if (SDLNet_TCP_Recv(csd, buffer, msgSize) <=0)
clientQuit = YES;
-
+
switch (buffer[0]) {
case 'C':
DLog(@"sending game config...\n%@",self.gameConfig);
-
+
// local game
[self sendToEngine:@"TL"];
-
+
// seed info
[self sendToEngine:[self.gameConfig objectForKey:@"seed_command"]];
-
+
// dimension of the map
[self sendToEngine:[self.gameConfig objectForKey:@"templatefilter_command"]];
[self sendToEngine:[self.gameConfig objectForKey:@"mapgen_command"]];
[self sendToEngine:[self.gameConfig objectForKey:@"mazesize_command"]];
-
+
// static land (if set)
NSString *staticMap = [self.gameConfig objectForKey:@"staticmap_command"];
if ([staticMap length] != 0)
[self sendToEngine:staticMap];
-
+
// theme info
[self sendToEngine:[self.gameConfig objectForKey:@"theme_command"]];
-
+
// scheme (returns initial health)
NSInteger health = [self provideScheme:[self.gameConfig objectForKey:@"scheme"]];
-
+
NSArray *teamsConfig = [self.gameConfig objectForKey:@"teams_list"];
for (NSDictionary *teamData in teamsConfig) {
- [self provideTeamData:[teamData objectForKey:@"team"]
+ [self provideTeamData:[teamData objectForKey:@"team"]
forHogs:[[teamData objectForKey:@"number"] intValue]
withHealth:health
ofColor:[teamData objectForKey:@"color"]];
}
-
+
[self provideAmmoData:[self.gameConfig objectForKey:@"weapon"] forPlayingTeams:[teamsConfig count]];
break;
case '?':
@@ -320,7 +320,7 @@
sscanf(buffer, "%*s %d", &eProto);
short int netProto = 0;
char *versionStr;
-
+
HW_versionInfo(&netProto, &versionStr);
if (netProto == eProto) {
DLog(@"Setting protocol version %d (%s)", eProto, versionStr);
@@ -328,7 +328,7 @@
DLog(@"ERROR - wrong protocol number: [%s] - expecting %d", &buffer[1], eProto);
clientQuit = YES;
}
-
+
break;
case 'i':
switch (buffer[1]) {
@@ -351,9 +351,9 @@
// wait a little to let the client close cleanly
[NSThread sleepForTimeInterval:2];
// Close the client socket
- SDLNet_TCP_Close(csd);
+ SDLNet_TCP_Close(csd);
SDLNet_Quit();
-
+
[pool release];
//Invoking this method should be avoided as it does not give your thread a chance to clean up any resources it allocated during its execution.
//[NSThread exit];
@@ -370,21 +370,21 @@
NSString *hSize = [[NSString alloc] initWithFormat:@"%d", (int) screenBounds.size.height];
const char **gameArgs = (const char**) malloc(sizeof(char *) * 10);
NSInteger tmpQuality;
-
+
NSString *modelId = modelType();
if ([modelId hasPrefix:@"iPhone1"] || // = iPhone or iPhone 3G
[modelId hasPrefix:@"iPod1,1"] || [modelId hasPrefix:@"iPod2,1"]) // = iPod Touch or iPod Touch 2G
tmpQuality = 0x00000001 | 0x00000002 | 0x00000040; // rqLowRes | rqBlurryLand | rqKillFlakes
else if ([modelId hasPrefix:@"iPhone2"] || // = iPhone 3GS
[modelId hasPrefix:@"iPod3"]) // = iPod Touch 3G
- tmpQuality = 0x00000002 | 0x00000040; // rqBlurryLand | rqKillFlakes
+ tmpQuality = 0x00000002 | 0x00000040; // rqBlurryLand | rqKillFlakes
else if ([modelId hasPrefix:@"iPad1"]) // = iPad
tmpQuality = 0x00000002; // rqBlurryLand
else // = everything else
tmpQuality = 0; // full quality
if (![modelId hasPrefix:@"iPad"]) // = disable tooltips unless iPad
tmpQuality = tmpQuality | 0x00000400;
-
+
gameArgs[9] = [[[NSNumber numberWithInteger:tmpQuality] stringValue] UTF8String];
// prevents using an empty nickname
@@ -394,7 +394,7 @@
username = [[NSString alloc] initWithFormat:@"MobileUser-%@",ipcString];
else
username = [[NSString alloc] initWithString:originalUsername];
-
+
gameArgs[0] = [username UTF8String]; //UserNick
gameArgs[1] = [ipcString UTF8String]; //ipcPort
gameArgs[2] = [[[self.systemSettings objectForKey:@"sound"] stringValue] UTF8String]; //isSoundEnabled
@@ -404,7 +404,7 @@
gameArgs[6] = [wSize UTF8String]; //cScreenHeight
gameArgs[7] = [hSize UTF8String]; //cScreenWidth
gameArgs[8] = NULL; //recordFileName
-
+
[wSize release];
[hSize release];
[localeString release];
--- a/project_files/HedgewarsMobile/Classes/GeneralSettingsViewController.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/GeneralSettingsViewController.m Sat Jul 31 11:24:53 2010 +0200
@@ -25,7 +25,7 @@
-(void) viewWillAppear:(BOOL)animated {
[self.tableView setContentOffset:CGPointMake(0,0) animated:NO];
-
+
NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] initWithContentsOfFile:SETTINGS_FILE()];
self.settingsDictionary = dictionary;
[dictionary release];
@@ -34,7 +34,7 @@
}
-(void) viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
+ [super viewWillDisappear:animated];
[self.settingsDictionary writeToFile:SETTINGS_FILE() atomically:YES];
}
@@ -42,7 +42,7 @@
-(void) switchValueChanged:(id) sender {
UISwitch *theSwitch = (UISwitch *)sender;
UISwitch *theOtherSwitch = nil;
-
+
switch (theSwitch.tag) {
case 10: //soundSwitch
// this turn off also the switch below
@@ -123,7 +123,7 @@
static NSString *cellIdentifier1 = @"Cell1";
NSInteger row = [indexPath row];
NSInteger section = [indexPath section];
-
+
UITableViewCell *cell = nil;
EditableCellView *editableCell = nil;
if (section == 0) {
@@ -135,7 +135,7 @@
editableCell.textField.font = [UIFont systemFontOfSize:[UIFont systemFontSize]];
editableCell.textField.textColor = [UIColor lightGrayColor];
}
-
+
if (row == 0) {
editableCell.titleLabel.text = NSLocalizedString(@"Nickname","from the settings table");
editableCell.textField.placeholder = NSLocalizedString(@"Insert your username (if you have one)",@"");
@@ -149,7 +149,7 @@
editableCell.textField.secureTextEntry = YES;
editableCell.tag = 50;
}
-
+
editableCell.accessoryView = nil;
cell = editableCell;
} else {
@@ -161,7 +161,7 @@
cell.accessoryView = theSwitch;
[theSwitch release];
}
-
+
UISwitch *switchContent = (UISwitch *)cell.accessoryView;
if (section == 1) {
if (row == 0) {
@@ -179,11 +179,11 @@
switchContent.tag = 30;
}
}
-
+
cell.accessoryType = UITableViewCellAccessoryNone;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.imageView.image = nil;
-
+
return cell;
}
@@ -212,7 +212,7 @@
headerLabel.text = @"!";
break;
}
-
+
[containerView addSubview:headerLabel];
return containerView;
}
--- a/project_files/HedgewarsMobile/Classes/GravesViewController.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/GravesViewController.m Sat Jul 31 11:24:53 2010 +0200
@@ -26,7 +26,7 @@
// load all the grave names and store them into graveArray
self.graveArray = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:GRAVES_DIRECTORY() error:NULL];
-
+
self.title = NSLocalizedString(@"Choose hedgehog graves",@"");
}
@@ -51,14 +51,14 @@
// Customize the appearance of table view cells.
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
-
+
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
-
+
NSString *grave = [self.graveArray objectAtIndex:[indexPath row]];
cell.textLabel.text = [grave stringByDeletingPathExtension];
-
+
if ([grave isEqualToString:[self.teamDictionary objectForKey:@"grave"]]) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
self.lastIndexPath = indexPath;
@@ -69,10 +69,10 @@
NSString *graveFilePath = [[NSString alloc] initWithFormat:@"%@/%@",GRAVES_DIRECTORY(),grave];
// because we also have multi frame graves, let's take the first one only
UIImage *graveSprite = [[UIImage alloc] initWithContentsOfFile:graveFilePath andCutAt:CGRectMake(0, 0, 32, 32)];
- [graveFilePath release];
+ [graveFilePath release];
cell.imageView.image = graveSprite;
[graveSprite release];
-
+
return cell;
}
@@ -82,13 +82,13 @@
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
int newRow = [indexPath row];
int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1;
-
+
if (newRow != oldRow) {
[teamDictionary setObject:[[graveArray objectAtIndex:newRow] stringByDeletingPathExtension] forKey:@"grave"];
-
+
// tell our boss to write this new stuff on disk
[[NSNotificationCenter defaultCenter] postNotificationName:@"setWriteNeedTeams" object:nil];
-
+
UITableViewCell *newCell = [aTableView cellForRowAtIndexPath:indexPath];
newCell.accessoryType = UITableViewCellAccessoryCheckmark;
UITableViewCell *oldCell = [aTableView cellForRowAtIndexPath:lastIndexPath];
--- a/project_files/HedgewarsMobile/Classes/HogButtonView.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/HogButtonView.m Sat Jul 31 11:24:53 2010 +0200
@@ -16,11 +16,11 @@
-(id) initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
self.backgroundColor = [UIColor clearColor];
-
+
NSString *normalHogFile = [[NSString alloc] initWithFormat:@"%@/Hedgehog.png",GRAPHICS_DIRECTORY()];
UIImage *normalHogSprite = [[UIImage alloc] initWithContentsOfFile:normalHogFile andCutAt:CGRectMake(96, 0, 32, 32)];
[normalHogFile release];
-
+
self.singleHog = normalHogSprite;
[normalHogSprite release];
[self addTarget:self action:@selector(addOne) forControlEvents:UIControlEventTouchUpInside];
@@ -46,11 +46,11 @@
numberOfHogs = MAX_HOGS;
}
[ownerDictionary setObject:[NSNumber numberWithInt:numberOfHogs] forKey:@"number"];
-
+
UIImage *teamHogs = [[[UIImage alloc] init] autorelease];
for (int i = 0; i < numberOfHogs; i++) {
teamHogs = [singleHog mergeWith:teamHogs
- atPoint:CGPointMake(8, 0)
+ atPoint:CGPointMake(8, 0)
atSize:CGSizeMake(88, 32)];
}
[self setImage:teamHogs forState:UIControlStateNormal];
--- a/project_files/HedgewarsMobile/Classes/HogHatViewController.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/HogHatViewController.m Sat Jul 31 11:24:53 2010 +0200
@@ -28,7 +28,7 @@
NSString *hatsDirectory = HATS_DIRECTORY();
NSArray *array = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:hatsDirectory error:NULL];
self.hatArray = array;
-
+
// load the base hog image, drawing will occure in cellForRow...
NSString *normalHogFile = [[NSString alloc] initWithFormat:@"%@/Hedgehog.png",GRAPHICS_DIRECTORY()];
UIImage *hogSprite = [[UIImage alloc] initWithContentsOfFile:normalHogFile andCutAt:CGRectMake(96, 0, 32, 32)];
@@ -41,7 +41,7 @@
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
-
+
// this updates the hog name and its hat
[self.tableView reloadData];
// this moves the tableview to the top
@@ -61,23 +61,23 @@
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-
+
static NSString *CellIdentifier = @"Cell";
-
+
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- if (cell == nil)
+ if (cell == nil)
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
-
+
NSDictionary *hog = [[self.teamDictionary objectForKey:@"hedgehogs"] objectAtIndex:selectedHog];
NSString *hat = [hatArray objectAtIndex:[indexPath row]];
cell.textLabel.text = [hat stringByDeletingPathExtension];
-
+
NSString *hatFile = [[NSString alloc] initWithFormat:@"%@/%@", HATS_DIRECTORY(), hat];
UIImage *hatSprite = [[UIImage alloc] initWithContentsOfFile: hatFile andCutAt:CGRectMake(0, 0, 32, 32)];
[hatFile release];
cell.imageView.image = [self.normalHogSprite mergeWith:hatSprite atPoint:CGPointMake(0, -5)];
[hatSprite release];
-
+
if ([hat isEqualToString:[hog objectForKey:@"hat"]]) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
self.lastIndexPath = indexPath;
@@ -94,27 +94,27 @@
- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
int newRow = [indexPath row];
int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1;
-
+
if (newRow != oldRow) {
// if the two selected rows differ update data on the hog dictionary and reload table content
// TODO: maybe this section could be cleaned up
NSDictionary *oldHog = [[teamDictionary objectForKey:@"hedgehogs"] objectAtIndex:selectedHog];
-
+
NSMutableDictionary *newHog = [[NSMutableDictionary alloc] initWithDictionary: oldHog];
[newHog setObject:[[hatArray objectAtIndex:newRow] stringByDeletingPathExtension] forKey:@"hat"];
[[teamDictionary objectForKey:@"hedgehogs"] replaceObjectAtIndex:selectedHog withObject:newHog];
[newHog release];
-
+
// tell our boss to write this new stuff on disk
[[NSNotificationCenter defaultCenter] postNotificationName:@"setWriteNeedTeams" object:nil];
-
+
UITableViewCell *newCell = [aTableView cellForRowAtIndexPath:indexPath];
newCell.accessoryType = UITableViewCellAccessoryCheckmark;
UITableViewCell *oldCell = [aTableView cellForRowAtIndexPath:lastIndexPath];
oldCell.accessoryType = UITableViewCellAccessoryNone;
self.lastIndexPath = indexPath;
[aTableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
- }
+ }
[aTableView deselectRowAtIndexPath:indexPath animated:YES];
[self.navigationController popViewControllerAnimated:YES];
}
--- a/project_files/HedgewarsMobile/Classes/InGameMenuViewController.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/InGameMenuViewController.m Sat Jul 31 11:24:53 2010 +0200
@@ -33,12 +33,12 @@
nil];
self.menuList = array;
[array release];
-
+
// save the sdl window (!= uikit window) for future reference
SDL_VideoDevice *_this = SDL_GetVideoDevice();
SDL_VideoDisplay *display = &_this->displays[0];
sdlwindow = display->windows;
-
+
[super viewDidLoad];
}
@@ -59,7 +59,7 @@
CGRect screen = [[UIScreen mainScreen] bounds];
self.view.backgroundColor = [UIColor clearColor];
self.view.frame = CGRectMake(screen.size.height, 0, 200, 170);
-
+
[UIView beginAnimations:@"showing popover" context:NULL];
[UIView setAnimationDuration:0.35];
self.view.frame = CGRectMake(screen.size.height-200, 0, 200, 170);
@@ -72,9 +72,9 @@
[UIView setAnimationDuration:0.35];
self.view.frame = CGRectMake(screen.size.height, 0, 200, 170);
[UIView commitAnimations];
-
+
[self.view performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:0.35];
-
+
[self removeChat];
}
@@ -90,23 +90,23 @@
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = @"CellIdentifier";
-
+
UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (nil == cell) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:cellIdentifier] autorelease];
}
cell.textLabel.text = [menuList objectAtIndex:[indexPath row]];
-
+
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
cell.textLabel.textAlignment = UITextAlignmentCenter;
-
+
return cell;
}
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UIActionSheet *actionSheet;
-
+
switch ([indexPath row]) {
case 0:
HW_pause();
@@ -136,13 +136,13 @@
otherButtonTitles:nil];
[actionSheet showInView:self.view];
[actionSheet release];
-
+
break;
default:
DLog(@"Warning: unset case value in section!");
break;
}
-
+
[aTableView deselectRowAtIndexPath:indexPath animated:YES];
}
@@ -163,9 +163,9 @@
self.view.frame = CGRectMake(screen.size.height-200, 0, 200, 170);
[UIView commitAnimations];
}
-
+
if ([actionSheet cancelButtonIndex] != buttonIndex)
- HW_terminate(NO);
+ HW_terminate(NO);
}
@end
--- a/project_files/HedgewarsMobile/Classes/LevelViewController.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/LevelViewController.m Sat Jul 31 11:24:53 2010 +0200
@@ -34,7 +34,7 @@
nil];
self.levelArray = array;
[array release];
-
+
self.title = NSLocalizedString(@"Set difficulty level",@"");
}
@@ -58,13 +58,13 @@
// Customize the appearance of table view cells.
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
-
+
NSInteger row = [indexPath row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
-
+
cell.textLabel.text = [levelArray objectAtIndex:row];
NSDictionary *hog = [[self.teamDictionary objectForKey:@"hedgehogs"] objectAtIndex:0];
if ([[hog objectForKey:@"level"] intValue] == row) {
@@ -73,7 +73,7 @@
} else {
cell.accessoryType = UITableViewCellAccessoryNone;
}
-
+
NSString *botlevelPath = [[NSString alloc] initWithFormat:@"%@/%d.png",BOTLEVELS_DIRECTORY(),row];
UIImage *levelImage = [[UIImage alloc] initWithContentsOfFile:botlevelPath];
[botlevelPath release];
@@ -96,14 +96,14 @@
/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
-
+
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
- }
+ }
else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
- }
+ }
}
*/
@@ -129,18 +129,18 @@
- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
int newRow = [indexPath row];
int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1;
-
+
if (newRow != oldRow) {
NSMutableArray *hogs = [teamDictionary objectForKey:@"hedgehogs"];
-
+
for (NSMutableDictionary *hog in hogs) {
[hog setObject:[NSNumber numberWithInt:newRow] forKey:@"level"];
}
-
+
// tell our boss to write this new stuff on disk
[[NSNotificationCenter defaultCenter] postNotificationName:@"setWriteNeedTeams" object:nil];
[self.tableView reloadData];
-
+
self.lastIndexPath = indexPath;
[self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
}
--- a/project_files/HedgewarsMobile/Classes/MainMenuViewController.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/MainMenuViewController.m Sat Jul 31 11:24:53 2010 +0200
@@ -24,9 +24,9 @@
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
- if (settingsViewController.view.superview == nil)
+ if (settingsViewController.view.superview == nil)
settingsViewController = nil;
- if (gameConfigViewController.view.superview == nil)
+ if (gameConfigViewController.view.superview == nil)
gameConfigViewController = nil;
MSG_MEMCLEAN();
}
@@ -42,7 +42,7 @@
[NSThread detachNewThreadSelector:@selector(initAudioThread)
toTarget:self
withObject:nil];
-
+
char *ver;
HW_versionInfo(NULL, &ver);
NSString *versionNumber = [[NSString alloc] initWithCString:ver];
@@ -52,13 +52,13 @@
// listen to request to remove the modalviewcontroller
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(dismissModalViewController)
- name: @"dismissModalView"
+ name: @"dismissModalView"
object:nil];
-
+
// initialize some files the first time we load the game
- if (!([[NSFileManager defaultManager] fileExistsAtPath:SETTINGS_FILE()]))
+ if (!([[NSFileManager defaultManager] fileExistsAtPath:SETTINGS_FILE()]))
[NSThread detachNewThreadSelector:@selector(checkFirstRun) toTarget:self withObject:nil];
-
+
[super viewDidLoad];
}
@@ -67,7 +67,7 @@
-(void) checkFirstRun {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
DLog(@"First time run, creating settings files at %@", SETTINGS_FILE());
-
+
// show a popup with an indicator to make the user wait
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Please wait",@"")
message:nil
@@ -75,20 +75,20 @@
cancelButtonTitle:nil
otherButtonTitles:nil];
[alert show];
-
- UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc]
+
+ UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
indicator.center = CGPointMake(alert.bounds.size.width / 2, alert.bounds.size.height - 50);
[indicator startAnimating];
[alert addSubview:indicator];
[indicator release];
-
+
// create default files (teams/weapons/scheme)
createTeamNamed(@"Pirates");
createTeamNamed(@"Ninjas");
createWeaponNamed(@"Default");
createSchemeNamed(@"Default");
-
+
// create settings.plist
NSMutableDictionary *saveDict = [[NSMutableDictionary alloc] init];
@@ -99,8 +99,8 @@
[saveDict setObject:[NSNumber numberWithBool:NO] forKey:@"alternate"];
[saveDict writeToFile:SETTINGS_FILE() atomically:YES];
- [saveDict release];
-
+ [saveDict release];
+
// ok let the user take control
[alert dismissWithClickedButtonIndex:0 animated:YES];
[alert release];
@@ -118,7 +118,7 @@
switch (button.tag) {
case 0:
- gameConfigViewController = [[GameConfigViewController alloc] initWithNibName:@"GameConfigViewController" bundle:nil];
+ gameConfigViewController = [[GameConfigViewController alloc] initWithNibName:@"GameConfigViewController" bundle:nil];
[self presentModalViewController:gameConfigViewController animated:YES];
break;
@@ -127,7 +127,7 @@
settingsViewController = [[SplitViewRootController alloc] initWithNibName:nil bundle:nil];
settingsViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
}
-
+
[self presentModalViewController:settingsViewController animated:YES];
break;
case 3:
@@ -136,7 +136,7 @@
scroll.text = debugStr;
[debugStr release];
scroll.editable = NO;
-
+
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn addTarget:scroll action:@selector(removeFromSuperview) forControlEvents:UIControlEventTouchUpInside];
btn.backgroundColor = [UIColor blackColor];
--- a/project_files/HedgewarsMobile/Classes/MapConfigViewController.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/MapConfigViewController.m Sat Jul 31 11:24:53 2010 +0200
@@ -28,7 +28,7 @@
#pragma mark Preview Handling
-(int) sendToEngine: (NSString *)string {
unsigned char length = [string length];
-
+
SDLNet_TCP_Send(csd, &length , 1);
return SDLNet_TCP_Send(csd, [string UTF8String], length);
}
@@ -37,43 +37,43 @@
IPaddress ip;
BOOL serverQuit = NO;
static uint8_t map[128*32];
-
+
if (SDLNet_Init() < 0) {
DLog(@"SDLNet_Init: %s", SDLNet_GetError());
serverQuit = YES;
}
-
+
// Resolving the host using NULL make network interface to listen
if (SDLNet_ResolveHost(&ip, NULL, port) < 0) {
DLog(@"SDLNet_ResolveHost: %s\n", SDLNet_GetError());
serverQuit = YES;
}
-
+
// Open a connection with the IP provided (listen on the host's port)
if (!(sd = SDLNet_TCP_Open(&ip))) {
DLog(@"SDLNet_TCP_Open: %s %\n", SDLNet_GetError(), port);
serverQuit = YES;
}
-
+
// launch the preview here so that we're sure the tcp channel is open
pthread_t thread_id;
pthread_create(&thread_id, NULL, (void *)GenLandPreview, (void *)port);
pthread_detach(thread_id);
-
+
DLog(@"Waiting for a client on port %d", port);
while (!serverQuit) {
/* This check the sd if there is a pending connection.
* If there is one, accept that, and open a new socket for communicating */
csd = SDLNet_TCP_Accept(sd);
- if (NULL != csd) {
+ if (NULL != csd) {
DLog(@"Client found");
-
+
[self sendToEngine:self.seedCommand];
[self sendToEngine:self.templateFilterCommand];
[self sendToEngine:self.mapGenCommand];
[self sendToEngine:self.mazeSizeCommand];
[self sendToEngine:@"!"];
-
+
memset(map, 0, 128*32);
SDLNet_TCP_Recv(csd, map, 128*32);
SDLNet_TCP_Recv(csd, &maxHogs, sizeof(uint8_t));
@@ -82,7 +82,7 @@
serverQuit = YES;
}
}
-
+
SDLNet_TCP_Close(sd);
SDLNet_Quit();
return map;
@@ -90,7 +90,7 @@
-(void) drawingThread {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
+
// select the port for IPC and launch the preview generation through engineProtocol:
int port = randomPort();
const uint8_t *map = [self engineProtocol:port];
@@ -114,7 +114,7 @@
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceGray();
CGContextRef bitmapImage = CGBitmapContextCreate(mapExp, 256, 128, 8, 256, colorspace, kCGImageAlphaNone);
CGColorSpaceRelease(colorspace);
-
+
CGImageRef previewCGImage = CGBitmapContextCreateImage(bitmapImage);
CGContextRelease(bitmapImage);
UIImage *previewImage = [[UIImage alloc] initWithCGImage:previewCGImage];
@@ -125,23 +125,23 @@
[self performSelectorOnMainThread:@selector(setButtonImage:) withObject:[previewImage makeRoundCornersOfSize:CGSizeMake(12, 12)] waitUntilDone:NO];
[previewImage release];
[self performSelectorOnMainThread:@selector(setLabelText:) withObject:[NSString stringWithFormat:@"%d", maxHogs] waitUntilDone:NO];
-
+
// restore functionality of button and remove the spinning wheel on the main thread to prevent a leak
[self performSelectorOnMainThread:@selector(turnOnWidgets) withObject:nil waitUntilDone:NO];
-
+
[pool release];
//Invoking this method should be avoided as it does not give your thread a chance to clean up any resources it allocated during its execution.
//[NSThread exit];
/*
// http://developer.apple.com/mac/library/qa/qa2001/qa1037.html
- UIGraphicsBeginImageContext(CGSizeMake(256,128));
- CGContextRef context = UIGraphicsGetCurrentContext();
- UIGraphicsPushContext(context);
+ UIGraphicsBeginImageContext(CGSizeMake(256,128));
+ CGContextRef context = UIGraphicsGetCurrentContext();
+ UIGraphicsPushContext(context);
CGContextSetRGBFillColor(context, 0.5, 0.5, 0.7, 1.0);
CGContextFillRect(context,CGRectMake(xc,yc,1,1));
-
+
UIGraphicsPopContext();
UIImage *previewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
@@ -152,7 +152,7 @@
// don't generate a new preview while it's already generating one
if (busy)
return;
-
+
// generate a seed
CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);
NSString *seed = (NSString *)CFUUIDCreateString(kCFAllocatorDefault, uuid);
@@ -161,13 +161,13 @@
[seed release];
self.seedCommand = seedCmd;
[seedCmd release];
-
+
NSIndexPath *theIndex;
if (segmentedControl.selectedSegmentIndex != 1) {
// remove the current preview and title
[self.previewButton setImage:nil forState:UIControlStateNormal];
[self.previewButton setTitle:nil forState:UIControlStateNormal];
-
+
// don't display preview on slower device, too slow and memory hog
NSString *modelId = modelType();
if ([modelId hasPrefix:@"iPhone1"] || [modelId hasPrefix:@"iPod1,1"] || [modelId hasPrefix:@"iPod2,1"]) {
@@ -176,20 +176,20 @@
} else {
// prevent other events and add an activity while the preview is beign generated
[self turnOffWidgets];
-
+
// add a very nice spinning wheel
- UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc]
+ UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
indicator.center = CGPointMake(previewButton.bounds.size.width / 2, previewButton.bounds.size.height / 2);
indicator.tag = INDICATOR_TAG;
[indicator startAnimating];
[self.previewButton addSubview:indicator];
[indicator release];
-
+
// let's draw in a separate thread so the gui can work; at the end it restore other widgets
[NSThread detachNewThreadSelector:@selector(drawingThread) toTarget:self withObject:nil];
}
-
+
theIndex = [NSIndexPath indexPathForRow:(random()%[self.themeArray count]) inSection:0];
} else {
theIndex = [NSIndexPath indexPathForRow:(random()%[self.mapArray count]) inSection:0];
@@ -207,7 +207,7 @@
[fileImage release];
[self.previewButton setImage:[image makeRoundCornersOfSize:CGSizeMake(12, 12)] forState:UIControlStateNormal];
[image release];
-
+
// update label
maxHogs = 18;
NSString *fileCfg = [[NSString alloc] initWithFormat:@"%@/%@/map.cfg", MAPS_DIRECTORY(),[self.mapArray objectAtIndex:index]];
@@ -219,8 +219,8 @@
// set the theme and map here
self.themeCommand = [NSString stringWithFormat:@"etheme %@", [split objectAtIndex:0]];
self.staticMapCommand = [NSString stringWithFormat:@"emap %@", [self.mapArray objectAtIndex:index]];
-
- // if the number is not set we keep 18 standard;
+
+ // if the number is not set we keep 18 standard;
// sometimes it's not set but there are trailing characters, we get around them with the second equation
if ([split count] > 1 && [[split objectAtIndex:1] intValue] > 0)
maxHogs = [[split objectAtIndex:1] intValue];
@@ -244,14 +244,14 @@
self.segmentedControl.enabled = YES;
self.slider.enabled = YES;
busy = NO;
-
+
UIActivityIndicatorView *indicator = (UIActivityIndicatorView *)[self.previewButton viewWithTag:INDICATOR_TAG];
if (indicator) {
[indicator stopAnimating];
[indicator removeFromSuperview];
}
}
-
+
-(void) setLabelText:(NSString *)str {
self.maxLabel.text = str;
}
@@ -262,13 +262,13 @@
-(void) restoreBackgroundImage {
// white rounded rectangle as background image for previewButton
- UIGraphicsBeginImageContext(CGSizeMake(256,128));
- CGContextRef context = UIGraphicsGetCurrentContext();
- UIGraphicsPushContext(context);
+ UIGraphicsBeginImageContext(CGSizeMake(256,128));
+ CGContextRef context = UIGraphicsGetCurrentContext();
+ UIGraphicsPushContext(context);
CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0);
CGContextFillRect(context,CGRectMake(0,0,256,128));
-
+
UIGraphicsPopContext();
UIImage *bkgImg = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
@@ -291,15 +291,15 @@
-(UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
NSInteger row = [indexPath row];
-
+
UITableViewCell *cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier];
- if (cell == nil)
+ if (cell == nil)
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
-
+
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
cell.textLabel.textColor = [UIColor colorWithRed:(CGFloat)0xFE/255 green:(CGFloat)0xCB/255 blue:0 alpha:1 ];
}
-
+
if (self.segmentedControl.selectedSegmentIndex != 1) {
// the % prevents a strange bug that occurs sporadically
NSString *themeName = [self.themeArray objectAtIndex:row % [self.themeArray count]];
@@ -311,8 +311,8 @@
cell.textLabel.text = [self.mapArray objectAtIndex:row];
cell.imageView.image = nil;
}
-
- if (row == [self.lastIndexPath row])
+
+ if (row == [self.lastIndexPath row])
cell.accessoryType = UITableViewCellAccessoryCheckmark;
else
cell.accessoryType = UITableViewCellAccessoryNone;
@@ -326,17 +326,17 @@
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
int newRow = [indexPath row];
int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1;
-
+
if (newRow != oldRow) {
if (self.segmentedControl.selectedSegmentIndex != 1) {
- NSString *theme = [self.themeArray objectAtIndex:newRow];
+ NSString *theme = [self.themeArray objectAtIndex:newRow];
self.themeCommand = [NSString stringWithFormat:@"etheme %@", theme];
} else {
// theme and map are set in the function below
[self updatePreviewWithMap:newRow];
}
-
- UITableViewCell *newCell = [aTableView cellForRowAtIndexPath:indexPath];
+
+ UITableViewCell *newCell = [aTableView cellForRowAtIndexPath:indexPath];
newCell.accessoryType = UITableViewCellAccessoryCheckmark;
UITableViewCell *oldCell = [aTableView cellForRowAtIndexPath:self.lastIndexPath];
oldCell.accessoryType = UITableViewCellAccessoryNone;
@@ -355,7 +355,7 @@
NSString *labelText;
NSString *templateCommand;
NSString *mazeCommand;
-
+
switch ((int)(self.slider.value*100)) {
case 0:
if (self.segmentedControl.selectedSegmentIndex == 0) {
@@ -417,7 +417,7 @@
mazeCommand = nil;
break;
}
-
+
self.sizeLabel.text = labelText;
self.templateFilterCommand = templateCommand;
self.mazeSizeCommand = mazeCommand;
@@ -432,13 +432,13 @@
}
}
-// perform actions based on the activated section, then call updatePreview to visually update the selection
+// perform actions based on the activated section, then call updatePreview to visually update the selection
// updatePreview will call didSelectRowAtIndexPath which will call the right update routine)
// and if necessary update the table with a slide animation
-(IBAction) segmentedControlChanged:(id) sender {
NSString *mapgen, *staticmap;
NSInteger newPage = self.segmentedControl.selectedSegmentIndex;
-
+
switch (newPage) {
case 0: // Random
mapgen = @"e$mapgen 0";
@@ -446,7 +446,7 @@
[self sliderChanged:nil];
self.slider.enabled = YES;
break;
-
+
case 1: // Map
mapgen = @"e$mapgen 0";
// dummy value, everything is set by -updatePreview -> -didSelectRowAtIndexPath -> -updatePreviewWithMap
@@ -455,14 +455,14 @@
self.sizeLabel.text = @".";
[self restoreBackgroundImage];
break;
-
+
case 2: // Maze
mapgen = @"e$mapgen 1";
staticmap = @"";
[self sliderChanged:nil];
self.slider.enabled = YES;
break;
-
+
default:
mapgen = nil;
staticmap = nil;
@@ -471,7 +471,7 @@
self.mapGenCommand = mapgen;
self.staticMapCommand = staticmap;
[self updatePreview];
-
+
// nice animation for updating the table when appropriate (on iphone)
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
if (((oldPage == 0 || oldPage == 2) && newPage == 1) ||
@@ -487,7 +487,7 @@
// update data when table is not visible and then show it
-(void) moveTable {
[self.tableView reloadData];
-
+
[UIView beginAnimations:@"moving in table" context:NULL];
self.tableView.frame = CGRectMake(295, 0, 185, 276);
[UIView commitAnimations];
@@ -497,15 +497,15 @@
#pragma mark view management
-(void) viewDidLoad {
[super viewDidLoad];
-
+
srandom(time(NULL));
-
+
CGSize screenSize = [[UIScreen mainScreen] bounds].size;
self.view.frame = CGRectMake(0, 0, screenSize.height, screenSize.width - 44);
// themes.cfg contains all the user-selectable themes
NSString *string = [[NSString alloc] initWithContentsOfFile:[THEMES_DIRECTORY() stringByAppendingString:@"/themes.cfg"]
- encoding:NSUTF8StringEncoding
+ encoding:NSUTF8StringEncoding
error:NULL];
NSMutableArray *array = [[NSMutableArray alloc] initWithArray:[string componentsSeparatedByString:@"\n"]];
[string release];
@@ -517,14 +517,14 @@
self.tableView.rowHeight = 42;
busy = NO;
-
+
// draw a white background
[self restoreBackgroundImage];
-
+
// initialize some "default" values
self.sizeLabel.text = NSLocalizedString(@"All",@"");
self.slider.value = 0.05f;
-
+
// on slower device we show directly the static map
NSString *modelId = modelType();
if ([modelId hasPrefix:@"iPhone1"] || [modelId hasPrefix:@"iPod1,1"] || [modelId hasPrefix:@"iPod2,1"])
@@ -536,9 +536,9 @@
self.mazeSizeCommand = @"e$maze_size 0";
self.mapGenCommand = @"e$mapgen 0";
self.staticMapCommand = @"";
-
+
self.lastIndexPath = [NSIndexPath indexPathForRow:0 inSection:0];
-
+
oldValue = 5;
oldPage = 0;
}
@@ -562,18 +562,18 @@
self.mazeSizeCommand = nil;
self.themeCommand = nil;
self.staticMapCommand = nil;
-
+
self.previewButton = nil;
self.tableView = nil;
self.maxLabel = nil;
self.sizeLabel = nil;
self.segmentedControl = nil;
self.slider = nil;
-
+
self.lastIndexPath = nil;
self.themeArray = nil;
self.mapArray = nil;
-
+
MSG_DIDUNLOAD();
[super viewDidUnload];
}
@@ -585,18 +585,18 @@
[mazeSizeCommand release];
[themeCommand release];
[staticMapCommand release];
-
+
[previewButton release];
[tableView release];
[maxLabel release];
[sizeLabel release];
[segmentedControl release];
[slider release];
-
+
[lastIndexPath release];
[themeArray release];
[mapArray release];
-
+
[super dealloc];
}
--- a/project_files/HedgewarsMobile/Classes/MasterViewController.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/MasterViewController.m Sat Jul 31 11:24:53 2010 +0200
@@ -27,7 +27,7 @@
#pragma mark View lifecycle
-(void) viewDidLoad {
[super viewDidLoad];
-
+
// the list of selectable controllers
controllerNames = [[NSArray alloc] initWithObjects:NSLocalizedString(@"General",@""),
NSLocalizedString(@"Teams",@""),
@@ -54,13 +54,13 @@
// Customize the appearance of table view cells.
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
-
+
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.textLabel.text = [controllerNames objectAtIndex:[indexPath row]];
}
-
+
return cell;
}
@@ -70,11 +70,11 @@
int newRow = [indexPath row];
int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1;
UIViewController *nextController = nil;
-
+
if (newRow != oldRow) {
[self.tableView deselectRowAtIndexPath:lastIndexPath animated:YES];
[detailViewController.navigationController popToRootViewControllerAnimated:NO];
-
+
switch (newRow) {
case 0:
if (nil == generalSettingsViewController)
@@ -97,7 +97,7 @@
nextController = schemeSettingsViewController;
break;
}
-
+
nextController.navigationItem.hidesBackButton = YES;
nextController.title = [controllerNames objectAtIndex:newRow];
[detailViewController.navigationController pushViewController:nextController animated:NO];
@@ -112,7 +112,7 @@
-(void) didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
- // Relinquish ownership any cached data, images, etc that aren't in use.
+ // Relinquish ownership any cached data, images, etc that aren't in use.
if (generalSettingsViewController.view.superview == nil)
generalSettingsViewController = nil;
if (teamSettingsViewController.view.superview == nil)
--- a/project_files/HedgewarsMobile/Classes/OverlayViewController.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/OverlayViewController.m Sat Jul 31 11:24:53 2010 +0200
@@ -23,7 +23,7 @@
#define CONFIRMATION_TAG 5959
#define GRENADE_TAG 9595
#define ANIMATION_DURATION 0.25
-#define removeConfirmationInput() [[self.view viewWithTag:CONFIRMATION_TAG] removeFromSuperview];
+#define removeConfirmationInput() [[self.view viewWithTag:CONFIRMATION_TAG] removeFromSuperview];
@implementation OverlayViewController
@synthesize popoverController, popupMenu;
@@ -32,12 +32,12 @@
return rotationManager(interfaceOrientation);
}
--(void) didRotate:(NSNotification *)notification {
+-(void) didRotate:(NSNotification *)notification {
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
CGRect rect = [[UIScreen mainScreen] bounds];
CGRect usefulRect = CGRectMake(0, 0, rect.size.width, rect.size.height);
UIView *sdlView = [[[UIApplication sharedApplication] keyWindow] viewWithTag:SDL_VIEW_TAG];
-
+
[UIView beginAnimations:@"rotation" context:NULL];
[UIView setAnimationDuration:0.8f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
@@ -84,7 +84,7 @@
isPopoverVisible = NO;
self.view.alpha = 0;
self.view.center = CGPointMake(self.view.frame.size.height/2.0, self.view.frame.size.width/2.0);
-
+
// set initial orientation
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
UIView *sdlView = [[[UIApplication sharedApplication] keyWindow] viewWithTag:SDL_VIEW_TAG];
@@ -102,18 +102,18 @@
}
CGRect rect = [[UIScreen mainScreen] bounds];
self.view.frame = CGRectMake(0, 0, rect.size.width, rect.size.height);
-
+
dimTimer = [[NSTimer alloc] initWithFireDate:[NSDate dateWithTimeIntervalSinceNow:6]
interval:1000
target:self
selector:@selector(dimOverlay)
userInfo:nil
repeats:YES];
-
+
// add timer too runloop, otherwise it doesn't work
[[NSRunLoop currentRunLoop] addTimer:dimTimer forMode:NSDefaultRunLoopMode];
-
- [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
+
+ [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didRotate:)
name:UIDeviceOrientationDidChangeNotification
@@ -123,7 +123,7 @@
[UIView setAnimationDuration:1];
self.view.alpha = 1;
[UIView commitAnimations];
-
+
// find the sdl window we're on
SDL_VideoDevice *_this = SDL_GetVideoDevice();
SDL_VideoDisplay *display = &_this->displays[0];
@@ -141,7 +141,7 @@
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
- if (popupMenu.view.superview == nil)
+ if (popupMenu.view.superview == nil)
popupMenu = nil;
MSG_MEMCLEAN();
}
@@ -176,9 +176,9 @@
-(IBAction) buttonReleased:(id) sender {
if (!isGameRunning)
return;
-
+
UIButton *theButton = (UIButton *)sender;
-
+
switch (theButton.tag) {
case 0:
case 1:
@@ -202,18 +202,18 @@
doDim();
}
-// issue certain action based on the tag of the button
+// issue certain action based on the tag of the button
-(IBAction) buttonPressed:(id) sender {
[self activateOverlay];
if (isPopoverVisible) {
[self dismissPopover];
}
-
+
if (!isGameRunning)
return;
-
+
UIButton *theButton = (UIButton *)sender;
-
+
switch (theButton.tag) {
case 0:
HW_walkLeft();
@@ -267,7 +267,7 @@
if ([actionSheet cancelButtonIndex] != buttonIndex)
HW_terminate(NO);
else
- HW_pause();
+ HW_pause();
}
// show up a popover containing a popupMenuViewController; we hook it with setPopoverContentSize
@@ -277,7 +277,7 @@
isPopoverVisible = YES;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
- if (popupMenu == nil)
+ if (popupMenu == nil)
popupMenu = [[InGameMenuViewController alloc] initWithStyle:UITableViewStylePlain];
if (popoverController == nil) {
popoverController = [[UIPopoverController alloc] initWithContentViewController:popupMenu];
@@ -292,7 +292,7 @@
} else {
if (popupMenu == nil)
popupMenu = [[InGameMenuViewController alloc] initWithStyle:UITableViewStyleGrouped];
-
+
[self.view addSubview:popupMenu.view];
[popupMenu present];
}
@@ -305,7 +305,7 @@
isPopoverVisible = NO;
if (HW_isPaused())
HW_pause();
-
+
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
[(InGameMenuViewController *)popoverController.contentViewController removeChat];
[popoverController dismissPopoverAnimated:YES];
@@ -321,24 +321,24 @@
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSSet *allTouches = [event allTouches];
UITouch *first, *second;
-
+
// hide in-game menu
if (isPopoverVisible)
[self dismissPopover];
-
+
// reset default dimming
doDim();
-
+
HW_setPianoSound([allTouches count]);
-
+
switch ([allTouches count]) {
- case 1:
+ case 1:
removeConfirmationInput();
startingPoint = [[[allTouches allObjects] objectAtIndex:0] locationInView:self.view];
if (2 == [[[allTouches allObjects] objectAtIndex:0] tapCount])
HW_zoomReset();
break;
- case 2:
+ case 2:
// pinching
first = [[allTouches allObjects] objectAtIndex:0];
second = [[allTouches allObjects] objectAtIndex:1];
@@ -355,7 +355,7 @@
CGRect screen = [[UIScreen mainScreen] bounds];
NSSet *allTouches = [event allTouches];
CGPoint currentPosition = [[[allTouches allObjects] objectAtIndex:0] locationInView:self.view];
-
+
switch ([allTouches count]) {
case 1:
// if we're in the menu we just click in the point
@@ -363,12 +363,12 @@
HW_setCursor(HWXZ(currentPosition.x), HWYZ(currentPosition.y));
// this click doesn't need any wrapping because the ammoMenu already limits the cursor
HW_click();
- } else
+ } else
// if weapon requires a further click, ask for tapping again
if (HW_isWeaponRequiringClick()) {
// here don't have to wrap thanks to isCursorVisible magic
HW_setCursor(HWX(currentPosition.x), HWY(currentPosition.y));
-
+
// draw the button at the last touched point (which is the current position)
UIButton *tapAgain = [UIButton buttonWithType:UIButtonTypeRoundedRect];
tapAgain.frame = CGRectMake(currentPosition.x - 75, currentPosition.y + 25, 150, 40);
@@ -377,13 +377,13 @@
[tapAgain addTarget:self action:@selector(sendHWClick) forControlEvents:UIControlEventTouchUpInside];
[tapAgain setTitle:NSLocalizedString(@"Tap to set!",@"from the overlay") forState:UIControlStateNormal];
[self.view addSubview:tapAgain];
-
+
// animation ftw!
- [UIView beginAnimations:@"inserting button" context:NULL];
+ [UIView beginAnimations:@"inserting button" context:NULL];
[UIView setAnimationDuration:ANIMATION_DURATION];
[self.view viewWithTag:CONFIRMATION_TAG].alpha = 1;
[UIView commitAnimations];
-
+
// keep the overlay active, or the button will fade
[self activateOverlay];
doNotDim();
@@ -391,35 +391,35 @@
if (HW_isWeaponTimerable()) {
if (isSegmentVisible) {
UISegmentedControl *grenadeTime = (UISegmentedControl *)[self.view viewWithTag:GRENADE_TAG];
-
+
[UIView beginAnimations:@"removing segmented control" context:NULL];
[UIView setAnimationDuration:ANIMATION_DURATION];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
grenadeTime.frame = CGRectMake(screen.size.height / 2 - 125, screen.size.width, 250, 50);
[UIView commitAnimations];
-
+
[grenadeTime performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:ANIMATION_DURATION];
} else {
NSArray *items = [[NSArray alloc] initWithObjects:@"1",@"2",@"3",@"4",@"5",nil];
UISegmentedControl *grenadeTime = [[UISegmentedControl alloc] initWithItems:items];
[items release];
-
+
[grenadeTime addTarget:self action:@selector(setGrenadeTime:) forControlEvents:UIControlEventValueChanged];
grenadeTime.frame = CGRectMake(screen.size.height / 2 - 125, screen.size.width, 250, 50);
grenadeTime.selectedSegmentIndex = 2;
grenadeTime.tag = GRENADE_TAG;
[self.view addSubview:grenadeTime];
[grenadeTime release];
-
+
[UIView beginAnimations:@"inserting segmented control" context:NULL];
[UIView setAnimationDuration:ANIMATION_DURATION];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
grenadeTime.frame = CGRectMake(screen.size.height / 2 - 125, screen.size.width - 100, 250, 50);
[UIView commitAnimations];
-
+
[self activateOverlay];
doNotDim();
- }
+ }
isSegmentVisible = !isSegmentVisible;
} else
if (HW_isWeaponSwitch())
@@ -431,7 +431,7 @@
default:
break;
}
-
+
initialDistanceForPinching = 0;
}
@@ -454,7 +454,7 @@
CGRect screen = [[UIScreen mainScreen] bounds];
NSSet *allTouches = [event allTouches];
int x, y, dx, dy;
-
+
UITouch *touch, *first, *second;
switch ([allTouches count]) {
@@ -488,7 +488,7 @@
second = [[allTouches allObjects] objectAtIndex:1];
CGFloat currentDistanceOfPinching = distanceBetweenPoints([first locationInView:self.view], [second locationInView:self.view]);
const int pinchDelta = 40;
-
+
if (0 != initialDistanceForPinching) {
if (currentDistanceOfPinching - initialDistanceForPinching > pinchDelta) {
HW_zoomIn();
@@ -498,9 +498,9 @@
HW_zoomOut();
initialDistanceForPinching = currentDistanceOfPinching;
}
- } else
+ } else
initialDistanceForPinching = currentDistanceOfPinching;
-
+
break;
default:
break;
@@ -532,15 +532,15 @@
UIWindow *theWindow = [[UIApplication sharedApplication] keyWindow];
UIButton *theButton = (UIButton *)[theWindow viewWithTag:CONFIRMATION_TAG];
UISegmentedControl *theSegment = (UISegmentedControl *)[theWindow viewWithTag:GRENADE_TAG];
-
+
[UIView beginAnimations:@"remove button" context:NULL];
[UIView setAnimationDuration:ANIMATION_DURATION];
theButton.alpha = 0;
theSegment.alpha = 0;
[UIView commitAnimations];
-
+
[theWindow performSelector:@selector(removeFromSuperview) withObject:theButton afterDelay:0.3];
- [theWindow performSelector:@selector(removeFromSuperview) withObject:theSegment afterDelay:0.3];
+ [theWindow performSelector:@selector(removeFromSuperview) withObject:theSegment afterDelay:0.3];
}
@end
--- a/project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/SDL_uikitappdelegate.m Sat Jul 31 11:24:53 2010 +0200
@@ -1,21 +1,21 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
-
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
-
+
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
+
Sam Lantinga, mods for Hedgewars by Vittorio Giovara
slouken@libsdl.org, vittorio.giovara@gmail.com
*/
@@ -81,24 +81,24 @@
-(IBAction) startSDLgame: (NSDictionary *)gameDictionary {
// pull out useful configuration info from various files
GameSetup *setup = [[GameSetup alloc] initWithDictionary:gameDictionary];
-
+
[setup startThread:@"engineProtocol"];
const char **gameArgs = [setup getSettings];
[setup release];
// since the sdlwindow is not yet created, we add the overlayController with a delay
[self performSelector:@selector(displayOverlayLater) withObject:nil afterDelay:0.1];
-
+
// this is the pascal fuction that starts the game (wrapped around isInGame)
isInGame = YES;
Game(gameArgs);
isInGame = NO;
free(gameArgs);
-
+
// bring the uiwindow below in front
UIWindow *aWin = [[[UIApplication sharedApplication] windows] objectAtIndex:0];
[aWin makeKeyAndVisible];
-
+
// notice that in the simulator this reports 2 windows
DLog(@"%@",[[UIApplication sharedApplication] windows]);
}
@@ -114,10 +114,10 @@
// override the direct execution of SDL_main to allow us to implement the frontend (or even using a nib)
-(void) applicationDidFinishLaunching:(UIApplication *)application {
- [application setStatusBarHidden:YES];
-
+ [application setStatusBarHidden:YES];
+
UIWindow *uiwindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
-
+
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
self.mainViewController = [[MainMenuViewController alloc] initWithNibName:@"MainMenuViewController-iPad" bundle:nil];
else
@@ -135,7 +135,7 @@
-(void) applicationWillTerminate:(UIApplication *)application {
Mix_CloseAudio();
SDL_SendQuit();
-
+
if (isInGame) {
HW_terminate(YES);
// hack to prevent automatic termination. See SDL_uikitevents.m for details
@@ -152,7 +152,7 @@
-(void) applicationWillResignActive:(UIApplication *)application {
if (isInGame) {
HW_pause();
-
+
// Send every window on every screen a MINIMIZED event.
SDL_VideoDevice *_this = SDL_GetVideoDevice();
if (!_this)
--- a/project_files/HedgewarsMobile/Classes/SchemeSettingsViewController.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/SchemeSettingsViewController.m Sat Jul 31 11:24:53 2010 +0200
@@ -21,24 +21,24 @@
#pragma mark View lifecycle
-(void) viewDidLoad {
[super viewDidLoad];
-
+
UIBarButtonItem *editButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Edit",@"from the scheme panel")
style:UIBarButtonItemStyleBordered
target:self
action:@selector(toggleEdit:)];
self.navigationItem.rightBarButtonItem = editButton;
[editButton release];
-
+
}
-(void) viewWillAppear:(BOOL) animated {
[super viewWillAppear:animated];
-
+
NSArray *contentsOfDir = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:SCHEMES_DIRECTORY() error:NULL];
NSMutableArray *array = [[NSMutableArray alloc] initWithArray:contentsOfDir copyItems:YES];
self.listOfSchemes = array;
[array release];
-
+
[self.tableView reloadData];
}
@@ -46,7 +46,7 @@
-(void) toggleEdit:(id) sender {
BOOL isEditing = self.tableView.editing;
[self.tableView setEditing:!isEditing animated:YES];
-
+
if (isEditing) {
[self.navigationItem.rightBarButtonItem setTitle:NSLocalizedString(@"Edit",@"from the scheme panel")];
[self.navigationItem.rightBarButtonItem setStyle: UIBarButtonItemStyleBordered];
@@ -65,15 +65,15 @@
-(void) addScheme:(id) sender {
NSString *fileName = [[NSString alloc] initWithFormat:@"Scheme %u.plist", [self.listOfSchemes count]];
-
+
createSchemeNamed([fileName stringByDeletingPathExtension]);
-
+
[self.listOfSchemes addObject:fileName];
[fileName release];
-
+
// order the array alphabetically, so schemes will keep their position
[self.listOfSchemes sortUsingSelector:@selector(compare:)];
-
+
[self.tableView reloadData];
}
@@ -89,28 +89,28 @@
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
-
+
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
-
- NSUInteger row = [indexPath row];
- NSString *rowString = [[self.listOfSchemes objectAtIndex:row] stringByDeletingPathExtension];
- cell.textLabel.text = rowString;
+
+ NSUInteger row = [indexPath row];
+ NSString *rowString = [[self.listOfSchemes objectAtIndex:row] stringByDeletingPathExtension];
+ cell.textLabel.text = rowString;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
-
+
return cell;
}
// delete the row and the file
-(void) tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger row = [indexPath row];
-
+
NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@",SCHEMES_DIRECTORY(),[self.listOfSchemes objectAtIndex:row]];
[[NSFileManager defaultManager] removeItemAtPath:schemeFile error:NULL];
[schemeFile release];
-
+
[self.listOfSchemes removeObjectAtIndex:row];
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
@@ -121,10 +121,10 @@
if (childController == nil) {
childController = [[SingleSchemeViewController alloc] initWithStyle:UITableViewStyleGrouped];
}
-
+
NSInteger row = [indexPath row];
NSString *selectedSchemeFile = [self.listOfSchemes objectAtIndex:row];
-
+
// this must be set so childController can load the correct plist
childController.schemeName = [selectedSchemeFile stringByDeletingPathExtension];
[childController.tableView setContentOffset:CGPointMake(0,0) animated:NO];
--- a/project_files/HedgewarsMobile/Classes/SchemeWeaponConfigViewController.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/SchemeWeaponConfigViewController.m Sat Jul 31 11:24:53 2010 +0200
@@ -23,12 +23,12 @@
CGSize screenSize = [[UIScreen mainScreen] bounds].size;
self.view.frame = CGRectMake(0, 0, screenSize.height, screenSize.width - 44);
-
+
self.selectedScheme = @"";
self.selectedWeapon = @"";
-
+
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
- [self.tableView setBackgroundView:nil];
+ [self.tableView setBackgroundView:nil];
self.view.backgroundColor = [UIColor clearColor];
self.tableView.separatorColor = [UIColor colorWithRed:(CGFloat)0xFE/255 green:(CGFloat)0xCB/255 blue:0 alpha:1];
}
@@ -40,13 +40,13 @@
NSArray *contentsOfDir = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:SCHEMES_DIRECTORY() error:NULL];
self.listOfSchemes = contentsOfDir;
-
+
if ([listOfSchemes containsObject:@"Default.plist"])
self.selectedScheme = @"Default.plist";
-
+
contentsOfDir = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:WEAPONS_DIRECTORY() error:NULL];
self.listOfWeapons = contentsOfDir;
-
+
if ([listOfWeapons containsObject:@"Default.plist"])
self.selectedWeapon = @"Default.plist";
@@ -61,7 +61,7 @@
}
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- if (section == 0)
+ if (section == 0)
return [self.listOfSchemes count];
else
return [self.listOfWeapons count];
@@ -71,12 +71,12 @@
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
NSInteger row = [indexPath row];
-
+
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
-
+
cell.accessoryType = UITableViewCellAccessoryNone;
if ([indexPath section] == 0) {
cell.textLabel.text = [[self.listOfSchemes objectAtIndex:row] stringByDeletingPathExtension];
@@ -103,25 +103,25 @@
lastIndexPath = self.lastIndexPath_sc;
else
lastIndexPath = self.lastIndexPath_we;
-
+
int newRow = [indexPath row];
int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1;
-
+
if (newRow != oldRow) {
//TODO: this code works only for a single section table
UITableViewCell *newCell = [aTableView cellForRowAtIndexPath:indexPath];
newCell.accessoryType = UITableViewCellAccessoryCheckmark;
UITableViewCell *oldCell = [aTableView cellForRowAtIndexPath:lastIndexPath];
oldCell.accessoryType = UITableViewCellAccessoryNone;
-
+
if ([indexPath section] == 0) {
self.lastIndexPath_sc = indexPath;
self.selectedScheme = [self.listOfSchemes objectAtIndex:newRow];
} else {
self.lastIndexPath_we = indexPath;
self.selectedWeapon = [self.listOfWeapons objectAtIndex:newRow];
- }
-
+ }
+
[aTableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
}
[aTableView deselectRowAtIndexPath:indexPath animated:YES];
--- a/project_files/HedgewarsMobile/Classes/SingleSchemeViewController.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/SingleSchemeViewController.m Sat Jul 31 11:24:53 2010 +0200
@@ -81,7 +81,7 @@
nil];
self.gameModifierArray = mods;
[mods release];
-
+
NSArray *basicSettings = [[NSArray alloc] initWithObjects:
[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Damage Modifier",@""),@"title",@"Damage",@"image",
[NSNumber numberWithInt:100],@"default",[NSNumber numberWithInt:10],@"min",[NSNumber numberWithInt:300],@"max",nil],
@@ -104,27 +104,27 @@
nil];
self.basicSettingList = basicSettings;
[basicSettings release];
-
+
self.title = NSLocalizedString(@"Edit scheme preferences",@"");
}
// load from file
-(void) viewWillAppear:(BOOL) animated {
[super viewWillAppear:animated];
-
+
NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.schemeName];
NSMutableArray *scheme = [[NSMutableArray alloc] initWithContentsOfFile:schemeFile];
[schemeFile release];
self.schemeArray = scheme;
[scheme release];
-
+
[self.tableView reloadData];
}
// save to file
-(void) viewWillDisappear:(BOOL) animated {
[super viewWillDisappear:animated];
-
+
NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.schemeName];
[self.schemeArray writeToFile:schemeFile atomically:YES];
[schemeFile release];
@@ -133,7 +133,7 @@
#pragma mark -
#pragma mark editableCellView delegate
// set the new value
--(void) saveTextFieldValue:(NSString *)textString withTag:(NSInteger) tagValue {
+-(void) saveTextFieldValue:(NSString *)textString withTag:(NSInteger) tagValue {
// delete old file
[[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@.plist",SCHEMES_DIRECTORY(),self.schemeName] error:NULL];
// update filename
@@ -168,20 +168,20 @@
static NSString *CellIdentifier0 = @"Cell0";
static NSString *CellIdentifier1 = @"Cell1";
static NSString *CellIdentifier2 = @"Cell2";
-
+
UITableViewCell *cell = nil;
EditableCellView *editableCell = nil;
NSInteger row = [indexPath row];
-
+
switch ([indexPath section]) {
case 0:
editableCell = (EditableCellView *)[aTableView dequeueReusableCellWithIdentifier:CellIdentifier0];
if (editableCell == nil) {
- editableCell = [[[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault
+ editableCell = [[[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier0] autorelease];
editableCell.delegate = self;
}
-
+
editableCell.textField.text = self.schemeName;
editableCell.detailTextLabel.text = nil;
editableCell.imageView.image = nil;
@@ -194,13 +194,13 @@
// need to offset this section (see format in CommodityFunctions.m and above)
NSInteger gmSize = [self.gameModifierArray count];
if (cell == nil) {
- cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1
+ cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1
reuseIdentifier:CellIdentifier1] autorelease];
-
+
int offset = 0;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
offset = 50;
-
+
UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(offset+260, 12, offset+150, 23)];
slider.maximumValue = [[detail objectForKey:@"max"] floatValue];
slider.minimumValue = [[detail objectForKey:@"min"] floatValue];
@@ -208,7 +208,7 @@
[slider addTarget:self action:@selector(sliderChanged:) forControlEvents:UIControlEventValueChanged];
[cell.contentView addSubview:slider];
[slider release];
-
+
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(50, 7, 200, 30)];
label.tag = LABEL_TAG;
label.backgroundColor = [UIColor clearColor];
@@ -216,23 +216,23 @@
[cell.contentView addSubview:label];
[label release];
}
-
+
UIImage *img = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/icon%@.png",BTN_DIRECTORY(),[[self.basicSettingList objectAtIndex:row] objectForKey:@"image"]]];
cell.imageView.image = img;
[img release];
-
+
UILabel *cellLabel = (UILabel *)[cell.contentView viewWithTag:LABEL_TAG];
cellLabel.text = [[self.basicSettingList objectAtIndex:row] objectForKey:@"title"];
-
+
UISlider *cellSlider = (UISlider *)[cell.contentView viewWithTag:row+gmSize];
cellSlider.value = [[self.schemeArray objectAtIndex:row+gmSize] floatValue];
-
+
// forced to use this weird format otherwise the label disappears when size of the text is bigger than the original
NSString *prestring = [NSString stringWithFormat:@"%d",[[self.schemeArray objectAtIndex:row+gmSize] intValue]];
while ([prestring length] <= 4)
prestring = [NSString stringWithFormat:@" %@",prestring];
cell.detailTextLabel.text = prestring;
-
+
cell.selectionStyle = UITableViewCellSelectionStyleBlue;
break;
case 2:
@@ -246,7 +246,7 @@
cell.accessoryView = onOff;
[onOff release];
}
-
+
UIImage *image = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/btn%@.png",BTN_DIRECTORY(),[[self.gameModifierArray objectAtIndex:row] objectForKey:@"image"]]];
cell.imageView.image = image;
[image release];
@@ -256,10 +256,10 @@
cell.textLabel.text = [[self.gameModifierArray objectAtIndex:row] objectForKey:@"title"];
cell.detailTextLabel.text = [[self.gameModifierArray objectAtIndex:row] objectForKey:@"description"];
[(UISwitch *)cell.accessoryView setOn:[[self.schemeArray objectAtIndex:row] boolValue] animated:NO];
-
+
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
-
+
return cell;
}
@@ -291,7 +291,7 @@
UITableViewCell *cell = [aTableView cellForRowAtIndexPath:indexPath];
EditableCellView *editableCell = nil;
UISlider *cellSlider = nil;
-
+
switch ([indexPath section]) {
case 0:
editableCell = (EditableCellView *)cell;
@@ -311,7 +311,7 @@
default:
break;
}
-
+
[aTableView deselectRowAtIndexPath:indexPath animated:YES];
}
--- a/project_files/HedgewarsMobile/Classes/SingleTeamViewController.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/SingleTeamViewController.m Sat Jul 31 11:24:53 2010 +0200
@@ -48,7 +48,7 @@
#pragma mark View lifecycle
-(void) viewDidLoad {
[super viewDidLoad];
-
+
// labels for the entries
NSArray *array = [[NSArray alloc] initWithObjects:
NSLocalizedString(@"Grave",@""),
@@ -65,27 +65,27 @@
[normalHogFile release];
self.normalHogSprite = hogSprite;
[hogSprite release];
-
+
// listen if any childController modifies the plist and write it if needed
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setWriteNeeded) name:@"setWriteNeedTeams" object:nil];
isWriteNeeded = NO;
-
+
self.title = NSLocalizedString(@"Edit team settings",@"");
}
-(void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
-
+
// load data about the team and write if there has been a change from other childControllers
- if (isWriteNeeded)
+ if (isWriteNeeded)
[self writeFile];
-
+
NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",TEAMS_DIRECTORY(),self.teamName];
NSMutableDictionary *teamDict = [[NSMutableDictionary alloc] initWithContentsOfFile:teamFile];
self.teamDictionary = teamDict;
[teamDict release];
[teamFile release];
-
+
[self.tableView reloadData];
}
@@ -93,7 +93,7 @@
-(void) viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
- if (isWriteNeeded)
+ if (isWriteNeeded)
[self writeFile];
}
@@ -159,23 +159,23 @@
static NSString *CellIdentifier0 = @"Cell0";
static NSString *CellIdentifier1 = @"Cell1";
static NSString *CellIdentifier2 = @"Cell2";
-
+
NSArray *hogArray;
UITableViewCell *cell = nil;
EditableCellView *editableCell = nil;
NSInteger row = [indexPath row];
UIImage *accessoryImage;
-
+
switch ([indexPath section]) {
case 0:
editableCell = (EditableCellView *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier0];
if (editableCell == nil) {
- editableCell = [[[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault
+ editableCell = [[[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier0] autorelease];
editableCell.delegate = self;
editableCell.tag = TEAMNAME_TAG;
}
-
+
editableCell.imageView.image = nil;
editableCell.accessoryType = UITableViewCellAccessoryNone;
editableCell.textField.text = self.teamName;
@@ -185,33 +185,33 @@
case 1:
editableCell = (EditableCellView *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier1];
if (editableCell == nil) {
- editableCell = [[[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault
+ editableCell = [[[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier1] autorelease];
editableCell.delegate = self;
editableCell.tag = [indexPath row];
}
-
+
hogArray = [self.teamDictionary objectForKey:@"hedgehogs"];
-
+
// draw the hat on top of the hog
NSString *hatFile = [[NSString alloc] initWithFormat:@"%@/%@.png", HATS_DIRECTORY(), [[hogArray objectAtIndex:row] objectForKey:@"hat"]];
UIImage *hatSprite = [[UIImage alloc] initWithContentsOfFile: hatFile andCutAt:CGRectMake(0, 0, 32, 32)];
[hatFile release];
editableCell.imageView.image = [self.normalHogSprite mergeWith:hatSprite atPoint:CGPointMake(0, -5)];
[hatSprite release];
-
+
editableCell.textField.text = [[hogArray objectAtIndex:row] objectForKey:@"hogname"];
editableCell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
-
+
cell = editableCell;
break;
case 2:
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier2];
if (cell == nil) {
- cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
+ cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier2] autorelease];
}
-
+
cell.textLabel.text = [self.secondaryItems objectAtIndex:row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
switch (row) {
@@ -228,7 +228,7 @@
cell.imageView.image = [accessoryImage scaleToSize:CGSizeMake(42, 42)];
[accessoryImage release];
break;
-
+
case 3: // flags
accessoryImage = [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.png",
FLAGS_DIRECTORY(),[teamDictionary objectForKey:@"flag"]]];
@@ -249,7 +249,7 @@
}
break;
}
-
+
return cell;
}
@@ -260,41 +260,41 @@
NSInteger row = [indexPath row];
NSInteger section = [indexPath section];
UITableViewController *nextController = nil;
-
+
if (2 == section) {
switch (row) {
case 0: // grave
if (nil == gravesViewController)
gravesViewController = [[GravesViewController alloc] initWithStyle:UITableViewStyleGrouped];
-
+
nextController = gravesViewController;
break;
case 1: // voice
if (nil == voicesViewController)
voicesViewController = [[VoicesViewController alloc] initWithStyle:UITableViewStyleGrouped];
-
- nextController = voicesViewController;
+
+ nextController = voicesViewController;
break;
case 2: // fort
if (nil == fortsViewController)
fortsViewController = [[FortsViewController alloc] initWithStyle:UITableViewStyleGrouped];
-
+
nextController = fortsViewController;
break;
case 3: // flag
- if (nil == flagsViewController)
+ if (nil == flagsViewController)
flagsViewController = [[FlagsViewController alloc] initWithStyle:UITableViewStyleGrouped];
-
+
nextController = flagsViewController;
break;
case 4: // level
if (nil == levelViewController)
levelViewController = [[LevelViewController alloc] initWithStyle:UITableViewStyleGrouped];
-
+
nextController = levelViewController;
break;
}
-
+
if ([nextController respondsToSelector:@selector(setTeamDictionary:)])
[nextController setTeamDictionary:teamDictionary];
[self.navigationController pushViewController:nextController animated:YES];
@@ -310,15 +310,15 @@
-(void) tableView:(UITableView *)aTableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
if (nil == hogHatViewController)
hogHatViewController = [[HogHatViewController alloc] initWithStyle:UITableViewStyleGrouped];
-
+
// cache the dictionary file of the team, so that other controllers can modify it
hogHatViewController.teamDictionary = self.teamDictionary;
hogHatViewController.selectedHog = [indexPath row];
-
+
// if we are editing the field undo any change before proceeding
EditableCellView *cell = (EditableCellView *)[aTableView cellForRowAtIndexPath:indexPath];
[cell cancel:nil];
-
+
[self.navigationController pushViewController:hogHatViewController animated:YES];
}
--- a/project_files/HedgewarsMobile/Classes/SingleWeaponViewController.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/SingleWeaponViewController.m Sat Jul 31 11:24:53 2010 +0200
@@ -22,7 +22,7 @@
#pragma mark View lifecycle
-(void) viewDidLoad {
[super viewDidLoad];
-
+
NSArray *array = [[NSArray alloc] initWithObjects:
NSLocalizedString(@"Grenade",@""),
NSLocalizedString(@"Cluster Bomb",@""),
@@ -78,28 +78,28 @@
probability = (char *)malloc(sizeof(char)*(CURRENT_AMMOSIZE+1));
delay = (char *)malloc(sizeof(char)*(CURRENT_AMMOSIZE+1));
crateness = (char *)malloc(sizeof(char)*(CURRENT_AMMOSIZE+1));
-
+
NSString *str = [NSString stringWithFormat:@"%@/AmmoMenu/Ammos.png",GRAPHICS_DIRECTORY()];
UIImage *img = [[UIImage alloc] initWithContentsOfFile:str];
self.ammoStoreImage = img;
[img release];
-
+
self.title = NSLocalizedString(@"Edit weapons preferences",@"");
}
-(void) viewWillAppear:(BOOL) animated {
[super viewWillAppear:animated];
-
+
NSString *ammoFile = [[NSString alloc] initWithFormat:@"%@/%@.plist",WEAPONS_DIRECTORY(),self.weaponName];
NSDictionary *weapon = [[NSDictionary alloc] initWithContentsOfFile:ammoFile];
[ammoFile release];
-
+
const char *tmp1 = [[weapon objectForKey:@"ammostore_initialqt"] UTF8String];
const char *tmp2 = [[weapon objectForKey:@"ammostore_probability"] UTF8String];
const char *tmp3 = [[weapon objectForKey:@"ammostore_delay"] UTF8String];
const char *tmp4 = [[weapon objectForKey:@"ammostore_crate"] UTF8String];
[weapon release];
-
+
// if the new weaponset is diffrent from the older we need to update it replacing
// the missing ammos with 0 quantity
int oldlen = strlen(tmp1);
@@ -115,7 +115,7 @@
delay[i] = '0';
crateness[i] = '0';
}
-
+
[self.tableView reloadData];
}
@@ -129,7 +129,7 @@
probability[CURRENT_AMMOSIZE] = '\0';
delay[CURRENT_AMMOSIZE] = '\0';
crateness[CURRENT_AMMOSIZE] = '\0';
-
+
NSString *quantityStr = [NSString stringWithUTF8String:quantity];
NSString *probabilityStr = [NSString stringWithUTF8String:probability];
NSString *delayStr = [NSString stringWithUTF8String:delay];
@@ -171,11 +171,11 @@
if (0 == [indexPath section]) {
EditableCellView *customCell = (EditableCellView *)[aTableView dequeueReusableCellWithIdentifier:CellIdentifier0];
if (customCell == nil) {
- customCell = [[[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault
+ customCell = [[[EditableCellView alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier0] autorelease];
customCell.delegate = self;
}
-
+
customCell.textField.text = self.weaponName;
customCell.detailTextLabel.text = nil;
customCell.imageView.image = nil;
@@ -187,22 +187,22 @@
customCell = [[[WeaponCellView alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier1] autorelease];
customCell.delegate = self;
}
-
+
int x = ((row*32)/1024)*32;
int y = (row*32)%1024;
-
+
UIImage *img = [[self.ammoStoreImage cutAt:CGRectMake(x, y, 32, 32)] makeRoundCornersOfSize:CGSizeMake(7, 7)];
customCell.weaponIcon.image = img;
customCell.weaponName.text = [ammoNames objectAtIndex:row];
customCell.tag = row;
-
+
[customCell.initialQt setValue:[[NSString stringWithFormat:@"%c",quantity[row]] intValue] animated:NO];
[customCell.probabilityQt setValue:[[NSString stringWithFormat:@"%c", probability[row]] intValue] animated:NO];
[customCell.delayQt setValue:[[NSString stringWithFormat:@"%c", delay[row]] intValue] animated:NO];
[customCell.crateQt setValue:[[NSString stringWithFormat:@"%c", crateness[row]] intValue] animated:NO];
cell = customCell;
}
-
+
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}
@@ -226,7 +226,7 @@
#pragma mark -
#pragma mark editableCellView delegate
// set the new value
--(void) saveTextFieldValue:(NSString *)textString withTag:(NSInteger) tagValue {
+-(void) saveTextFieldValue:(NSString *)textString withTag:(NSInteger) tagValue {
// delete old file
[[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@/%@.plist",WEAPONS_DIRECTORY(),self.weaponName] error:NULL];
// update filename
--- a/project_files/HedgewarsMobile/Classes/SplitViewRootController.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/SplitViewRootController.m Sat Jul 31 11:24:53 2010 +0200
@@ -20,14 +20,14 @@
-(void) didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
- [super didReceiveMemoryWarning];
+ [super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
if (detailViewController.view.superview == nil)
detailViewController = nil;
MSG_MEMCLEAN();
}
-// load the view programmatically; we need a splitViewController that handles a MasterViewController
+// load the view programmatically; we need a splitViewController that handles a MasterViewController
// (which is just a UITableViewController) and a DetailViewController where we present options
-(void) viewDidLoad {
detailViewController = [[DetailViewController alloc] initWithStyle:UITableViewStyleGrouped];
@@ -37,20 +37,20 @@
CGRect rect = [[UIScreen mainScreen] bounds];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
self.view.frame = CGRectMake(0, 0, rect.size.height, rect.size.width);
-
+
UISplitViewController *splitViewRootController = [[UISplitViewController alloc] init];
splitViewRootController.view.frame = CGRectMake(0, 0, rect.size.height, rect.size.width);
-
+
MasterViewController *masterViewController = [[MasterViewController alloc] initWithStyle:UITableViewStylePlain];
UINavigationController *mainNavController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
[masterViewController release];
splitViewRootController.delegate = detailViewController;
- masterViewController.detailViewController = detailViewController;
+ masterViewController.detailViewController = detailViewController;
splitViewRootController.viewControllers = [NSArray arrayWithObjects: mainNavController, detailedNavController, nil];
[mainNavController release];
[detailedNavController release];
-
+
// add view to main controller
[self.view addSubview:splitViewRootController.view];
} else {
@@ -59,7 +59,7 @@
[super viewDidLoad];
}
-
+
-(void) viewDidUnload {
detailViewController = nil;
MSG_DIDUNLOAD();
--- a/project_files/HedgewarsMobile/Classes/SquareButtonView.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/SquareButtonView.m Sat Jul 31 11:24:53 2010 +0200
@@ -32,12 +32,12 @@
// set the color to the first available one
[self nextColor];
-
+
// this makes the button round and nice with a border
[self.layer setCornerRadius:7.0f];
- [self.layer setMasksToBounds:YES];
+ [self.layer setMasksToBounds:YES];
[self.layer setBorderWidth:2];
-
+
// this changes the color at button press
[self addTarget:self action:@selector(nextColor) forControlEvents:UIControlEventTouchUpInside];
}
@@ -51,11 +51,11 @@
colorIndex = 0;
NSUInteger color = [[self.colorArray objectAtIndex:colorIndex] unsignedIntValue];
- self.backgroundColor = [UIColor colorWithRed:((color & 0x00FF0000) >> 16)/255.0f
- green:((color & 0x0000FF00) >> 8)/255.0f
- blue: (color & 0x000000FF)/255.0f
+ self.backgroundColor = [UIColor colorWithRed:((color & 0x00FF0000) >> 16)/255.0f
+ green:((color & 0x0000FF00) >> 8)/255.0f
+ blue: (color & 0x000000FF)/255.0f
alpha:1.0f];
-
+
[ownerDictionary setObject:[NSNumber numberWithInt:color] forKey:@"color"];
}
@@ -63,10 +63,10 @@
if (color != selectedColor) {
selectedColor = color;
colorIndex = [colorArray indexOfObject:[NSNumber numberWithUnsignedInt:color]];
-
- self.backgroundColor = [UIColor colorWithRed:((color & 0x00FF0000) >> 16)/255.0f
- green:((color & 0x0000FF00) >> 8)/255.0f
- blue: (color & 0x000000FF)/255.0f
+
+ self.backgroundColor = [UIColor colorWithRed:((color & 0x00FF0000) >> 16)/255.0f
+ green:((color & 0x0000FF00) >> 8)/255.0f
+ blue: (color & 0x000000FF)/255.0f
alpha:1.0f];
}
}
--- a/project_files/HedgewarsMobile/Classes/TeamConfigViewController.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/TeamConfigViewController.m Sat Jul 31 11:24:53 2010 +0200
@@ -22,7 +22,7 @@
#pragma mark View lifecycle
-(void) viewDidLoad {
[super viewDidLoad];
-
+
CGSize screenSize = [[UIScreen mainScreen] bounds].size;
self.view.frame = CGRectMake(0, 0, screenSize.height, screenSize.width - 44);
isFirstLoad = YES;
@@ -47,7 +47,7 @@
}
self.listOfTeams = array;
[array release];
-
+
NSMutableArray *emptyArray = [[NSMutableArray alloc] initWithObjects:nil];
self.listOfSelectedTeams = emptyArray;
[emptyArray release];
@@ -87,7 +87,7 @@
static NSString *CellIdentifier1 = @"Cell1";
NSInteger section = [indexPath section];
UITableViewCell *cell;
-
+
if (section == 0) {
cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier0];
if (cell == nil) {
@@ -97,12 +97,12 @@
numberButton.tag = NUMBERBUTTON_TAG;
[cell addSubview:numberButton];
[numberButton release];
-
+
SquareButtonView *squareButton = [[SquareButtonView alloc] initWithFrame:CGRectMake(12+88+7, 5, 36, 36)];
squareButton.tag = SQUAREBUTTON_TAG;
[cell addSubview:squareButton];
[squareButton release];
-
+
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(12+88+7+36+7, 10, 250, 25)];
label.textAlignment = UITextAlignmentLeft;
label.backgroundColor = [UIColor clearColor];
@@ -111,16 +111,16 @@
[cell.contentView addSubview:label];
[label release];
}
-
+
NSMutableDictionary *selectedRow = [listOfSelectedTeams objectAtIndex:[indexPath row]];
-
+
UILabel *cellLabel = (UILabel *)[cell viewWithTag:LABEL_TAG];
cellLabel.text = [[selectedRow objectForKey:@"team"] stringByDeletingPathExtension];
-
+
HogButtonView *numberButton = (HogButtonView *)[cell viewWithTag:NUMBERBUTTON_TAG];
[numberButton drawManyHogs:[[selectedRow objectForKey:@"number"] intValue]];
numberButton.ownerDictionary = selectedRow;
-
+
SquareButtonView *squareButton = (SquareButtonView *)[cell viewWithTag:SQUAREBUTTON_TAG];
[squareButton selectColor:[[selectedRow objectForKey:@"color"] intValue]];
squareButton.ownerDictionary = selectedRow;
@@ -129,15 +129,15 @@
}
} else {
cell = [aTableView dequeueReusableCellWithIdentifier:CellIdentifier1];
- if (cell == nil)
+ if (cell == nil)
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier1] autorelease];
-
+
cell.textLabel.text = [[[listOfTeams objectAtIndex:[indexPath row]] objectForKey:@"team"] stringByDeletingPathExtension];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
cell.textLabel.textColor = [UIColor colorWithRed:(CGFloat)0xFE/255 green:(CGFloat)0xCB/255 blue:0 alpha:1 ];
}
}
-
+
return cell;
}
@@ -153,7 +153,7 @@
[self.listOfSelectedTeams removeObjectAtIndex:row];
} else {
[self.listOfSelectedTeams addObject:[self.listOfTeams objectAtIndex:row]];
- [self.listOfTeams removeObjectAtIndex:row];
+ [self.listOfTeams removeObjectAtIndex:row];
}
[aTableView reloadData];
}
--- a/project_files/HedgewarsMobile/Classes/TeamSettingsViewController.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/TeamSettingsViewController.m Sat Jul 31 11:24:53 2010 +0200
@@ -35,12 +35,12 @@
// load the list of teams in the teams directory
-(void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
-
+
NSArray *contentsOfDir = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:TEAMS_DIRECTORY() error:NULL];
NSMutableArray *array = [[NSMutableArray alloc] initWithArray:contentsOfDir copyItems:YES];
self.listOfTeams = array;
[array release];
-
+
[self.tableView reloadData];
}
@@ -48,7 +48,7 @@
-(void) toggleEdit:(id) sender {
BOOL isEditing = self.tableView.editing;
[self.tableView setEditing:!isEditing animated:YES];
-
+
if (isEditing) {
[self.navigationItem.rightBarButtonItem setTitle:NSLocalizedString(@"Edit",@"from the team panel")];
[self.navigationItem.rightBarButtonItem setStyle: UIBarButtonItemStyleBordered];
@@ -68,15 +68,15 @@
// add a team file with default values and updates the table
-(void) addTeam:(id) sender {
NSString *fileName = [[NSString alloc] initWithFormat:@"Default Team %u.plist", [self.listOfTeams count]];
-
+
createTeamNamed([fileName stringByDeletingPathExtension]);
-
+
[self.listOfTeams addObject:fileName];
[fileName release];
-
+
// order the array alphabetically, so teams will keep their position
[self.listOfTeams sortUsingSelector:@selector(compare:)];
-
+
[self.tableView reloadData];
}
@@ -93,28 +93,28 @@
// Customize the appearance of table view cells.
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
-
+
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
-
- NSUInteger row = [indexPath row];
- NSString *rowString = [[self.listOfTeams objectAtIndex:row] stringByDeletingPathExtension];
- cell.textLabel.text = rowString;
+
+ NSUInteger row = [indexPath row];
+ NSString *rowString = [[self.listOfTeams objectAtIndex:row] stringByDeletingPathExtension];
+ cell.textLabel.text = rowString;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
-
+
return cell;
}
// delete the row and the file
-(void) tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger row = [indexPath row];
-
+
NSString *teamFile = [[NSString alloc] initWithFormat:@"%@/%@",TEAMS_DIRECTORY(),[self.listOfTeams objectAtIndex:row]];
[[NSFileManager defaultManager] removeItemAtPath:teamFile error:NULL];
[teamFile release];
-
+
[self.listOfTeams removeObjectAtIndex:row];
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
@@ -126,10 +126,10 @@
if (childController == nil) {
childController = [[SingleTeamViewController alloc] initWithStyle:UITableViewStyleGrouped];
}
-
+
NSInteger row = [indexPath row];
NSString *selectedTeamFile = [listOfTeams objectAtIndex:row];
-
+
// this must be set so childController can load the correct plist
childController.teamName = [selectedTeamFile stringByDeletingPathExtension];
[childController.tableView setContentOffset:CGPointMake(0,0) animated:NO];
--- a/project_files/HedgewarsMobile/Classes/UIImageExtra.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/UIImageExtra.m Sat Jul 31 11:24:53 2010 +0200
@@ -10,22 +10,22 @@
@implementation UIImage (extra)
-
+
-(UIImage *)scaleToSize:(CGSize) size {
DLog(@"warning - this is a very expensive operation, you should avoid using it");
-
+
// Create a bitmap graphics context; this will also set it as the current context
UIGraphicsBeginImageContext(size);
-
+
// Draw the scaled image in the current context
[self drawInRect:CGRectMake(0, 0, size.width, size.height)];
-
+
// Create a new image from current context
UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext();
-
+
// Pop the current context from the stack
UIGraphicsEndImageContext();
-
+
// Return our new scaled image (autoreleased)
return scaledImage;
}
@@ -38,19 +38,19 @@
-(UIImage *)mergeWith:(UIImage *)secondImage atPoint:(CGPoint) secondImagePoint atSize:(CGSize) resultingSize {
// Create a bitmap graphics context; this will also set it as the current context
UIGraphicsBeginImageContext(resultingSize);
-
+
// draw the background image in the current context
[self drawAtPoint:CGPointMake(0,0)];
-
+
// draw the image on top of the first image (because the context is the same)
[secondImage drawAtPoint:secondImagePoint];
-
+
// create an image from the current contex (not thread safe)
UIImage *resultImage = UIGraphicsGetImageFromCurrentImageContext();
-
+
// free drawing contex
UIGraphicsEndImageContext();
-
+
// return the resulting autoreleased image
return resultImage;
}
@@ -58,17 +58,17 @@
-(id) initWithContentsOfFile:(NSString *)path andCutAt:(CGRect) rect {
// load image from path
UIImage *image = [[UIImage alloc] initWithContentsOfFile: path];
-
+
if (nil != image) {
// get its CGImage representation with a give size
CGImageRef cgImage = CGImageCreateWithImageInRect([image CGImage], rect);
-
+
// clean memory
[image release];
-
+
// create a UIImage from the CGImage (memory must be allocated already)
UIImage *sprite = [self initWithCGImage:cgImage];
-
+
// clean memory
CGImageRelease(cgImage);
@@ -82,38 +82,38 @@
-(UIImage *)cutAt:(CGRect) rect {
CGImageRef cgImage = CGImageCreateWithImageInRect([self CGImage], rect);
-
+
UIImage *res = [UIImage imageWithCGImage:cgImage];
CGImageRelease(cgImage);
-
+
return res;
}
-(UIImage *)convertToGrayScale {
// Create image rectangle with current image width/height
CGRect imageRect = CGRectMake(0, 0, self.size.width, self.size.height);
-
+
// Grayscale color space
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray();
-
+
// Create bitmap content with current image size and grayscale colorspace
CGContextRef context = CGBitmapContextCreate(nil, self.size.width, self.size.height, 8, 0, colorSpace, kCGImageAlphaNone);
-
+
// Draw image into current context, with specified rectangle
// using previously defined context (with grayscale colorspace)
CGContextDrawImage(context, imageRect, [self CGImage]);
-
+
// Create bitmap image info from pixel data in current context
CGImageRef imageRef = CGBitmapContextCreateImage(context);
-
- // Create a new UIImage object
+
+ // Create a new UIImage object
UIImage *newImage = [UIImage imageWithCGImage:imageRef];
-
+
// Release colorspace, context and bitmap information
CGColorSpaceRelease(colorSpace);
CGContextRelease(context);
CFRelease(imageRef);
-
+
// Return the new grayscale image
return newImage;
}
@@ -122,7 +122,7 @@
-(UIImage*) maskImageWith:(UIImage *)maskImage {
// prepare the reference image
CGImageRef maskRef = [maskImage CGImage];
-
+
// create the mask using parameters of the mask reference
CGImageRef mask = CGImageMaskCreate(CGImageGetWidth(maskRef),
CGImageGetHeight(maskRef),
@@ -130,14 +130,14 @@
CGImageGetBitsPerPixel(maskRef),
CGImageGetBytesPerRow(maskRef),
CGImageGetDataProvider(maskRef), NULL, false);
-
+
// create an image in the current context
CGImageRef masked = CGImageCreateWithMask([self CGImage], mask);
CGImageRelease(mask);
-
+
UIImage* retImage = [UIImage imageWithCGImage:masked];
CGImageRelease(masked);
-
+
return retImage;
}
@@ -162,30 +162,30 @@
CGContextRestoreGState(context);
}
--(UIImage *)makeRoundCornersOfSize:(CGSize) sizewh {
+-(UIImage *)makeRoundCornersOfSize:(CGSize) sizewh {
CGFloat cornerWidth = sizewh.width;
CGFloat cornerHeight = sizewh.height;
CGFloat w = self.size.width;
CGFloat h = self.size.height;
-
+
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(NULL, w, h, 8, 4 * w, colorSpace, kCGImageAlphaPremultipliedFirst);
-
+
CGContextBeginPath(context);
CGRect rect = CGRectMake(0, 0, w, h);
addRoundedRectToPath(context, rect, cornerWidth, cornerHeight);
CGContextClosePath(context);
CGContextClip(context);
-
+
CGContextDrawImage(context, CGRectMake(0, 0, w, h), [self CGImage]);
-
+
CGImageRef imageMasked = CGBitmapContextCreateImage(context);
CGContextRelease(context);
CGColorSpaceRelease(colorSpace);
-
+
UIImage *newImage = [UIImage imageWithCGImage:imageMasked];
CGImageRelease(imageMasked);
-
+
return newImage;
}
--- a/project_files/HedgewarsMobile/Classes/VoicesViewController.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/VoicesViewController.m Sat Jul 31 11:24:53 2010 +0200
@@ -31,13 +31,13 @@
// it's here and not in viewWillAppear because user cannot add/remove them
NSArray *array = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:VOICES_DIRECTORY() error:NULL];
self.voiceArray = array;
-
+
self.title = NSLocalizedString(@"Set hedgehog voices",@"");
}
-(void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
-
+
// this moves the tableview to the top
[self.tableView setContentOffset:CGPointMake(0,0) animated:NO];
}
@@ -64,17 +64,17 @@
// Customize the appearance of table view cells.
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-
+
static NSString *CellIdentifier = @"Cell";
-
+
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
-
+
NSString *voice = [[voiceArray objectAtIndex:[indexPath row]] stringByDeletingPathExtension];
cell.textLabel.text = voice;
-
+
if ([voice isEqualToString:[teamDictionary objectForKey:@"voicepack"]]) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
self.lastIndexPath = indexPath;
@@ -91,33 +91,33 @@
-(void) tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
int newRow = [indexPath row];
int oldRow = (lastIndexPath != nil) ? [lastIndexPath row] : -1;
-
+
if (newRow != oldRow) {
[teamDictionary setObject:[voiceArray objectAtIndex:newRow] forKey:@"voicepack"];
-
+
// tell our boss to write this new stuff on disk
[[NSNotificationCenter defaultCenter] postNotificationName:@"setWriteNeedTeams" object:nil];
[self.tableView reloadData];
-
+
self.lastIndexPath = indexPath;
[self.tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
- }
+ }
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
-
+
if (voiceBeingPlayed != NULL) {
Mix_HaltChannel(lastChannel);
Mix_FreeChunk(voiceBeingPlayed);
voiceBeingPlayed = NULL;
}
-
+
NSString *voiceDir = [[NSString alloc] initWithFormat:@"%@/%@/",VOICES_DIRECTORY(),[voiceArray objectAtIndex:newRow]];
NSArray *array = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:voiceDir error:NULL];
-
+
int index = random() % [array count];
-
+
voiceBeingPlayed = Mix_LoadWAV([[voiceDir stringByAppendingString:[array objectAtIndex:index]] UTF8String]);
[voiceDir release];
- lastChannel = Mix_PlayChannel(-1, voiceBeingPlayed, 0);
+ lastChannel = Mix_PlayChannel(-1, voiceBeingPlayed, 0);
}
--- a/project_files/HedgewarsMobile/Classes/WeaponCellView.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/WeaponCellView.m Sat Jul 31 11:24:53 2010 +0200
@@ -16,32 +16,32 @@
-(id) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) {
delegate = nil;
-
+
weaponName = [[UILabel alloc] init];
weaponName.backgroundColor = [UIColor clearColor];
weaponName.font = [UIFont boldSystemFontOfSize:[UIFont labelFontSize]];
weaponIcon = [[UIImageView alloc] init];
-
+
initialQt = [[UISlider alloc] init];
[initialQt addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
initialQt.maximumValue = 9;
initialQt.minimumValue = 0;
-
+
probabilityQt = [[UISlider alloc] init];
[probabilityQt addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
probabilityQt.maximumValue = 9;
probabilityQt.minimumValue = 0;
-
+
delayQt = [[UISlider alloc] init];
[delayQt addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
delayQt.maximumValue = 9;
delayQt.minimumValue = 0;
-
+
crateQt = [[UISlider alloc] init];
[crateQt addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
crateQt.maximumValue = 9;
crateQt.minimumValue = 0;
-
+
NSString *imgAmmoStr = [NSString stringWithFormat:@"%@/iconAmmo.png",BTN_DIRECTORY()];
NSString *imgDamageStr = [NSString stringWithFormat:@"%@/iconDamage.png",BTN_DIRECTORY()];
NSString *imgTimeStr = [NSString stringWithFormat:@"%@/iconTime.png",BTN_DIRECTORY()];
@@ -51,35 +51,35 @@
probabImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:imgDamageStr]];
delayImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:imgTimeStr]];
crateImg = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:imgBoxStr]];
-
+
initialLab = [[UILabel alloc] init];
initialLab.backgroundColor = [UIColor clearColor];
initialLab.textColor = [UIColor grayColor];
initialLab.textAlignment = UITextAlignmentCenter;
-
+
probLab = [[UILabel alloc] init];
probLab.backgroundColor = [UIColor clearColor];
probLab.textColor = [UIColor grayColor];
probLab.textAlignment = UITextAlignmentCenter;
-
+
delLab = [[UILabel alloc] init];
delLab.backgroundColor = [UIColor clearColor];
delLab.textColor = [UIColor grayColor];
delLab.textAlignment = UITextAlignmentCenter;
-
+
craLab = [[UILabel alloc] init];
craLab.backgroundColor = [UIColor clearColor];
craLab.textColor = [UIColor grayColor];
craLab.textAlignment = UITextAlignmentCenter;
-
+
[self.contentView addSubview:weaponName]; // [weaponName release];
[self.contentView addSubview:weaponIcon]; // [weaponIcon release];
-
+
[self.contentView addSubview:initialQt]; // [initialQt release];
[self.contentView addSubview:probabilityQt]; // [probabilityQt release];
[self.contentView addSubview:delayQt]; // [delayQt release];
[self.contentView addSubview:crateQt]; // [crateQt release];
-
+
[self.contentView addSubview:initialImg]; // [initialImg release];
[self.contentView addSubview:probabImg]; // [probabImg release];
[self.contentView addSubview:delayImg]; // [delayImg release];
@@ -98,7 +98,7 @@
CGRect contentRect = self.contentView.bounds;
CGFloat boundsX = contentRect.origin.x;
-
+
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
boundsX += 65;
else
@@ -106,24 +106,24 @@
weaponIcon.frame = CGRectMake(5, 5, 32, 32);
weaponName.frame = CGRectMake(45, 8, 200, 25);
-
+
// second line
initialImg.frame = CGRectMake(boundsX+20, 40, 32, 32);
initialLab.frame = CGRectMake(boundsX+56, 40, 20, 32);
initialLab.text = ((int)initialQt.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)initialQt.value];
initialQt.frame = CGRectMake(boundsX+80, 40, 150, 32);
-
+
probabImg.frame = CGRectMake(boundsX+255, 40, 32, 32);
probLab.frame = CGRectMake(boundsX+291, 40, 20, 32);
probLab.text = ((int)probabilityQt.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)probabilityQt.value];
probabilityQt.frame = CGRectMake(boundsX+314, 40, 150, 32);
-
+
// third line
delayImg.frame = CGRectMake(boundsX+20, 80, 32, 32);
delLab.frame = CGRectMake(boundsX+56, 80, 20, 32);
delLab.text = ((int)delayQt.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)delayQt.value];
delayQt.frame = CGRectMake(boundsX+80, 80, 150, 32);
-
+
crateImg.frame = CGRectMake(boundsX+255, 80, 32, 32);
craLab.frame = CGRectMake(boundsX+291, 80, 20, 32);
craLab.text = ((int)crateQt.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)crateQt.value];
@@ -143,12 +143,12 @@
probLab.text = ((int)probabilityQt.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)probabilityQt.value];
delLab.text = ((int)delayQt.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)delayQt.value];
craLab.text = ((int)crateQt.value == 9) ? @"∞" : [NSString stringWithFormat:@"%d",(int)crateQt.value];
-
+
[delegate updateValues:[NSArray arrayWithObjects:
[NSNumber numberWithInt:(int)initialQt.value],
[NSNumber numberWithInt:(int)probabilityQt.value],
[NSNumber numberWithInt:(int)delayQt.value],
- [NSNumber numberWithInt:(int)crateQt.value], nil]
+ [NSNumber numberWithInt:(int)crateQt.value], nil]
atIndex:self.tag];
} else
DLog(@"error - delegate = nil!");
--- a/project_files/HedgewarsMobile/Classes/WeaponSettingsViewController.m Sat Jul 31 10:52:43 2010 +0200
+++ b/project_files/HedgewarsMobile/Classes/WeaponSettingsViewController.m Sat Jul 31 11:24:53 2010 +0200
@@ -21,24 +21,24 @@
#pragma mark View lifecycle
-(void) viewDidLoad {
[super viewDidLoad];
-
+
UIBarButtonItem *editButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Edit",@"from the weapon panel")
style:UIBarButtonItemStyleBordered
target:self
action:@selector(toggleEdit:)];
self.navigationItem.rightBarButtonItem = editButton;
[editButton release];
-
+
}
-(void) viewWillAppear:(BOOL) animated {
[super viewWillAppear:animated];
-
+
NSArray *contentsOfDir = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:WEAPONS_DIRECTORY() error:NULL];
NSMutableArray *array = [[NSMutableArray alloc] initWithArray:contentsOfDir copyItems:YES];
self.listOfWeapons = array;
[array release];
-
+
[self.tableView reloadData];
}
@@ -46,7 +46,7 @@
-(void) toggleEdit:(id) sender {
BOOL isEditing = self.tableView.editing;
[self.tableView setEditing:!isEditing animated:YES];
-
+
if (isEditing) {
[self.navigationItem.rightBarButtonItem setTitle:NSLocalizedString(@"Edit",@"from the scheme panel")];
[self.navigationItem.rightBarButtonItem setStyle: UIBarButtonItemStyleBordered];
@@ -65,15 +65,15 @@
-(void) addWeapon:(id) sender {
NSString *fileName = [[NSString alloc] initWithFormat:@"Weapon %u.plist", [self.listOfWeapons count]];
-
+
createWeaponNamed([fileName stringByDeletingPathExtension]);
-
+
[self.listOfWeapons addObject:fileName];
[fileName release];
-
+
// order the array alphabetically, so schemes will keep their position
[self.listOfWeapons sortUsingSelector:@selector(compare:)];
-
+
[self.tableView reloadData];
}
@@ -89,28 +89,28 @@
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
-
+
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
-
- NSUInteger row = [indexPath row];
- NSString *rowString = [[self.listOfWeapons objectAtIndex:row] stringByDeletingPathExtension];
- cell.textLabel.text = rowString;
+
+ NSUInteger row = [indexPath row];
+ NSString *rowString = [[self.listOfWeapons objectAtIndex:row] stringByDeletingPathExtension];
+ cell.textLabel.text = rowString;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
-
+
return cell;
}
// delete the row and the file
-(void) tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
NSUInteger row = [indexPath row];
-
+
NSString *schemeFile = [[NSString alloc] initWithFormat:@"%@/%@",WEAPONS_DIRECTORY(),[self.listOfWeapons objectAtIndex:row]];
[[NSFileManager defaultManager] removeItemAtPath:schemeFile error:NULL];
[schemeFile release];
-
+
[self.listOfWeapons removeObjectAtIndex:row];
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
@@ -121,10 +121,10 @@
if (childController == nil) {
childController = [[SingleWeaponViewController alloc] initWithStyle:UITableViewStyleGrouped];
}
-
+
NSInteger row = [indexPath row];
NSString *selectedWeaponFile = [self.listOfWeapons objectAtIndex:row];
-
+
// this must be set so childController can load the correct plist
childController.weaponName = [selectedWeaponFile stringByDeletingPathExtension];
[childController.tableView setContentOffset:CGPointMake(0,0) animated:NO];