neglected stuff
authornemo
Thu, 30 Aug 2012 14:26:05 -0400
changeset 7629 d624030abf24
parent 7628 bc7b1d228a2c
child 7630 13fa53bb3134
neglected stuff
QTfrontend/game.cpp
hedgewars/uCommandHandlers.pas
hedgewars/uVariables.pas
--- a/QTfrontend/game.cpp	Thu Aug 30 13:02:19 2012 -0400
+++ b/QTfrontend/game.cpp	Thu Aug 30 14:26:05 2012 -0400
@@ -21,6 +21,8 @@
 #include <QUuid>
 #include <QColor>
 #include <QStringListModel>
+#include <QMessageBox>
+#include <QTextStream>
 
 #include "game.h"
 #include "hwconsts.h"
@@ -29,10 +31,12 @@
 #include "teamselect.h"
 #include "KB.h"
 #include "proto.h"
+#include "campaign.h"
 
 #include <QTextStream>
+#include "ThemeModel.h"
 
-QString training, campaign; // TODO: Cleaner solution?
+QString training, campaign, campaignScript, campaignTeam; // TODO: Cleaner solution?
 
 HWGame::HWGame(GameUIConfig * config, GameCFGWidget * gamecfg, QString ammo, TeamSelWidget* pTeamSelWidget) :
     TCPBase(true),
@@ -98,7 +102,7 @@
             HWProto::addStringToBuffer(buf, QString("eammprob %1").arg(ammostr.mid(cAmmoNumber, cAmmoNumber)));
             HWProto::addStringToBuffer(buf, QString("eammdelay %1").arg(ammostr.mid(2 * cAmmoNumber, cAmmoNumber)));
             HWProto::addStringToBuffer(buf, QString("eammreinf %1").arg(ammostr.mid(3 * cAmmoNumber, cAmmoNumber)));
-            if(!gamecfg->schemeData(21).toBool()) HWProto::addStringToBuffer(buf, QString("eammstore"));
+            if(gamecfg->schemeData(15).toBool() || !gamecfg->schemeData(21).toBool()) HWProto::addStringToBuffer(buf, QString("eammstore"));
             HWProto::addStringListToBuffer(buf,
                                            team.teamGameConfig(gamecfg->getInitHealth()));
             ;
@@ -165,7 +169,7 @@
     HWProto::addStringToBuffer(campaigncfg, "TL");
     HWProto::addStringToBuffer(campaigncfg, "eseed " + QUuid::createUuid().toString());
 
-    HWProto::addStringToBuffer(campaigncfg, "escript " + campaign);
+    HWProto::addStringToBuffer(campaigncfg, "escript " + campaignScript);
 
     RawSendIPC(campaigncfg);
 }
@@ -277,6 +281,14 @@
             emit SendTeamMessage(msgbody);
             break;
         }
+        case 'V':
+        {
+            if (msg.at(2) == '?')
+                sendCampaignVar(msg.right(msg.size() - 3));
+            else if (msg.at(2) == '!')
+                writeCampaignVar(msg.right(msg.size() - 3));
+            break;
+        }
         default:
         {
             if (gameType == gtNet && !netSuspend)
@@ -391,10 +403,12 @@
     SetGameState(gsStarted);
 }
 
-void HWGame::StartCampaign(const QString & file)
+void HWGame::StartCampaign(const QString & camp, const QString & campScript, const QString & campTeam)
 {
     gameType = gtCampaign;
-    campaign = "Missions/Campaign/" + file + ".lua";
+    campaign = camp;
+    campaignScript = "Missions/Campaign/" + camp + "/" + campScript;
+    campaignTeam = campTeam;
     demo.clear();
     Start();
     SetGameState(gsStarted);
@@ -404,6 +418,10 @@
 {
     gameState = state;
     emit GameStateChanged(state);
+    if (gameType == gtCampaign)
+    {
+      emit CampStateChanged(1);
+    }
 }
 
 void HWGame::abort()
@@ -412,3 +430,37 @@
     HWProto::addStringToBuffer(buf, QString("efinish"));
     RawSendIPC(buf);
 }
+
+void HWGame::sendCampaignVar(QByteArray varToSend)
+{
+    QString varToFind(varToSend);
+    QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + campaignTeam + ".hwt", QSettings::IniFormat, 0);
+    teamfile.setIniCodec("UTF-8");
+    QString varValue = teamfile.value("Campaign " + campaign + "/" + varToFind, "").toString();
+    QByteArray command;
+    HWProto::addStringToBuffer(command, "V." + varValue);
+    RawSendIPC(command);
+}
+
+void HWGame::writeCampaignVar(QByteArray varVal)
+{
+    QString varToWrite("");
+    QString varValue("");
+    unsigned int i = 0;
+    while (i < varVal.size() && varVal.at(i) != ' ')
+    {
+      varToWrite.append(varVal.at(i));
+      i++;
+    }
+    i++;
+    while (i < varVal.size() && varVal.at(i) != '\0')
+    {
+      varValue.append(varVal.at(i));
+      i++;
+    }
+
+    QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + campaignTeam + ".hwt", QSettings::IniFormat, 0);
+    teamfile.setIniCodec("UTF-8");
+    teamfile.setValue("Campaign " + campaign + "/" + varToWrite, varValue);
+}
+
--- a/hedgewars/uCommandHandlers.pas	Thu Aug 30 13:02:19 2012 -0400
+++ b/hedgewars/uCommandHandlers.pas	Thu Aug 30 14:26:05 2012 -0400
@@ -26,7 +26,8 @@
 procedure freeModule;
 
 implementation
