# HG changeset patch # User Medo # Date 1338640029 -7200 # Node ID 8d1d6adf5f821489ffdc3db2dfc2cbc6f07ea410 # Parent fe76d24a25d7b7bf1ca8720151987d7bad0121cb# Parent fad64b97947ee19a1e738476d03184302b96bb39 Merge diff -r fad64b97947e -r 8d1d6adf5f82 .hgignore --- a/.hgignore Fri Jun 01 12:42:44 2012 +0400 +++ b/.hgignore Sat Jun 02 14:27:09 2012 +0200 @@ -40,7 +40,7 @@ glob:*.rej glob:project_files/Android-build/SDL-android-project/jni/** glob:project_files/Android-build/SDL-android-project/obj -glob:project_files/Android-build/SDL-android-project/libs +glob:project_files/Android-build/SDL-android-project/libs/armeabi* glob:project_files/Android-build/SDL-android-project/bin glob:project_files/Android-build/SDL-android-project/gen glob:project_files/Android-build/SDL-android-project/local.properties diff -r fad64b97947e -r 8d1d6adf5f82 QTfrontend/CMakeLists.txt --- a/QTfrontend/CMakeLists.txt Fri Jun 01 12:42:44 2012 +0400 +++ b/QTfrontend/CMakeLists.txt Sat Jun 02 14:27:09 2012 +0200 @@ -128,7 +128,6 @@ achievements.h binds.h ui_hwform.h - KB.h hwconsts.h sdlkeys.h ) diff -r fad64b97947e -r 8d1d6adf5f82 QTfrontend/game.cpp --- a/QTfrontend/game.cpp Fri Jun 01 12:42:44 2012 +0400 +++ b/QTfrontend/game.cpp Sat Jun 02 14:27:09 2012 +0200 @@ -27,7 +27,6 @@ #include "gameuiconfig.h" #include "gamecfgwidget.h" #include "teamselect.h" -#include "KB.h" #include "proto.h" #include @@ -225,20 +224,6 @@ emit ErrorMessage(QString("Last two engine messages:\n") + QString().append(msg.mid(2)).left(size - 4)); return; } - case 'K': - { - ulong kb = msg.mid(2).toULong(); - if (kb==1) - { - qWarning("%s", KBMessages[kb - 1].toLocal8Bit().constData()); - return; - } - if (kb && kb <= KBmsgsCount) - { - emit ErrorMessage(KBMessages[kb - 1]); - } - return; - } case 'i': { emit GameStats(msg.at(2), QString::fromUtf8(msg.mid(3))); @@ -264,7 +249,6 @@ int size = msg.size(); QString msgbody = QString::fromUtf8(msg.mid(2).left(size - 4)); emit SendChat(msgbody); - // FIXME: /me command doesn't work here QByteArray buf; HWProto::addStringToBuffer(buf, "s" + HWProto::formatChatMsg(config->netNick(), msgbody) + "\x20\x20"); demo.append(buf); @@ -283,8 +267,7 @@ { emit SendNet(msg); } - if (msg.at(1) != 's') - demo.append(msg); + demo.append(msg); } } } diff -r fad64b97947e -r 8d1d6adf5f82 QTfrontend/net/newnetclient.h --- a/QTfrontend/net/newnetclient.h Fri Jun 01 12:42:44 2012 +0400 +++ b/QTfrontend/net/newnetclient.h Sat Jun 02 14:27:09 2012 +0200 @@ -66,27 +66,6 @@ bool m_game_connected; RoomsListModel * m_roomsListModel; - template - void SendCfgStrNet(T a) - { - QByteArray strmsg; - strmsg.append(a); - quint8 sz = strmsg.size(); - QByteArray enginemsg = QByteArray((char *)&sz, 1) + strmsg; - QString _msg = delimeter + QString(enginemsg.toBase64()); - RawSendNet(_msg); - } - - template - void SendCfgStrLoc(T a) - { - QByteArray strmsg; - strmsg.append(QString(a).toUtf8()); - quint8 sz = strmsg.size(); - QByteArray enginemsg = QByteArray((char *)&sz, 1) + strmsg; - emit FromNet(enginemsg); - } - QStringList cmdbuf; void RawSendNet(const QString & buf); diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/Licenses/Android Support library/NOTICE.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/Android-build/Licenses/Android Support library/NOTICE.txt Sat Jun 02 14:27:09 2012 +0200 @@ -0,0 +1,195 @@ +Notice for all the files in this folder. +------------------------------------------------------------ + + + + Copyright (c) 2005-2008, The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/Licenses/ini4j/LICENSE.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/Android-build/Licenses/ini4j/LICENSE.txt Sat Jun 02 14:27:09 2012 +0200 @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/Licenses/ini4j/NOTICE.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/Android-build/Licenses/ini4j/NOTICE.txt Sat Jun 02 14:27:09 2012 +0200 @@ -0,0 +1,13 @@ +Copyright 2005,2009 Ivan SZKIBA + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. \ No newline at end of file diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/libs/android-support-v13.jar Binary file project_files/Android-build/SDL-android-project/libs/android-support-v13.jar has changed diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/libs/ini4j-0.5.2.jar Binary file project_files/Android-build/SDL-android-project/libs/ini4j-0.5.2.jar has changed diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/res/raw/basicflags.xml --- a/project_files/Android-build/SDL-android-project/res/raw/basicflags.xml Fri Jun 01 12:42:44 2012 +0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,390 +0,0 @@ - - - - - false - - - false - - - e$damagepct - - - 100 - - - Damage - - - 300 - - - 10 - - - <string>Damage Modifier</string> - - - - - true - - - true - - - e$turntime - - - 45 - - - Time - - - 100 - - - 1 - - - <string>Turn Time</string> - - - - - false - - - inithealth - - - 200 - - - Health - - - 200 - - - 50 - - - <string>Initial Health</string> - - - - - true - - - false - - - e$sd_turns - - - 15 - - - SuddenDeath - - - 50 - - - 0 - - - <string>Sudden Death Timeout</string> - - - - - false - - - false - - - e$casefreq - - - 5 - - - Box - - - 9 - - - 0 - - - <string>Crate Drop Turns</string> - - - - - false - - - true - - - e$minestime - - - 3 - - - Time - - - 5 - - - -1 - - - <string>Mines Time</string> - - - - - false - - - false - - - e$minesnum - - - 4 - - - Mine - - - 80 - - - 0 - - - <string>Mines Number</string> - - - - - false - - - false - - - e$minedudpct - - - 0 - - - Dud - - - 100 - - - 0 - - - <string>Dud Mines Probability (%)</string> - - - - - false - - - false - - - e$explosives - - - 2 - - - Damage - - - 40 - - - 0 - - - <string>Explosives</string> - - - - - false - - - false - - - e$healthprob - - - 35 - - - Health - - - 100 - - - 0 - - - <string>Health Kit Probability (%)</string> - - - - - false - - - false - - - e$hcaseamount - - - 25 - - - Health - - - 200 - - - 0 - - - <string>Health Amount in Kit</string> - - - - - false - - - false - - - e$waterrise - - - 47 - - - SuddenDeath - - - 100 - - - 0 - - - <string>Water Rise Amount</string> - - - - - false - - - false - - - e$healthdec - - - 5 - - - SuddenDeath - - - 100 - - - 0 - - - <string>Health Decrease</string> - - - - - false - - - false - - - e$ropepct - - - 100 - - - Rope - - - 999 - - - 25 - - - <string>Rope Length (%)</string> - - - - - false - - - false - - - e$getawaytime - - - 100 - - - Time - - - 999 - - - 0 - - - <string>Get Away Time (%)</string> - - - diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/res/raw/basicsettings.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/Android-build/SDL-android-project/res/raw/basicsettings.ini Sat Jun 02 14:27:09 2012 +0200 @@ -0,0 +1,149 @@ +[DamagePercent] +checkOverMax=false +times1000=false +command=e$damagepct +default=100 +image=Damage +max=300 +min=10 +title=Damage Modifier + +[TurnTime] +checkOverMax=true +times1000=true +command=e$turntime +default=45 +image=Time +max=100 +min=1 +title=Turn Time + +[InitialHealth] +times1000=false +command=inithealth +default=200 +image=Health +max=200 +min=50 +title=Initial Health + +[SuddenDeathTimeout] +checkOverMax=true +times1000=false +command=e$sd_turns +default=15 +image=SuddenDeath +max=50 +min=0 +title=Sudden Death Timeout + +[CrateDropTurns] +checkOverMax=false +times1000=false +command=e$casefreq +default=5 +image=Box +max=9 +min=0 +title=Crate Drop Turns + +[MinesTime] +checkOverMax=false +times1000=true +command=e$minestime +default=3 +image=Time +max=5 +min=-1 +title=Mines Time + +[MinesNumber] +checkOverMax=false +times1000=false +command=e$minesnum +default=4 +image=Mine +max=80 +min=0 +title=Mines Number + +[MinesDudPercent] +checkOverMax=false +times1000=false +command=e$minedudpct +default=0 +image=Dud +max=100 +min=0 +title=Dud Mines Probability (%) + +[Explosives] +checkOverMax=false +times1000=false +command=e$explosives +default=2 +image=Damage +max=40 +min=0 +title=Explosives + +[HealthCratePercent] +checkOverMax=false +times1000=false +command=e$healthprob +default=35 +image=Health +max=100 +min=0 +title=Health Kit Probability (%) + +[HealthCrateHP] +checkOverMax=false +times1000=false +command=e$hcaseamount +default=25 +image=Health +max=200 +min=0 +title=Health Amount in Kit + +[SuddenDeathWaterRise] +checkOverMax=false +times1000=false +command=e$waterrise +default=47 +image=SuddenDeath +max=100 +min=0 +title=Water Rise Amount + +[SuddenDeathHealthDecrease] +checkOverMax=false +times1000=false +command=e$healthdec +default=5 +image=SuddenDeath +max=100 +min=0 +title=Health Decrease + +[RopeLengthPercent] +checkOverMax=false +times1000=false +command=e$ropepct +default=100 +image=Rope +max=999 +min=25 +title=Rope Length (%) + +[GetAwayTimePercent] +checkOverMax=false +times1000=false +command=e$getawaytime +default=100 +image=Time +max=999 +min=0 +title=Get Away Time (%) + diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/res/raw/gamemods.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/Android-build/SDL-android-project/res/raw/gamemods.ini Sat Jun 02 14:27:09 2012 +0200 @@ -0,0 +1,74 @@ +[SolidLand] +bitmaskIndex=2 + +[Border] +bitmaskIndex=3 + +[DivideTeams] +bitmaskIndex=4 + +[LowGravity] +bitmaskIndex=5 + +[LaserSight] +bitmaskIndex=6 + +[Invulnerable] +bitmaskIndex=7 + +[ResetHealth] +bitmaskIndex=8 + +[Vampiric] +bitmaskIndex=9 + +[Karma] +bitmaskIndex=10 + +[Artillery] +bitmaskIndex=11 + +[Forts] +bitmaskIndex=12 + +[RandomOrder] +bitmaskIndex=13 + +[King] +bitmaskIndex=14 + +[PlaceHog] +bitmaskIndex=15 + +[SharedAmmo] +bitmaskIndex=16 + +[DisableGirders] +bitmaskIndex=17 + +[DisableLandObjects] +bitmaskIndex=18 + +[AISurvival] +bitmaskIndex=19 + +[InfAttack] +bitmaskIndex=20 + +[ResetWeps] +bitmaskIndex=21 + +[PerHogAmmo] +bitmaskIndex=22 + +[DisableWind] +bitmaskIndex=23 + +[MoreWind] +bitmaskIndex=24 + +[TagTeam] +bitmaskIndex=25 + +[BottomBorder] +bitmaskIndex=26 diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/res/raw/scheme_barrelmayhem.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/Android-build/SDL-android-project/res/raw/scheme_barrelmayhem.ini Sat Jun 02 14:27:09 2012 +0200 @@ -0,0 +1,46 @@ +[Scheme] +name=Barrel Mayhem + +[BasicSettings] +DamagePercent=100 +TurnTime=30 +InitialHealth=100 +SuddenDeathTimeout=15 +CrateDropTurns=0 +MinesTime=0 +MinesNumber=0 +MinesDudPercent=0 +Explosives=80 +HealthCratePercent=35 +HealthCrateHP=25 +SuddenDeathWaterRise=47 +SuddenDeathHealthDecrease=5 +RopeLengthPercent=100 +GetAwayTimePercent=100 + +[GameMods] +SolidLand=false +Border=false +DivideTeams=false +LowGravity=false +LaserSight=false +Invulnerable=false +ResetHealth=false +Vampiric=false +Karma=false +Artillery=false +Forts=false +RandomOrder=true +King=false +PlaceHog=false +SharedAmmo=true +DisableGirders=false +DisableLandObjects=false +AISurvival=false +InfAttack=false +ResetWeps=false +PerHogAmmo=false +DisableWind=false +MoreWind=false +TagTeam=false +BottomBorder=false diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/res/raw/scheme_barrelmayhem.xml --- a/project_files/Android-build/SDL-android-project/res/raw/scheme_barrelmayhem.xml Fri Jun 01 12:42:44 2012 +0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ - - - Barrel Mayhem - - 100 - 30 - 100 - 15 - 0 - 0 - 0 - 0 - 80 - 35 - 25 - 47 - 5 - 100 - 100 - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/res/raw/scheme_cleanslate.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/Android-build/SDL-android-project/res/raw/scheme_cleanslate.ini Sat Jun 02 14:27:09 2012 +0200 @@ -0,0 +1,46 @@ +[Scheme] +name=Clean Slate + +[BasicSettings] +DamagePercent=100 +TurnTime=45 +InitialHealth=100 +SuddenDeathTimeout=15 +CrateDropTurns=5 +MinesTime=3 +MinesNumber=4 +MinesDudPercent=0 +Explosives=2 +HealthCratePercent=35 +HealthCrateHP=25 +SuddenDeathWaterRise=47 +SuddenDeathHealthDecrease=5 +RopeLengthPercent=100 +GetAwayTimePercent=100 + +[GameMods] +SolidLand=false +Border=false +DivideTeams=false +LowGravity=false +LaserSight=false +Invulnerable=false +ResetHealth=true +Vampiric=false +Karma=false +Artillery=false +Forts=false +RandomOrder=true +King=false +PlaceHog=false +SharedAmmo=false +DisableGirders=false +DisableLandObjects=false +AISurvival=false +InfAttack=true +ResetWeps=true +PerHogAmmo=false +DisableWind=false +MoreWind=false +TagTeam=false +BottomBorder=false diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/res/raw/scheme_cleanslate.xml --- a/project_files/Android-build/SDL-android-project/res/raw/scheme_cleanslate.xml Fri Jun 01 12:42:44 2012 +0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ - - - Clean Slate - - 100 - 45 - 100 - 15 - 5 - 3 - 4 - 0 - 2 - 35 - 25 - 47 - 5 - 100 - 100 - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/res/raw/scheme_default_scheme.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/Android-build/SDL-android-project/res/raw/scheme_default_scheme.ini Sat Jun 02 14:27:09 2012 +0200 @@ -0,0 +1,46 @@ +[Scheme] +name=Default + +[BasicSettings] +DamagePercent=100 +TurnTime=45 +InitialHealth=100 +SuddenDeathTimeout=15 +CrateDropTurns=5 +MinesTime=3 +MinesNumber=4 +MinesDudPercent=0 +Explosives=2 +HealthCratePercent=35 +HealthCrateHP=25 +SuddenDeathWaterRise=47 +SuddenDeathHealthDecrease=5 +RopeLengthPercent=100 +GetAwayTimePercent=100 + +[GameMods] +SolidLand=false +Border=false +DivideTeams=false +LowGravity=false +LaserSight=false +Invulnerable=false +ResetHealth=false +Vampiric=false +Karma=false +Artillery=false +Forts=false +RandomOrder=true +King=false +PlaceHog=false +SharedAmmo=false +DisableGirders=false +DisableLandObjects=false +AISurvival=false +InfAttack=false +ResetWeps=false +PerHogAmmo=false +DisableWind=false +MoreWind=false +TagTeam=false +BottomBorder=false diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/res/raw/scheme_default_scheme.xml --- a/project_files/Android-build/SDL-android-project/res/raw/scheme_default_scheme.xml Fri Jun 01 12:42:44 2012 +0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ - - - Default - - 100 - 45 - 100 - 15 - 5 - 3 - 4 - 0 - 2 - 35 - 25 - 47 - 5 - 100 - 100 - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/res/raw/scheme_fortmode.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/Android-build/SDL-android-project/res/raw/scheme_fortmode.ini Sat Jun 02 14:27:09 2012 +0200 @@ -0,0 +1,46 @@ +[Scheme] +name=Fort Mode + +[BasicSettings] +DamagePercent=100 +TurnTime=45 +InitialHealth=100 +SuddenDeathTimeout=15 +CrateDropTurns=5 +MinesTime=3 +MinesNumber=0 +MinesDudPercent=0 +Explosives=0 +HealthCratePercent=35 +HealthCrateHP=25 +SuddenDeathWaterRise=47 +SuddenDeathHealthDecrease=5 +RopeLengthPercent=100 +GetAwayTimePercent=100 + +[GameMods] +SolidLand=false +Border=false +DivideTeams=true +LowGravity=true +LaserSight=false +Invulnerable=false +ResetHealth=false +Vampiric=false +Karma=false +Artillery=false +Forts=true +RandomOrder=true +King=false +PlaceHog=false +SharedAmmo=false +DisableGirders=false +DisableLandObjects=false +AISurvival=false +InfAttack=false +ResetWeps=false +PerHogAmmo=false +DisableWind=false +MoreWind=false +TagTeam=false +BottomBorder=false diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/res/raw/scheme_fortmode.xml --- a/project_files/Android-build/SDL-android-project/res/raw/scheme_fortmode.xml Fri Jun 01 12:42:44 2012 +0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ - - - Fort Mode - - 100 - 45 - 100 - 15 - 5 - 3 - 0 - 0 - 0 - 35 - 25 - 47 - 5 - 100 - 100 - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/res/raw/scheme_kingmode.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/Android-build/SDL-android-project/res/raw/scheme_kingmode.ini Sat Jun 02 14:27:09 2012 +0200 @@ -0,0 +1,46 @@ +[Scheme] +name=King Mode + +[BasicSettings] +DamagePercent=100 +TurnTime=45 +InitialHealth=100 +SuddenDeathTimeout=15 +CrateDropTurns=5 +MinesTime=3 +MinesNumber=4 +MinesDudPercent=0 +Explosives=2 +HealthCratePercent=35 +HealthCrateHP=25 +SuddenDeathWaterRise=47 +SuddenDeathHealthDecrease=5 +RopeLengthPercent=100 +GetAwayTimePercent=100 + +[GameMods] +SolidLand=false +Border=false +DivideTeams=false +LowGravity=false +LaserSight=false +Invulnerable=false +ResetHealth=false +Vampiric=false +Karma=false +Artillery=false +Forts=false +RandomOrder=true +King=true +PlaceHog=false +SharedAmmo=false +DisableGirders=false +DisableLandObjects=false +AISurvival=false +InfAttack=false +ResetWeps=false +PerHogAmmo=false +DisableWind=false +MoreWind=false +TagTeam=false +BottomBorder=false diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/res/raw/scheme_kingmode.xml --- a/project_files/Android-build/SDL-android-project/res/raw/scheme_kingmode.xml Fri Jun 01 12:42:44 2012 +0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ - - - King Mode - - 100 - 45 - 100 - 15 - 5 - 3 - 4 - 0 - 2 - 35 - 25 - 47 - 5 - 100 - 100 - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/res/raw/scheme_minefield.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/Android-build/SDL-android-project/res/raw/scheme_minefield.ini Sat Jun 02 14:27:09 2012 +0200 @@ -0,0 +1,46 @@ +[Scheme] +name=Minefield + +[BasicSettings] +DamagePercent=100 +TurnTime=30 +InitialHealth=50 +SuddenDeathTimeout=15 +CrateDropTurns=0 +MinesTime=0 +MinesNumber=80 +MinesDudPercent=0 +Explosives=0 +HealthCratePercent=35 +HealthCrateHP=25 +SuddenDeathWaterRise=47 +SuddenDeathHealthDecrease=5 +RopeLengthPercent=100 +GetAwayTimePercent=100 + +[GameMods] +SolidLand=false +Border=false +DivideTeams=false +LowGravity=false +LaserSight=false +Invulnerable=false +ResetHealth=false +Vampiric=false +Karma=false +Artillery=false +Forts=false +RandomOrder=true +King=false +PlaceHog=false +SharedAmmo=true +DisableGirders=true +DisableLandObjects=false +AISurvival=false +InfAttack=false +ResetWeps=false +PerHogAmmo=false +DisableWind=false +MoreWind=false +TagTeam=false +BottomBorder=false diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/res/raw/scheme_minefield.xml --- a/project_files/Android-build/SDL-android-project/res/raw/scheme_minefield.xml Fri Jun 01 12:42:44 2012 +0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ - - - Minefield - - 100 - 30 - 50 - 15 - 0 - 0 - 80 - 0 - 0 - 35 - 25 - 47 - 5 - 100 - 100 - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/res/raw/scheme_promode.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/Android-build/SDL-android-project/res/raw/scheme_promode.ini Sat Jun 02 14:27:09 2012 +0200 @@ -0,0 +1,46 @@ +[Scheme] +name=Pro Mode + +[BasicSettings] +DamagePercent=100 +TurnTime=15 +InitialHealth=100 +SuddenDeathTimeout=15 +CrateDropTurns=0 +MinesTime=3 +MinesNumber=0 +MinesDudPercent=0 +Explosives=2 +HealthCratePercent=35 +HealthCrateHP=25 +SuddenDeathWaterRise=47 +SuddenDeathHealthDecrease=5 +RopeLengthPercent=100 +GetAwayTimePercent=100 + +[GameMods] +SolidLand=false +Border=false +DivideTeams=false +LowGravity=false +LaserSight=false +Invulnerable=false +ResetHealth=false +Vampiric=false +Karma=false +Artillery=false +Forts=false +RandomOrder=true +King=false +PlaceHog=false +SharedAmmo=true +DisableGirders=false +DisableLandObjects=false +AISurvival=false +InfAttack=false +ResetWeps=false +PerHogAmmo=false +DisableWind=false +MoreWind=false +TagTeam=false +BottomBorder=false diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/res/raw/scheme_promode.xml --- a/project_files/Android-build/SDL-android-project/res/raw/scheme_promode.xml Fri Jun 01 12:42:44 2012 +0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ - - - Pro Mode - - 100 - 15 - 100 - 15 - 0 - 3 - 0 - 0 - 2 - 35 - 25 - 47 - 5 - 100 - 100 - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/res/raw/scheme_shoppa.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/Android-build/SDL-android-project/res/raw/scheme_shoppa.ini Sat Jun 02 14:27:09 2012 +0200 @@ -0,0 +1,46 @@ +[Scheme] +name=Shoppa + +[BasicSettings] +DamagePercent=100 +TurnTime=30 +InitialHealth=100 +SuddenDeathTimeout=50 +CrateDropTurns=1 +MinesTime=3 +MinesNumber=0 +MinesDudPercent=0 +Explosives=0 +HealthCratePercent=0 +HealthCrateHP=25 +SuddenDeathWaterRise=47 +SuddenDeathHealthDecrease=5 +RopeLengthPercent=100 +GetAwayTimePercent=100 + +[GameMods] +SolidLand=false +Border=true +DivideTeams=true +LowGravity=false +LaserSight=false +Invulnerable=false +ResetHealth=false +Vampiric=false +Karma=false +Artillery=false +Forts=false +RandomOrder=true +King=false +PlaceHog=false +SharedAmmo=true +DisableGirders=true +DisableLandObjects=false +AISurvival=false +InfAttack=false +ResetWeps=false +PerHogAmmo=false +DisableWind=false +MoreWind=false +TagTeam=false +BottomBorder=false diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/res/raw/scheme_shoppa.xml --- a/project_files/Android-build/SDL-android-project/res/raw/scheme_shoppa.xml Fri Jun 01 12:42:44 2012 +0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ - - - Shoppa - - 100 - 30 - 100 - 50 - 1 - 3 - 0 - 0 - 0 - 0 - 25 - 47 - 5 - 100 - 100 - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/res/raw/scheme_thinkingwithportals.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/Android-build/SDL-android-project/res/raw/scheme_thinkingwithportals.ini Sat Jun 02 14:27:09 2012 +0200 @@ -0,0 +1,46 @@ +[Scheme] +name=Thinking with Portals + +[BasicSettings] +DamagePercent=100 +TurnTime=45 +InitialHealth=100 +SuddenDeathTimeout=15 +CrateDropTurns=2 +MinesTime=3 +MinesNumber=5 +MinesDudPercent=0 +Explosives=5 +HealthCratePercent=25 +HealthCrateHP=25 +SuddenDeathWaterRise=47 +SuddenDeathHealthDecrease=5 +RopeLengthPercent=100 +GetAwayTimePercent=100 + +[GameMods] +SolidLand=false +Border=false +DivideTeams=false +LowGravity=false +LaserSight=false +Invulnerable=false +ResetHealth=false +Vampiric=false +Karma=false +Artillery=false +Forts=true +RandomOrder=true +King=false +PlaceHog=false +SharedAmmo=false +DisableGirders=false +DisableLandObjects=false +AISurvival=false +InfAttack=false +ResetWeps=false +PerHogAmmo=false +DisableWind=false +MoreWind=false +TagTeam=false +BottomBorder=false diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/res/raw/scheme_thinkingwithportals.xml --- a/project_files/Android-build/SDL-android-project/res/raw/scheme_thinkingwithportals.xml Fri Jun 01 12:42:44 2012 +0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ - - - Thinking with Portals - - 100 - 45 - 100 - 15 - 2 - 3 - 5 - 0 - 5 - 25 - 25 - 47 - 5 - 100 - 100 - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/res/raw/scheme_timeless.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/Android-build/SDL-android-project/res/raw/scheme_timeless.ini Sat Jun 02 14:27:09 2012 +0200 @@ -0,0 +1,46 @@ +[Scheme] +name=Timeless + +[BasicSettings] +DamagePercent=100 +TurnTime=9999 +InitialHealth=100 +SuddenDeathTimeout=15 +CrateDropTurns=5 +MinesTime=3 +MinesNumber=5 +MinesDudPercent=10 +Explosives=2 +HealthCratePercent=35 +HealthCrateHP=30 +SuddenDeathWaterRise=0 +SuddenDeathHealthDecrease=0 +RopeLengthPercent=100 +GetAwayTimePercent=100 + +[GameMods] +SolidLand=false +Border=false +DivideTeams=false +LowGravity=false +LaserSight=false +Invulnerable=false +ResetHealth=false +Vampiric=false +Karma=false +Artillery=false +Forts=false +RandomOrder=true +King=false +PlaceHog=false +SharedAmmo=true +DisableGirders=false +DisableLandObjects=false +AISurvival=false +InfAttack=false +ResetWeps=false +PerHogAmmo=true +DisableWind=false +MoreWind=false +TagTeam=false +BottomBorder=false diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/res/raw/scheme_timeless.xml --- a/project_files/Android-build/SDL-android-project/res/raw/scheme_timeless.xml Fri Jun 01 12:42:44 2012 +0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ - - - Timeless - - 100 - 9999 - 100 - 15 - 5 - 3 - 5 - 10 - 2 - 35 - 30 - 0 - 0 - 100 - 100 - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/res/raw/scheme_tunnelhogs.ini --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/Android-build/SDL-android-project/res/raw/scheme_tunnelhogs.ini Sat Jun 02 14:27:09 2012 +0200 @@ -0,0 +1,46 @@ +[Scheme] +name=Tunnelhogs + +[BasicSettings] +DamagePercent=100 +TurnTime=30 +InitialHealth=100 +SuddenDeathTimeout=15 +CrateDropTurns=5 +MinesTime=3 +MinesNumber=10 +MinesDudPercent=10 +Explosives=10 +HealthCratePercent=35 +HealthCrateHP=25 +SuddenDeathWaterRise=47 +SuddenDeathHealthDecrease=5 +RopeLengthPercent=100 +GetAwayTimePercent=100 + +[GameMods] +SolidLand=false +Border=false +DivideTeams=true +LowGravity=false +LaserSight=false +Invulnerable=false +ResetHealth=false +Vampiric=false +Karma=false +Artillery=false +Forts=false +RandomOrder=true +King=false +PlaceHog=false +SharedAmmo=true +DisableGirders=true +DisableLandObjects=true +AISurvival=false +InfAttack=false +ResetWeps=false +PerHogAmmo=false +DisableWind=false +MoreWind=false +TagTeam=false +BottomBorder=false diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/res/raw/scheme_tunnelhogs.xml --- a/project_files/Android-build/SDL-android-project/res/raw/scheme_tunnelhogs.xml Fri Jun 01 12:42:44 2012 +0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ - - - Tunnelhogs - - 100 - 30 - 100 - 15 - 5 - 3 - 10 - 10 - 10 - 35 - 25 - 47 - 5 - 100 - 100 - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/res/values/frontend_data_pointers.xml --- a/project_files/Android-build/SDL-android-project/res/values/frontend_data_pointers.xml Fri Jun 01 12:42:44 2012 +0400 +++ b/project_files/Android-build/SDL-android-project/res/values/frontend_data_pointers.xml Sat Jun 02 14:27:09 2012 +0200 @@ -2,7 +2,8 @@ - @raw/basicflags + @raw/basicsettings + @raw/gamemods @raw/scheme_default_scheme @raw/scheme_barrelmayhem @raw/scheme_cleanslate diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Scheme.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Scheme.java Fri Jun 01 12:42:44 2012 +0400 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Scheme.java Sat Jun 02 14:27:09 2012 +0200 @@ -1,7 +1,8 @@ /* * Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game * Copyright (c) 2011-2012 Richard Deurwaarder - * + * Copyright (c) 2012 Simeon Maxein + * * 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 @@ -18,322 +19,167 @@ package org.hedgewars.hedgeroid.Datastructures; -import java.io.BufferedReader; +import java.util.Map; + import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; import java.io.FilenameFilter; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; -import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map.Entry; +import java.util.TreeMap; import org.hedgewars.hedgeroid.EngineProtocol.EngineProtocolNetwork; -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; -import org.xmlpull.v1.XmlPullParserFactory; +import org.ini4j.Ini; +import org.ini4j.InvalidFileFormatException; +import org.ini4j.Profile.Section; import android.content.Context; import android.os.Parcel; import android.os.Parcelable; +import android.util.Log; public class Scheme implements Parcelable, Comparable{ - public static final String DIRECTORY_SCHEME = "schemes"; + private static final Map basicSettingsMeta = new TreeMap(); + private static final Map gameModsMeta = new TreeMap(); - private String name; - //private ArrayList basic; - private Integer gamemod; - private ArrayList basic;; - private static ArrayList> basicflags = new ArrayList>();//TODO why is it static? - public int health; - - public Scheme(String _name, ArrayList _basic, int _gamemod){ + private final String name; + private final int gamemod; + private final Map basic = new TreeMap(); + + public Scheme(String _name, Map _basic, int _gamemod) { name = _name; gamemod = _gamemod; - basic = _basic; + basic.putAll(_basic); } public Scheme(Parcel in){ - readFromParcel(in); + name = in.readString(); + gamemod = in.readInt(); + in.readMap(basic, Integer.class.getClassLoader()); } - public void sendToEngine(EngineProtocolNetwork epn)throws IOException{ + public int getHealth() { + return basic.get("InitialHealth"); + } + + public void sendToEngine(EngineProtocolNetwork epn) throws IOException{ epn.sendToEngine(String.format("e$gmflags %d", gamemod)); - for(int pos = 0; pos < basic.size(); pos++){ - LinkedHashMap basicflag = basicflags.get(pos); + for(Map.Entry entry : basic.entrySet()) { + BasicSettingMeta basicflag = basicSettingsMeta.get(entry.getKey()); - String command = (String)basicflag.get("command"); - Integer value = basic.get(pos); - - if(command.equals("inithealth")){//Health is a special case, it doesn't need to be send - health = value; //to the engine yet, we'll do that with the other HH info - continue; + //Health is a special case, it doesn't need to be send + //to the engine yet, we'll do that with the other HH info + if(!basicflag.command.equals("inithealth")){ + epn.sendToEngine(String.format("%s %d", basicflag.command, entry.getValue())); } - - Boolean checkOverMax = (Boolean) basicflag.get("checkOverMax"); - Boolean times1000 = (Boolean) basicflag.get("times1000"); - Integer max = (Integer) basicflag.get("max"); - - if(checkOverMax && value >= max) value = max; - if(times1000) value *= 1000; - - epn.sendToEngine(String.format("%s %d", command, value)); } } + public String toString(){ return name; } - - public static final int STATE_START = 0; - public static final int STATE_ROOT = 1; - public static final int STATE_NAME = 2; - public static final int STATE_BASICFLAGS = 3; - public static final int STATE_GAMEMOD = 4; - public static final int STATE_BASICFLAG_INTEGER = 5; - public static final int STATE_GAMEMOD_TRUE = 6; - public static final int STATE_GAMEMOD_FALSE = 7; - - public static ArrayList getSchemes(Context c) throws IllegalArgumentException{ - String dir = c.getFilesDir().getAbsolutePath() + '/' + DIRECTORY_SCHEME + '/'; - String[] files = new File(dir).list(fnf); - if(files == null) files = new String[]{}; + public static List getSchemes(Context c) throws IllegalArgumentException { + File schemeDir = new File(c.getFilesDir(), DIRECTORY_SCHEME); + File[] files = schemeDir.listFiles(new FilenameFilter() { + public boolean accept(File dir, String filename) { + return filename.toLowerCase().startsWith("scheme_"); + } + }); + if(files == null) files = new File[0]; Arrays.sort(files); - ArrayList schemes = new ArrayList(); - - try { - XmlPullParserFactory xmlPullFactory = XmlPullParserFactory.newInstance(); - XmlPullParser xmlPuller = xmlPullFactory.newPullParser(); - - for(String file : files){ - BufferedReader br = new BufferedReader(new FileReader(dir + file), 1024); - xmlPuller.setInput(br); - String name = null; - ArrayList basic = new ArrayList(); - Integer gamemod = 0; - int health = 0; - int mask = 0x000000004; + List schemes = new ArrayList(); - int eventType = xmlPuller.getEventType(); - int state = STATE_START; - while(eventType != XmlPullParser.END_DOCUMENT){ - switch(state){ - case STATE_START: - if(eventType == XmlPullParser.START_TAG && xmlPuller.getName().equals("scheme")) state = STATE_ROOT; - else if(eventType != XmlPullParser.START_DOCUMENT) throwException(file, eventType); - break; - case STATE_ROOT: - if(eventType == XmlPullParser.START_TAG){ - if(xmlPuller.getName().equals("basicflags")) state = STATE_BASICFLAGS; - else if(xmlPuller.getName().toLowerCase().equals("gamemod")) state = STATE_GAMEMOD; - else if(xmlPuller.getName().toLowerCase().equals("name")) state = STATE_NAME; - else throwException(file, eventType); - }else if(eventType == XmlPullParser.END_TAG) state = STATE_START; - else throwException(xmlPuller.getText(), eventType); - break; - case STATE_BASICFLAGS: - if(eventType == XmlPullParser.START_TAG && xmlPuller.getName().toLowerCase().equals("integer")) state = STATE_BASICFLAG_INTEGER; - else if(eventType == XmlPullParser.END_TAG) state = STATE_ROOT; - else throwException(file, eventType); - break; - case STATE_GAMEMOD: - if(eventType == XmlPullParser.START_TAG){ - if(xmlPuller.getName().toLowerCase().equals("true")) state = STATE_GAMEMOD_TRUE; - else if(xmlPuller.getName().toLowerCase().equals("false")) state = STATE_GAMEMOD_FALSE; - else throwException(file, eventType); - }else if(eventType == XmlPullParser.END_TAG) state = STATE_ROOT; - else throwException(file, eventType); - break; - case STATE_NAME: - if(eventType == XmlPullParser.TEXT) name = xmlPuller.getText().trim(); - else if(eventType == XmlPullParser.END_TAG) state = STATE_ROOT; - else throwException(file, eventType); - break; - case STATE_BASICFLAG_INTEGER: - if(eventType == XmlPullParser.TEXT) basic.add(Integer.parseInt(xmlPuller.getText().trim())); - else if(eventType == XmlPullParser.END_TAG) state = STATE_BASICFLAGS; - else throwException(file, eventType); - break; - case STATE_GAMEMOD_FALSE: - if(eventType == XmlPullParser.TEXT) gamemod <<= 1; - else if(eventType == XmlPullParser.END_TAG) state = STATE_GAMEMOD; - else throwException(file, eventType); - break; - case STATE_GAMEMOD_TRUE: - if(eventType == XmlPullParser.TEXT){ - gamemod |= mask; - gamemod <<= 1; - }else if(eventType == XmlPullParser.END_TAG) state = STATE_GAMEMOD; - else throwException(file, eventType); - break; + for(File file : files) { + try { + Ini ini = new Ini(file); + + String name = ini.get("Scheme", "name"); + if(name==null) { + name = file.getName(); + } + Section basicSettingsSection = ini.get("BasicSettings"); + Section gameModsSection = ini.get("GameMods"); + if(basicSettingsSection == null || gameModsSection == null) { + Log.e(Scheme.class.getCanonicalName(), "Scheme file "+file+" is missing the BasicSettings or GameMods section - skipping."); + continue; + } + + Map basicSettings = new TreeMap(); + for(Entry entry : basicSettingsMeta.entrySet()) { + String key = entry.getKey(); + BasicSettingMeta settingMeta = entry.getValue(); + Integer value = null; + if(basicSettingsSection.containsKey(key)) { + try { + value = Integer.valueOf(basicSettingsSection.get(key)); + } catch (NumberFormatException e) { + // ignore + } } - eventType = getEventType(xmlPuller); - }//end while(eventtype != END_DOCUMENT - schemes.add(new Scheme(name, basic, gamemod)); - }//end for(string file : files - return schemes; - } catch (XmlPullParserException e) { - e.printStackTrace(); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); + + if(value==null) { + Log.w(Scheme.class.getCanonicalName(), "Scheme file "+file+" setting "+key+" is missing or invalid, using default."); + value = settingMeta.def; + } + + if(settingMeta.checkOverMax) { + value = Math.min(value, settingMeta.max); + } + if(settingMeta.times1000) { + value *= 1000; + } + + basicSettings.put(key, value); + } + + int gamemods = 0; + for(Entry entry : gameModsMeta.entrySet()) { + String key = entry.getKey(); + GameModMeta modMeta = entry.getValue(); + if(Boolean.parseBoolean(gameModsSection.get(key))) { + gamemods |= (1 << modMeta.bitmaskIndex); + } + } + + schemes.add(new Scheme(name, basicSettings, gamemods)); + } catch (InvalidFileFormatException e) { + throw new RuntimeException(e); + } catch (IOException e) { + throw new RuntimeException(e); + } } - return new ArrayList();//TODO handle correctly + return schemes; } - private static FilenameFilter fnf = new FilenameFilter(){ - public boolean accept(File dir, String filename) { - return filename.toLowerCase().startsWith("scheme_"); - } - }; - /** - * This method will parse the basic flags from a prespecified xml file. - * I use a raw xml file rather than one parsed by aatp at compile time - * to keep it generic with other frontends, ie in the future we could - * use one provided by the Data folder. - */ - public static void parseBasicFlags(Context c){ - String filename = String.format("%s/%s/basicflags", c.getFilesDir().getAbsolutePath(), DIRECTORY_SCHEME); - - XmlPullParser xmlPuller = null; - BufferedReader br = null; - try { - XmlPullParserFactory xmlPullFactory = XmlPullParserFactory.newInstance(); - xmlPuller = xmlPullFactory.newPullParser(); - br = new BufferedReader(new FileReader(filename), 1024); - xmlPuller.setInput(br); - - int eventType = getEventType(xmlPuller); - boolean continueParsing = true; - do{ - switch(eventType){ - - case XmlPullParser.START_TAG: - if(xmlPuller.getName().toLowerCase().equals("flag")){ - basicflags.add(parseFlag(xmlPuller)); - }else if(xmlPuller.getName().toLowerCase().equals("basicflags")){ - eventType = getEventType(xmlPuller); - }else{ - skipCurrentTag(xmlPuller); - eventType = getEventType(xmlPuller); - } - break; - case XmlPullParser.START_DOCUMENT://ignore all tags not being "flag" - case XmlPullParser.END_TAG: - case XmlPullParser.TEXT: - default: - continueParsing = true; - case XmlPullParser.END_DOCUMENT: - continueParsing = false; - } - }while(continueParsing); - - }catch(IOException e){ - e.printStackTrace(); - }catch (XmlPullParserException e) { - e.printStackTrace(); - }finally{ - if(br != null) - try { - br.close(); - } catch (IOException e) {} - } - - } - - /* - * * Parses a Tag structure from xml as example we use - * - * - * false - * - * - * - * It returns a LinkedHashMap with key/value pairs + * This method will parse the basic flags from a prespecified ini file. + * In the future we could use one provided by the Data folder. */ - private static LinkedHashMap parseFlag(XmlPullParser xmlPuller)throws XmlPullParserException, IOException{ - LinkedHashMap hash = new LinkedHashMap(); - - int eventType = xmlPuller.getEventType();//Get the event type which triggered this method - if(eventType == XmlPullParser.START_TAG && xmlPuller.getName().toLowerCase().equals("flag")){//valid start of flag tag - String lcKey = null; - String lcType = null; - String value = null; - - eventType = getEventType(xmlPuller);// - while(eventType == XmlPullParser.START_TAG){ - lcKey = xmlPuller.getName();//checkOverMax - if(getEventType(xmlPuller) == XmlPullParser.START_TAG){// - lcType = xmlPuller.getName().toLowerCase(); - if(getEventType(xmlPuller) == XmlPullParser.TEXT){ - value = xmlPuller.getText(); - if(getEventType(xmlPuller) == XmlPullParser.END_TAG && // - getEventType(xmlPuller) == XmlPullParser.END_TAG){// - if(lcType.equals("boolean")) hash.put(lcKey, new Boolean(value)); - else if(lcType.equals("string"))hash.put(lcKey, value); - else if(lcType.equals("integer")){ - try{ - hash.put(lcKey, new Integer(value)); - }catch (NumberFormatException e){ - throw new XmlPullParserException("Wrong integer value in xml file"); - } - }else{ - throwException("basicflags", eventType); - } - }// / - }//if TEXT - }//if boolean - eventType = getEventType(xmlPuller);//start new loop + public static void parseConfiguration(Context c) { + File schemeDir = new File(c.getFilesDir(), DIRECTORY_SCHEME); + File settingsFile = new File(schemeDir, "basicsettings"); + File gameModsFile = new File(schemeDir, "gamemods"); + + try { + Ini ini = new Ini(settingsFile); + for(Entry sectionEntry : ini.entrySet()) { + basicSettingsMeta.put(sectionEntry.getKey(), new BasicSettingMeta(sectionEntry.getValue())); } - eventType = getEventType(xmlPuller);// + + ini = new Ini(gameModsFile); + for(Entry sectionEntry : ini.entrySet()) { + gameModsMeta.put(sectionEntry.getKey(), new GameModMeta(sectionEntry.getValue())); + } + } catch (InvalidFileFormatException e) { + throw new RuntimeException(e); + } catch (IOException e) { + throw new RuntimeException(e); } - - return hash; - } - - private static void skipCurrentTag(XmlPullParser xmlPuller) throws XmlPullParserException, IOException{ - int eventType = xmlPuller.getEventType(); - if(eventType != XmlPullParser.START_TAG)return; - String tag = xmlPuller.getName().toLowerCase(); - - while(true){ - eventType = getEventType(xmlPuller);//getNext() - switch(eventType){ - case XmlPullParser.START_DOCUMENT://we're inside of a start tag so START_ or END_DOCUMENT is just wrong - case XmlPullParser.END_DOCUMENT: - throw new XmlPullParserException("invalid xml file"); - case XmlPullParser.START_TAG://if we get a new tag recursively handle it - skipCurrentTag(xmlPuller); - break; - case XmlPullParser.TEXT: - break; - case XmlPullParser.END_TAG: - if(!xmlPuller.getName().toLowerCase().equals(tag)){//if the end tag doesn't match the start tag - throw new XmlPullParserException("invalid xml file"); - }else{ - return;//skip completed - } - - } - } - } - - /** - * Skips whitespaces.. - */ - private static int getEventType(XmlPullParser xmlPuller)throws XmlPullParserException, IOException{ - int eventType = xmlPuller.next(); - while(eventType == XmlPullParser.TEXT && xmlPuller.isWhitespace()){ - eventType = xmlPuller.next(); - } - return eventType; - } - private static void throwException(String file, int eventType){ - throw new IllegalArgumentException(String.format("Xml file: %s malformed with error: %d.", file, eventType)); } public int describeContents() { @@ -343,13 +189,7 @@ public void writeToParcel(Parcel dest, int flags) { dest.writeString(name); dest.writeInt(gamemod); - dest.writeList(basic); - } - - public void readFromParcel(Parcel src){ - name = src.readString(); - gamemod = src.readInt(); - basic = src.readArrayList(ArrayList.class.getClassLoader()); + dest.writeMap(basic); } public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { @@ -366,3 +206,60 @@ return name.compareTo(another.name); } } + +class BasicSettingMeta { + final String command; + final String title; + final int def; + final int min; + final int max; + final boolean times1000; + final boolean checkOverMax; + + public BasicSettingMeta(Ini.Section section) { + command = getRequired(section, "command"); + title = section.get("title", ""); + def = Integer.parseInt(getRequired(section, "default")); + min = Integer.parseInt(getRequired(section, "min")); + max = Integer.parseInt(getRequired(section, "max")); + times1000 = Boolean.parseBoolean(section.get("times1000", "false")); + checkOverMax = Boolean.parseBoolean(section.get("checkOverMax", "false")); + } + + private String getRequired(Ini.Section section, String key) { + String result = section.get(key); + if(result==null) { + throw new IllegalArgumentException("basicsettings.ini, section "+section.getName()+" is missing required setting "+key+"."); + } + return result; + } + + @Override + public String toString() { + return String + .format("BasicSettingMeta [command=%s, title=%s, def=%s, min=%s, max=%s, times1000=%s, checkOverMax=%s]", + command, title, def, min, max, times1000, checkOverMax); + } +} + +// TODO: Extend with additional metadata +class GameModMeta { + final int bitmaskIndex; + + public GameModMeta(Ini.Section section) { + bitmaskIndex = Integer.parseInt(getRequired(section, "bitmaskIndex")); + } + + private String getRequired(Ini.Section section, String key) { + String result = section.get(key); + if(result==null) { + throw new IllegalArgumentException("gamemods.ini, section "+section.getName()+" is missing required setting "+key+"."); + } + return result; + } + + @Override + public String toString() { + return String.format("GameModMeta [bitmaskIndex=%s]", bitmaskIndex); + } +} \ No newline at end of file diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Team.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Team.java Fri Jun 01 12:42:44 2012 +0400 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/Team.java Sat Jun 02 14:27:09 2012 +0200 @@ -88,6 +88,7 @@ readFromParcel(in); } + @Override public boolean equals(Object o){ if(super.equals(o)) return true; else if(o instanceof Team){ @@ -103,6 +104,19 @@ return false; } } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((grave == null) ? 0 : grave.hashCode()); + result = prime * result + ((flag == null) ? 0 : flag.hashCode()); + result = prime * result + ((voice == null) ? 0 : voice.hashCode()); + result = prime * result + ((fort == null) ? 0 : fort.hashCode()); + result = prime * result + ((hash == null) ? 0 : hash.hashCode()); + return result; + } public void setRandomColor(int[] illegalcolors){ Integer[] colorsToPickFrom = TEAM_COLORS; diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Downloader/DownloadAsyncTask.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Downloader/DownloadAsyncTask.java Fri Jun 01 12:42:44 2012 +0400 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Downloader/DownloadAsyncTask.java Sat Jun 02 14:27:09 2012 +0200 @@ -107,7 +107,7 @@ entry = input.getNextEntry(); }catch(IOException e){ e.printStackTrace(); - if(conn != null) conn.disconnect(); + conn.disconnect(); return EXIT_CONNERROR; } diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Downloader/DownloadListActivity.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Downloader/DownloadListActivity.java Fri Jun 01 12:42:44 2012 +0400 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Downloader/DownloadListActivity.java Sat Jun 02 14:27:09 2012 +0200 @@ -6,7 +6,6 @@ import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; -import android.util.Log; import android.view.Gravity; import android.view.View; import android.view.View.OnClickListener; diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Downloader/DownloadPackage.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Downloader/DownloadPackage.java Fri Jun 01 12:42:44 2012 +0400 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Downloader/DownloadPackage.java Sat Jun 02 14:27:09 2012 +0200 @@ -29,7 +29,6 @@ import android.os.Parcel; import android.os.Parcelable; import android.preference.PreferenceManager; -import android.util.Log; public class DownloadPackage implements Parcelable{ private String url_without_suffix; diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/EngineProtocol/GameConfig.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/EngineProtocol/GameConfig.java Fri Jun 01 12:42:44 2012 +0400 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/EngineProtocol/GameConfig.java Sat Jun 02 14:27:09 2012 +0200 @@ -79,7 +79,7 @@ weapon.sendToEngine(epn, teamCount); for(Team t : teams){ - if(t != null)t.sendToEngine(epn, teamCount, scheme.health); + if(t != null)t.sendToEngine(epn, teamCount, scheme.getHealth()); } } diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/MainActivity.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/MainActivity.java Fri Jun 01 12:42:44 2012 +0400 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/MainActivity.java Sat Jun 02 14:27:09 2012 +0200 @@ -26,7 +26,6 @@ import android.app.ProgressDialog; import android.content.DialogInterface; import android.content.Intent; -import android.content.pm.PackageInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.os.Bundle; import android.preference.PreferenceManager; diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/SDLActivity.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/SDLActivity.java Fri Jun 01 12:42:44 2012 +0400 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/SDLActivity.java Sat Jun 02 14:27:09 2012 +0200 @@ -574,34 +574,29 @@ // Touch events public boolean onTouch(View v, MotionEvent event) { - { - final int touchDevId = event.getDeviceId(); - final int pointerCount = event.getPointerCount(); - // touchId, pointerId, action, x, y, pressure - int actionPointerIndex = event.getActionIndex(); - int pointerFingerId = event.getPointerId(actionPointerIndex); - int action = event.getActionMasked(); - - float x = event.getX(actionPointerIndex); - float y = event.getY(actionPointerIndex); - float p = event.getPressure(actionPointerIndex); + final int action = event.getAction() & MotionEvent.ACTION_MASK; + final int actionPointerIndex = event.getAction() & MotionEvent.ACTION_POINTER_ID_MASK; - if (action == MotionEvent.ACTION_MOVE && pointerCount > 1) { - // TODO send motion to every pointer if its position has - // changed since prev event. - for (int i = 0; i < pointerCount; i++) { - pointerFingerId = event.getPointerId(i); - x = event.getX(i); - y = event.getY(i); - p = event.getPressure(i); - SDLActivity.onNativeTouch(touchDevId, pointerFingerId, action, x, y, p); - } - } else { - SDLActivity.onNativeTouch(touchDevId, pointerFingerId, action, x, y, p); + if (action == MotionEvent.ACTION_MOVE) { + // TODO send motion to every pointer if its position has + // changed since prev event. + for (int i = 0; i < event.getPointerCount(); i++) { + sendNativeTouch(event, action, i); } + } else { + sendNativeTouch(event, action, actionPointerIndex); } return true; } + + private static void sendNativeTouch(MotionEvent event, int action, int pointerIndex) { + int touchDevId = event.getDeviceId(); + int pointerFingerId = event.getPointerId(pointerIndex); + float x = event.getX(pointerIndex); + float y = event.getY(pointerIndex); + float pressure = event.getPressure(pointerIndex); + SDLActivity.onNativeTouch(touchDevId, pointerFingerId, action, x, y, pressure); + } // Sensor events public void enableSensor(int sensortype, boolean enabled) { @@ -627,6 +622,5 @@ event.values[2] / SensorManager.GRAVITY_EARTH); } } - } diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/StartGameActivity.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/StartGameActivity.java Fri Jun 01 12:42:44 2012 +0400 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/StartGameActivity.java Sat Jun 02 14:27:09 2012 +0200 @@ -29,11 +29,9 @@ import android.app.Activity; import android.content.Intent; -import android.content.SharedPreferences; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Parcelable; -import android.preference.PreferenceManager; import android.view.View; import android.view.View.OnClickListener; import android.widget.AdapterView; @@ -56,7 +54,7 @@ public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); - Scheme.parseBasicFlags(this); + Scheme.parseConfiguration(this); config = new GameConfig(); setContentView(R.layout.starting_game); diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/TeamCreatorActivity.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/TeamCreatorActivity.java Fri Jun 01 12:42:44 2012 +0400 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/TeamCreatorActivity.java Sat Jun 02 14:27:09 2012 +0200 @@ -311,7 +311,7 @@ imgFort.setImageDrawable(fortIconDrawable); scroller.fullScroll(ScrollView.FOCUS_DOWN);// Scroll the scrollview // to the bottom, work - // around for scollview + // around for scrollview // invalidation (scrolls // back to top) } diff -r fad64b97947e -r 8d1d6adf5f82 project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Utils.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Utils.java Fri Jun 01 12:42:44 2012 +0400 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Utils.java Sat Jun 02 14:27:09 2012 +0200 @@ -27,6 +27,7 @@ import java.util.ArrayList; import java.util.List; +import android.annotation.TargetApi; import android.content.Context; import android.content.res.TypedArray; import android.os.Build; @@ -54,6 +55,7 @@ return getCachePath(c) + ROOT_DIR; } + @TargetApi(8) static class FroyoSDCardDir{ public static String getDownloadPath(Context c){ File f = c.getExternalCacheDir(); diff -r fad64b97947e -r 8d1d6adf5f82 project_files/frontlib/buffer.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/frontlib/buffer.c Sat Jun 02 14:27:09 2012 +0200 @@ -0,0 +1,90 @@ +#include "buffer.h" +#include "logging.h" + +#include +#include +#include + +typedef struct _flib_vector { + void *data; + size_t size; + size_t capacity; +} _flib_vector; + +flib_vector flib_vector_create() { + flib_vector result = malloc(sizeof(_flib_vector)); + if(result == NULL) { + return NULL; + } + result->data = malloc(16); + if(result->data == NULL) { + free(result); + return NULL; + } + result->size = 0; + result->capacity = 16; + return result; +} + +void flib_vector_destroy(flib_vector *vec) { + if(vec && *vec) { + free((*vec)->data); + free(*vec); + *vec = NULL; + } +} + +static void try_realloc(flib_vector vec, size_t newCapacity) { + void *newData = realloc(vec->data, newCapacity); + if(newData) { + vec->data = newData; + vec->capacity = newCapacity; + } +} + +static size_t getFreeCapacity(flib_vector vec) { + return vec->capacity - vec->size; +} + +int flib_vector_append(flib_vector vec, const void *data, size_t len) { + if(getFreeCapacity(vec) < len) { + // Resize exponentially for constant amortized time, + // But at least by as much as we need of course, + // and be extra careful with integer overflows... + size_t extraCapacity = (vec->capacity)/2; + + size_t minExtraCapacity = len - getFreeCapacity(vec); + if(extraCapacity < minExtraCapacity) { + extraCapacity = minExtraCapacity; + } + + if(extraCapacity <= SIZE_MAX - vec->capacity) { + try_realloc(vec, vec->capacity+extraCapacity); + } + + // Check if we were able to resize. + // If not, try to allocate at least what we need... + if(getFreeCapacity(vec) < len) { + try_realloc(vec, vec->capacity+minExtraCapacity); + + // Still not working? Then we fail. + if(getFreeCapacity(vec) < len) { + return 0; + } + } + } + + memmove(vec->data + vec->size, data, len); + vec->size += len; + return len; +} + +flib_buffer flib_vector_as_buffer(flib_vector vec) { + flib_buffer result = {vec->data, vec->size}; + return result; +} + +flib_constbuffer flib_vector_as_constbuffer(flib_vector vec) { + flib_constbuffer result = {vec->data, vec->size}; + return result; +} diff -r fad64b97947e -r 8d1d6adf5f82 project_files/frontlib/buffer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/frontlib/buffer.h Sat Jun 02 14:27:09 2012 +0200 @@ -0,0 +1,58 @@ +#ifndef BUFFER_H_ +#define BUFFER_H_ + +#include +#include + +/** + * A simple struct to hold both the pointer to an array and its size, + * for e.g. conveniently returning it from a function. + * + * Convention: Size is zero iff data is a NULL pointer. + */ +typedef struct { + void *data; + size_t size; +} flib_buffer; + +/** + * Just like flib_buffer, but the contents are not supposed to be modified. + */ +typedef struct { + const void *data; + size_t size; +} flib_constbuffer; + +/** + * Simple variable-capacity data structure (opaque type). + */ +struct _flib_vector; +typedef struct _flib_vector *flib_vector; + +/** + * Create a new vector. Needs to be destroyed again later with flib_vector_destroy. + * May return NULL if memory runs out. + */ +flib_vector flib_vector_create(); + +/** + * Free the memory of this vector and set it to NULL. + */ +void flib_vector_destroy(flib_vector *vec); + +/** + * Append the provided data to the end of the vector, enlarging it as required. + * Returns the ammount of data appended, which is either len (success) or 0 (out of memory). + * The vector remains unchanged if an out of memory situation occurs. + */ +int flib_vector_append(flib_vector vec, const void *data, size_t len); + +/** + * Return a buffer or constbuffer pointing to the current contents of the vector. + * These will become invalid if the vector size or capacity is changed. + */ +flib_buffer flib_vector_as_buffer(flib_vector vec); +flib_constbuffer flib_vector_as_constbuffer(flib_vector vec); + + +#endif diff -r fad64b97947e -r 8d1d6adf5f82 project_files/frontlib/events.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/frontlib/events.c Sat Jun 02 14:27:09 2012 +0200 @@ -0,0 +1,2 @@ +#include "events.h" + diff -r fad64b97947e -r 8d1d6adf5f82 project_files/frontlib/events.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/frontlib/events.h Sat Jun 02 14:27:09 2012 +0200 @@ -0,0 +1,14 @@ +/* + * events.h + * + * Created on: 01.06.2012 + * Author: simmax + */ + +#ifndef EVENTS_H_ +#define EVENTS_H_ + + + + +#endif /* EVENTS_H_ */ diff -r fad64b97947e -r 8d1d6adf5f82 project_files/frontlib/frontlib.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/frontlib/frontlib.c Sat Jun 02 14:27:09 2012 +0200 @@ -0,0 +1,87 @@ +#include "frontlib.h" +#include "logging.h" +#include "nonblocksockets.h" +#include "ipcconn.h" + +#include +#include +#include +#include +#include + +static int flib_initflags; + +int flib_init(int flags) { + flib_initflags = flags; + + if(!(flib_initflags | FRONTLIB_SDL_ALREADY_INITIALIZED)) { + if(SDL_Init(0)==-1) { + flib_log_e("Error in SDL_Init: %s", SDL_GetError()); + return -1; + } + } + + if(SDLNet_Init()==-1) { + flib_log_e("Error in SDLNet_Init: %s", SDLNet_GetError()); + if(!(flib_initflags | FRONTLIB_SDL_ALREADY_INITIALIZED)) { + SDL_Quit(); + } + return -1; + } + + flib_ipcconn_init(); + return 0; +} + +void flib_quit() { + flib_ipcconn_quit(); + + SDLNet_Quit(); + if(!(flib_initflags | FRONTLIB_SDL_ALREADY_INITIALIZED)) { + SDL_Quit(); + } +} + +int main(int argc, char *argv[]) { + flib_init(FRONTLIB_SDL_ALREADY_INITIALIZED); + flib_ipcconn_start(true); + char data[256]; + while(flib_ipcconn_state() != IPC_NOT_CONNECTED) { + flib_ipcconn_tick(); + int size = flib_ipcconn_recv_message(data); + if(size>0) { + data[size]=0; + flib_log_i("IPC IN: %s", data); + switch(data[0]) { + case 'C': + flib_log_i("Sending config..."); + flib_ipcconn_send_messagestr("TL"); + flib_ipcconn_send_messagestr("eseed loremipsum"); + flib_ipcconn_send_messagestr("escript Missions/Training/Basic_Training_-_Bazooka.lua"); + break; + case '?': + flib_log_i("Sending pong..."); + flib_ipcconn_send_messagestr("!"); + break; + case 'Q': + flib_log_i("Game interrupted."); + break; + case 'q': + flib_log_i("Game finished."); + flib_constbuffer demobuf = flib_ipcconn_getdemo(); + flib_log_i("Writing demo (%u bytes)...", demobuf.size); + FILE *file = fopen("testdemo.dem", "w"); + fwrite(demobuf.data, 1, demobuf.size, file); + fclose(file); + file = NULL; + break; + case 'H': + flib_log_i("Game halted."); + break; + } + } + } + flib_log_i("IPC connection lost."); + flib_quit(); + return 0; +} diff -r fad64b97947e -r 8d1d6adf5f82 project_files/frontlib/frontlib.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/frontlib/frontlib.h Sat Jun 02 14:27:09 2012 +0200 @@ -0,0 +1,31 @@ +/* + * Public header file for the hedgewars frontent networking library. + * + * This is the only header you should need to include from frontend code. + */ + +#ifndef FRONTLIB_H_ +#define FRONTLIB_H_ + +#define FRONTLIB_SDL_ALREADY_INITIALIZED 1 + +/** + * Call this function before anything else in this library. + * + * If the calling program uses SDL, it needs to call SDL_Init before initializing + * this library and then pass FRONTLIB_SDL_ALREADY_INITIALIZED as flag to this function. + * + * Otherwise, pass 0 to let this library handle SDL_Init an SDL_Quit itself. + * + * Returns 0 on success, -1 on error. + */ +int flib_init(int flags); + +/** + * Free resources associated with the library. Call this function once + * the library is no longer needed. You can re-initialize the library by calling + * flib_init again. + */ +void flib_quit(); + +#endif /* FRONTLIB_H_ */ diff -r fad64b97947e -r 8d1d6adf5f82 project_files/frontlib/ipcconn.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/frontlib/ipcconn.c Sat Jun 02 14:27:09 2012 +0200 @@ -0,0 +1,220 @@ +#include "ipcconn.h" +#include "logging.h" +#include "nonblocksockets.h" + +#include +#include +#include +#include + +static TCPsocket ipcListenSocket; +static NonBlockSocket ipcConnSocket; + +static uint8_t ipcReadBuffer[256]; +static int ipcReadBufferSize; + +static flib_vector demoBuffer; +static char localPlayerName[255]; + +void flib_ipcconn_init() { + ipcListenSocket = NULL; + ipcConnSocket = NULL; + ipcReadBufferSize = 0; + demoBuffer=NULL; + strncpy(localPlayerName, "Local Player", 255); +} + +void flib_ipcconn_quit() { + flib_vector_destroy(&demoBuffer); + flib_ipcconn_close(); +} + +int flib_ipcconn_start(bool recordDemo) { + if(ipcListenSocket || ipcConnSocket) { + flib_log_e("flib_ipcconn_listen: Already listening or connected."); + return -1; + } + IPaddress addr; + addr.host = INADDR_ANY; + + /* SDL_net does not seem to have a way to listen on a random unused port + and find out which port that is, so let's try to find one ourselves. */ + // TODO: Is socket binding fail-fast on all platforms? + srand(time(NULL)); + rand(); + for(int i=0; i<1000; i++) { + // IANA suggests using ports in the range 49152-65535 for things like this + int ipcPort = 49152+(rand()%(65535-49152)); + SDLNet_Write16(ipcPort, &addr.port); + ipcListenSocket = SDLNet_TCP_Open(&addr); + if(!ipcListenSocket) { + flib_log_w("Failed to start an IPC listening socket on port %i: %s", ipcPort, SDLNet_GetError()); + } else { + flib_log_i("Listening for IPC connections on port %i.", ipcPort); + if(recordDemo) { + flib_vector_destroy(&demoBuffer); + demoBuffer = flib_vector_create(); + } + return ipcPort; + } + } + flib_log_e("Unable to find a free port for IPC."); + return -1; +} + +void flib_ipcconn_close() { + if(ipcListenSocket) { + SDLNet_TCP_Close(ipcListenSocket); + ipcListenSocket = NULL; + } + flib_nbsocket_close(&ipcConnSocket); + ipcReadBufferSize = 0; +} + +IpcConnState flib_ipcconn_state() { + if(ipcConnSocket) { + return IPC_CONNECTED; + } else if(ipcListenSocket) { + return IPC_LISTENING; + } else { + return IPC_NOT_CONNECTED; + } +} + +static void demo_record(const void *data, size_t len) { + if(demoBuffer) { + if(flib_vector_append(demoBuffer, data, len) < len) { + // Out of memory, fail demo recording + flib_vector_destroy(&demoBuffer); + } + } +} + +static void demo_record_from_engine(const uint8_t *message) { + if(!demoBuffer || message[0]==0) { + return; + } + if(strchr("?CEiQqHb", message[1])) { + // Those message types are not recorded in a demo. + return; + } + + if(message[1] == 's') { + if(message[0] >= 3) { + // Chat messages get a special once-over to make them look as if they were received, not sent. + // Get the actual chat message as c string + char chatMsg[256]; + memcpy(chatMsg, message+2, message[0]-3); + chatMsg[message[0]-3] = 0; + + char converted[257]; + bool memessage = message[0] >= 7 && !memcmp(message+2, "/me ", 4); + const char *template = memessage ? "s\x02* %s %s " : "s\x01%s: %s "; + int size = snprintf(converted+1, 256, template, localPlayerName, chatMsg); + converted[0] = size>255 ? 255 : size; + demo_record(converted, converted[0]+1); + } + } else { + demo_record(message, message[0]+1); + } +} + +/** + * Receive a single message and copy it into the data buffer. + * Returns the length of the received message, -1 when nothing is received. + */ +int flib_ipcconn_recv_message(void *data) { + flib_ipcconn_tick(); + + if(ipcConnSocket) { + int size = flib_nbsocket_recv(ipcConnSocket, ipcReadBuffer+ipcReadBufferSize, sizeof(ipcReadBuffer)-ipcReadBufferSize); + if(size>=0) { + ipcReadBufferSize += size; + } else { + flib_nbsocket_close(&ipcConnSocket); + } + } + + int msgsize = ipcReadBuffer[0]; + if(ipcReadBufferSize > msgsize) { + demo_record_from_engine(ipcReadBuffer); + memcpy(data, ipcReadBuffer+1, msgsize); + memmove(ipcReadBuffer, ipcReadBuffer+msgsize+1, ipcReadBufferSize-(msgsize+1)); + ipcReadBufferSize -= (msgsize+1); + return msgsize; + } else if(!ipcConnSocket && ipcReadBufferSize>0) { + flib_log_w("Last message from engine data stream is incomplete (received %u of %u bytes)", ipcReadBufferSize-1, msgsize); + ipcReadBufferSize = 0; + return -1; + } else { + return -1; + } +} + +int flib_ipcconn_send_message(void *data, size_t len) { + flib_ipcconn_tick(); + + if(!ipcConnSocket) { + flib_log_w("flib_ipcconn_send_message: Not connected."); + return -1; + } + if(len>255) { + flib_log_e("Attempt to send too much data to the engine in a single message."); + return -1; + } + + uint8_t sendbuf[256]; + sendbuf[0] = len; + memcpy(sendbuf+1, data, len); + if(flib_nbsocket_blocksend(ipcConnSocket, sendbuf, len+1) == len+1) { + demo_record(sendbuf, len+1); + return 0; + } else { + flib_log_w("Failed or incomplete ICP write: engine connection lost."); + flib_nbsocket_close(&ipcConnSocket); + return -1; + } +} + +int flib_ipcconn_send_messagestr(char *data) { + return flib_ipcconn_send_message(data, strlen(data)); +} + +void flib_ipcconn_tick() { + if(!ipcConnSocket && ipcListenSocket) { + ipcConnSocket = flib_nbsocket_accept(ipcListenSocket, true); + if(ipcConnSocket) { + SDLNet_TCP_Close(ipcListenSocket); + ipcListenSocket = NULL; + } + } +} + +static void replace_gamemode(flib_buffer buf, char gamemode) { + size_t msgStart = 0; + char *data = (char*)buf.data; + while(msgStart+2 < buf.size) { + if(!memcmp(data+msgStart, "\x02T", 2)) { + data[msgStart+2] = gamemode; + } + msgStart += (uint8_t)data[msgStart]+1; + } +} + +flib_constbuffer flib_ipcconn_getdemo() { + if(!demoBuffer) { + flib_constbuffer result = {NULL, 0}; + return result; + } + replace_gamemode(flib_vector_as_buffer(demoBuffer), 'D'); + return flib_vector_as_constbuffer(demoBuffer); +} + +flib_constbuffer flib_ipcconn_getsave() { + if(!demoBuffer) { + flib_constbuffer result = {NULL, 0}; + return result; + } + replace_gamemode(flib_vector_as_buffer(demoBuffer), 'S'); + return flib_vector_as_constbuffer(demoBuffer); +} diff -r fad64b97947e -r 8d1d6adf5f82 project_files/frontlib/ipcconn.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/frontlib/ipcconn.h Sat Jun 02 14:27:09 2012 +0200 @@ -0,0 +1,109 @@ +/* + * Low-level protocol support for the IPC connection to the engine. + */ + +#ifndef IPCCONN_H_ +#define IPCCONN_H_ + +#include "buffer.h" + +#include +#include + +typedef enum {IPC_NOT_CONNECTED, IPC_LISTENING, IPC_CONNECTED} IpcConnState; + +/** + * Called by flib_init(). Initialize everything related to ipc. + */ +void flib_ipcconn_init(); + +/** + * Called by flib_quit(). Free resources and shut down. + */ +void flib_ipcconn_quit(); + +/** + * Start listening for a connection from the engine. The system has to be in state + * IPC_NOT_CONNECTED when calling this function, and will be in state IPC_LISTENING + * if the function returns successfully. + * + * The parameter "recordDemo" can be used to control whether demo recording should + * be enabled for this connection. + * + * Returns the port we started listening on, or a negative value if there is an error. + * + * We stop listening once a connection has been established, so if you want to start + * the engine again and talk to it you need to call this function again after the old + * connection is closed. + */ +int flib_ipcconn_start(bool recordDemo); + +/** + * Close the current IPC connection and/or stop listening for an incoming one. + * This also discards all unread messages. + */ +void flib_ipcconn_close(); + +/** + * Determine the current connection state + */ +IpcConnState flib_ipcconn_state(); + +/** + * Receive a single message (up to 255 bytes) and copy it into the data buffer. + * Returns the length of the received message, a negative value if no message could + * be read. + * + * Note: When a connection is closed, you probably want to call this function until + * no further message is returned, to ensure you see all messages that were sent + * before the connection closed. + */ +int flib_ipcconn_recv_message(void *data); + +/** + * Write a single message (up to 255 bytes) to the engine. This call blocks until the + * message is completely written or the connection is closed or an error occurs. + * + * Calling this function in a state other than IPC_CONNECTED will fail immediately. + * Returns a negative value on failure. + */ +int flib_ipcconn_send_message(void *data, size_t len); + +/** + * Convenience function for sending a 0-delimited string. + */ +int flib_ipcconn_send_messagestr(char *data); + +/** + * Call regularly to allow background work to proceed + */ +void flib_ipcconn_tick(); + +/** + * Get a demo record of the last connection. This should be called after + * the connection is closed and all messages have been received. + * + * If demo recording was not enabled in the last call to flib_ipcconn_start(), + * or if the recording failed for some reason, the buffer will be empty. + * + * The buffer is only valid until the next call to flib_ipcconn_start() or + * a call to flib_ipcconn_getsave() (save and demo records have some minor + * differences, and those are performed directly on the buffer before returning it). + */ +flib_constbuffer flib_ipcconn_getdemo(); + +/** + * Get a savegame record of the last connection. This should be called after + * the connection is closed and all messages have been received. + * + * If demo recording was not enabled in the last call to flib_ipcconn_start(), + * or if the recording failed for some reason, the buffer will be empty. + * + * The buffer is only valid until the next call to flib_ipcconn_start() or + * a call to flib_ipcconn_getdemo() (save and demo records have some minor + * differences, and those are performed directly on the buffer before returning it). + */ +flib_constbuffer flib_ipcconn_getsave(); + +#endif /* IPCCONN_H_ */ + diff -r fad64b97947e -r 8d1d6adf5f82 project_files/frontlib/logging.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/frontlib/logging.c Sat Jun 02 14:27:09 2012 +0200 @@ -0,0 +1,53 @@ +#include "logging.h" + +#include +#include +#include +#include + +char* flib_format_ip(uint32_t numip) { + static char ip[16]; + snprintf(ip, 16, "%u.%u.%u.%u", numip>>24, (numip>>16)&0xff, (numip>>8)&0xff, numip&0xff); + return ip; +} + +static void log_time(FILE *file) { + time_t timer; + char buffer[25]; + struct tm* tm_info; + + time(&timer); + tm_info = localtime(&timer); + + strftime(buffer, 25, "%Y-%m-%d %H:%M:%S", tm_info); + fprintf(file, "%s", buffer); +} + +static void flib_vflog(FILE *file, const char *prefix, const char *fmt, va_list args) { + log_time(file); + fprintf(file, " [%s]", prefix); + vfprintf(file, fmt, args); + fprintf(file, "\n"); + fflush(file); +} + +void flib_log_e(const char *fmt, ...) { + va_list argp; + va_start(argp, fmt); + flib_vflog(stderr, "E", fmt, argp); + va_end(argp); +} + +void flib_log_w(const char *fmt, ...) { + va_list argp; + va_start(argp, fmt); + flib_vflog(stdout, "W", fmt, argp); + va_end(argp); +} + +void flib_log_i(const char *fmt, ...) { + va_list argp; + va_start(argp, fmt); + flib_vflog(stdout, "I", fmt, argp); + va_end(argp); +} diff -r fad64b97947e -r 8d1d6adf5f82 project_files/frontlib/logging.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/frontlib/logging.h Sat Jun 02 14:27:09 2012 +0200 @@ -0,0 +1,16 @@ +/* + * + */ + +#ifndef LOGGING_H_ +#define LOGGING_H_ + +#include + +char* flib_format_ip(uint32_t numip); + +void flib_log_e(const char *fmt, ...); +void flib_log_w(const char *fmt, ...); +void flib_log_i(const char *fmt, ...); + +#endif /* LOGGING_H_ */ diff -r fad64b97947e -r 8d1d6adf5f82 project_files/frontlib/nonblocksockets.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/frontlib/nonblocksockets.c Sat Jun 02 14:27:09 2012 +0200 @@ -0,0 +1,76 @@ +#include "nonblocksockets.h" +#include "logging.h" +#include + +static uint32_t get_peer_ip(TCPsocket sock) { + IPaddress *addr = SDLNet_TCP_GetPeerAddress(sock); + return SDLNet_Read32(&addr->host); +} + +static bool connection_is_local(TCPsocket sock) { + return get_peer_ip(sock) == (uint32_t)((127UL<<24)+1); // 127.0.0.1 +} + +void flib_nbsocket_close(NonBlockSocket *nbsockptr) { + NonBlockSocket nbsock = *nbsockptr; + if(nbsock!=NULL) { + SDLNet_DelSocket(nbsock->sockset, (SDLNet_GenericSocket)nbsock->sock); + SDLNet_TCP_Close(nbsock->sock); + SDLNet_FreeSocketSet(nbsock->sockset); + } + free(nbsock); + *nbsockptr = NULL; +} + +NonBlockSocket flib_nbsocket_accept(TCPsocket listensocket, bool localOnly) { + NonBlockSocket result = NULL; + if(!listensocket) { + flib_log_e("Attempt to accept a connection on a NULL socket."); + return NULL; + } + while(result==NULL) { + TCPsocket sock = SDLNet_TCP_Accept(listensocket); + if(!sock) { + // No incoming connections + return NULL; + } + if(localOnly && !connection_is_local(sock)) { + flib_log_i("Rejected nonlocal connection attempt from %s", flib_format_ip(get_peer_ip(sock))); + SDLNet_TCP_Close(sock); + } else { + result = malloc(sizeof(_NonBlockSocket)); + if(result==NULL) { + flib_log_e("Out of memory!"); + SDLNet_TCP_Close(sock); + return NULL; + } + result->sock = sock; + result->sockset = SDLNet_AllocSocketSet(1); + if(result->sockset==NULL) { + flib_log_e("Out of memory!"); + SDLNet_TCP_Close(sock); + free(result); + return NULL; + } + SDLNet_AddSocket(result->sockset, (SDLNet_GenericSocket)result->sock); + } + } + return result; +} + +int flib_nbsocket_recv(NonBlockSocket sock, void *data, int maxlen) { + if(!sock) { + flib_log_e("Attempt to receive on a NULL socket."); + return -1; + } + int readySockets = SDLNet_CheckSockets(sock->sockset, 0); + if(readySockets>0) { + int size = SDLNet_TCP_Recv(sock->sock, data, maxlen); + return size>0 ? size : -1; + } else if(readySockets==0) { + return 0; + } else { + flib_log_e("Error in select system call: %s", SDLNet_GetError()); + return -1; + } +} diff -r fad64b97947e -r 8d1d6adf5f82 project_files/frontlib/nonblocksockets.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project_files/frontlib/nonblocksockets.h Sat Jun 02 14:27:09 2012 +0200 @@ -0,0 +1,51 @@ +/* + * nonblocksockets.h + * + * Created on: 31.05.2012 + * Author: simmax + */ + +#ifndef NONBLOCKSOCKETS_H_ +#define NONBLOCKSOCKETS_H_ + +#include +#include + +typedef struct { + TCPsocket sock; + SDLNet_SocketSet sockset; +} _NonBlockSocket; + +typedef _NonBlockSocket *NonBlockSocket; + +/** + * Close the indicated socket, free its memory and set it to NULL. + * If the socket is already NULL, nothing happens. + */ +void flib_nbsocket_close(NonBlockSocket *socket); + +/** + * Try to accept a connection from a listening socket. + * if localOnly is true, this will only accept connections which came from 127.0.0.1 + * Returns NULL if nothing can be accepted. + */ +NonBlockSocket flib_nbsocket_accept(TCPsocket listensocket, bool localOnly); + +/** + * Attempt to receive up to maxlen bytes from the socket, but does not + * block if nothing is available. + * Returns the ammount of data received, 0 if there was nothing to receive, + * or a negative number if the connection was closed or an error occurred. + */ +int flib_nbsocket_recv(NonBlockSocket sock, void *data, int maxlen); + +/** + * We can't do a nonblocking send over SDL_net, so this function just forwards + * to SDLNet_TCP_Send for convenience, which blocks until all data is sent or an + * error occurs. The ammount of data actually sent is returned, negative value on error. + */ +static inline int flib_nbsocket_blocksend(NonBlockSocket sock, void *data, int len) { + return SDLNet_TCP_Send(sock->sock, data, len); +} + +#endif /* NONBLOCKSOCKETS_H_ */ diff -r fad64b97947e -r 8d1d6adf5f82 share/hedgewars/Data/Maps/Sticks/map.cfg diff -r fad64b97947e -r 8d1d6adf5f82 share/hedgewars/Data/Maps/Sticks/preview@2x.png diff -r fad64b97947e -r 8d1d6adf5f82 share/hedgewars/Data/Music/Nature.ogg