-uses uCommands, uTypes, uVariables, uIO, uDebug, uConsts, uScript, uUtils, SDLh, uRandom, uCaptions;
+uses uCommands, uTypes, uVariables, uIO, uDebug, uConsts, uScript, uUtils, SDLh, uRandom, uCaptions
+     {$IFDEF USE_VIDEO_RECORDING}, uVideoRec {$ENDIF};
 
 var prevGState: TGameState = gsConfirm;
 
@@ -530,6 +531,17 @@
 flagMakeCapture:= true
 end;
 
+procedure chRecord(var s: shortstring);
+begin
+s:= s; // avoid compiler hint
+{$IFDEF USE_VIDEO_RECORDING}
+if flagPrerecording then
+    StopPreRecording()
+else
+    BeginPreRecording();
+{$ENDIF}
+end;
+
 procedure chSetMap(var s: shortstring);
 begin
 if isDeveloperMode then
@@ -614,13 +626,14 @@
 if CheckNoTeamOrHH or isPaused then
     exit;
 
-if FollowGear <> nil then
+if autoCameraOn then
     begin
+    FollowGear:= nil;
     AddCaption('Auto Camera Off', $CCCCCC, capgrpVolume);
     autoCameraOn:= false
     end
-    else
-        begin
+else
+    begin
     AddCaption('Auto Camera On', $CCCCCC, capgrpVolume);
     bShowFinger:= true;
     if not CurrentHedgehog^.Unplaced then
@@ -653,6 +666,7 @@
 procedure chSpeedup_p(var s: shortstring);
 begin
 s:= s; // avoid compiler hint
+SpeedStart:= RealTicks;
 isSpeed:= true
 end;
 
@@ -765,7 +779,7 @@
 procedure chGameFlags(var s: shortstring);
 begin
 GameFlags:= StrToInt(s);
-if GameFlags and gfSharedAmmo <> 0 then GameFlags:= GameFlags and not gfPerHogAmmo
+if GameFlags and gfSharedAmmo <> 0 then GameFlags:= GameFlags and (not gfPerHogAmmo)
 end;
 
 procedure chHedgehogTurnTime(var s: shortstring);
@@ -797,17 +811,17 @@
     RegisterVariable('-up'     , @chUp_m         , false, true);
     RegisterVariable('+left'   , @chLeft_p       , false, true);
     RegisterVariable('-left'   , @chLeft_m       , false, true);
-    RegisterVariable('+attack' , @chAttack_p     , false, false); // WTF?
+    RegisterVariable('+attack' , @chAttack_p     , false);
     RegisterVariable('+down'   , @chDown_p       , false, true);
     RegisterVariable('-down'   , @chDown_m       , false, true);
     RegisterVariable('hjump'   , @chHJump        , false, true);
     RegisterVariable('ljump'   , @chLJump        , false, true);
-    RegisterVariable('nextturn', @chNextTurn     , false, false);
-    RegisterVariable('-attack' , @chAttack_m     , false, false);
-    RegisterVariable('slot'    , @chSlot         , false, true);
+    RegisterVariable('nextturn', @chNextTurn     , false);
+    RegisterVariable('-attack' , @chAttack_m     , false);
+    RegisterVariable('slot'    , @chSlot         , false);
     RegisterVariable('setweap' , @chSetWeapon    , false, true);
 //////// End top by freq analysis
-    RegisterVariable('gencmd'  , @chGenCmd       , false, true);
+    RegisterVariable('gencmd'  , @chGenCmd       , false);
     RegisterVariable('flag'    , @chFlag         , false);
     RegisterVariable('script'  , @chScript       , false);
     RegisterVariable('proto'   , @chCheckProto   , true );
@@ -851,10 +865,10 @@
     RegisterVariable('zoomout' , @chZoomOut      , true );
     RegisterVariable('zoomreset',@chZoomReset    , true );
     RegisterVariable('ammomenu', @chAmmoMenu     , true);
-    RegisterVariable('+precise', @chPrecise_p    , false);
-    RegisterVariable('-precise', @chPrecise_m    , false);
+    RegisterVariable('+precise', @chPrecise_p    , false, true);
+    RegisterVariable('-precise', @chPrecise_m    , false, true);
     RegisterVariable('switch'  , @chSwitch       , false);
-    RegisterVariable('timer'   , @chTimer        , false);
+    RegisterVariable('timer'   , @chTimer        , false, true);
     RegisterVariable('taunt'   , @chTaunt        , false);
     RegisterVariable('put'     , @chPut          , false);
     RegisterVariable('+volup'  , @chVol_p        , true );
@@ -872,6 +886,7 @@
     RegisterVariable('+cur_r'  , @chCurR_p       , true );
     RegisterVariable('-cur_r'  , @chCurR_m       , true );
     RegisterVariable('campvar' , @chCampVar      , true );
+    RegisterVariable('record'  , @chRecord       , true );
 end;
 
 procedure freeModule;
--- a/hedgewars/uVariables.pas	Thu Aug 30 13:02:19 2012 -0400
+++ b/hedgewars/uVariables.pas	Thu Aug 30 14:26:05 2012 -0400
@@ -227,7 +227,7 @@
         '',                              // ptData
         'Graphics',                      // ptGraphics
         'Themes',                        // ptThemes
-        'Themes/avematan',               // ptCurrTheme
+        'Themes/Bamboo',                 // ptCurrTheme
         'Teams',                         // ptTeams
         'Maps',                          // ptMaps
         '',                              // ptMapCurrent
@@ -2645,6 +2645,7 @@
     LuaGoals:= '';
 
     LuaTemplateNumber:= 0;
+    hiddenHedgehogsNumber:=0;
 end;
 
 procedure freeModule;