hedgewars/uFLSchemes.pas
author unc0rr
Wed, 16 Dec 2015 00:20:56 +0300
branchqmlfrontend
changeset 11463 8318e841648f
parent 11461 ab77e2ea2f82
permissions -rw-r--r--
Send full game config to the engine
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10616
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
     1
unit uFLSchemes;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
     2
interface
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
     3
uses uFLTypes;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
     4
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
     5
function getSchemesList: PPChar; cdecl;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
     6
procedure freeSchemesList;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
     7
10819
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
     8
function schemeByName(s: shortstring): PScheme;
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
     9
procedure sendSchemeConfig(var scheme: TScheme);
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
    10
10616
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    11
implementation
11461
ab77e2ea2f82 uFLData was renamed, update "uses"
sheepluva
parents: 11445
diff changeset
    12
uses uFLUtils, uFLIPC, uPhysFSLayer, uFLThemes;
10616
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    13
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    14
const MAX_SCHEME_NAMES = 64;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    15
type
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    16
    TSchemeArray = array [0..0] of TScheme;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    17
    PSchemeArray = ^TSchemeArray;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    18
var
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    19
    schemesList: PScheme;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    20
    schemesNumber: LongInt;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    21
    listOfSchemeNames: array[0..MAX_SCHEME_NAMES] of PChar;
10757
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    22
    tmpScheme: TScheme;
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    23
11445
330c14f4ba69 Accept scheme from net
unc0rr
parents: 10821
diff changeset
    24
const ints: array[0 .. 17] of record
10757
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    25
            name: shortstring;
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    26
            param: ^LongInt;
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    27
        end = (
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    28
              (name: 'damagefactor'; param: @tmpScheme.damagefactor)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    29
            , (name: 'turntime'; param: @tmpScheme.turntime)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    30
            , (name: 'health'; param: @tmpScheme.health)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    31
            , (name: 'suddendeath'; param: @tmpScheme.suddendeath)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    32
            , (name: 'caseprobability'; param: @tmpScheme.caseprobability)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    33
            , (name: 'minestime'; param: @tmpScheme.minestime)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    34
            , (name: 'landadds'; param: @tmpScheme.landadds)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    35
            , (name: 'minedudpct'; param: @tmpScheme.minedudpct)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    36
            , (name: 'explosives'; param: @tmpScheme.explosives)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    37
            , (name: 'minesnum'; param: @tmpScheme.minesnum)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    38
            , (name: 'healthprobability'; param: @tmpScheme.healthprobability)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    39
            , (name: 'healthcaseamount'; param: @tmpScheme.healthcaseamount)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    40
            , (name: 'waterrise'; param: @tmpScheme.waterrise)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    41
            , (name: 'healthdecrease'; param: @tmpScheme.healthdecrease)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    42
            , (name: 'ropepct'; param: @tmpScheme.ropepct)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    43
            , (name: 'getawaytime'; param: @tmpScheme.getawaytime)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    44
            , (name: 'worldedge'; param: @tmpScheme.worldedge)
11445
330c14f4ba69 Accept scheme from net
unc0rr
parents: 10821
diff changeset
    45
            , (name: 'airmines'; param: @tmpScheme.airmines)
10757
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    46
              );
11463
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
    47
const bools: array[0 .. 24] of record
10757
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    48
            name: shortstring;
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    49
            param: ^boolean;
11463
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
    50
            flag: Longword;
10757
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    51
        end = (
11463
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
    52
              (name: 'fortsmode'; param: @tmpScheme.fortsmode; flag: $00001000)
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
    53
            , (name: 'divteams'; param: @tmpScheme.divteams; flag: $00000010)
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
    54
            , (name: 'solidland'; param: @tmpScheme.solidland; flag: $00000004)
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
    55
            , (name: 'border'; param: @tmpScheme.border; flag: $00000008)
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
    56
            , (name: 'lowgrav'; param: @tmpScheme.lowgrav; flag: $00000020)
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
    57
            , (name: 'laser'; param: @tmpScheme.laser; flag: $00000040)
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
    58
            , (name: 'invulnerability'; param: @tmpScheme.invulnerability; flag: $00000080)
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
    59
            , (name: 'resethealth'; param: @tmpScheme.resethealth; flag: $00000100)
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
    60
            , (name: 'vampiric'; param: @tmpScheme.vampiric; flag: $00000200)
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
    61
            , (name: 'karma'; param: @tmpScheme.karma; flag: $00000400)
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
    62
            , (name: 'artillery'; param: @tmpScheme.artillery; flag: $00000800)
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
    63
            , (name: 'randomorder'; param: @tmpScheme.randomorder; flag: $00002000)
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
    64
            , (name: 'king'; param: @tmpScheme.king; flag: $00004000)
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
    65
            , (name: 'placehog'; param: @tmpScheme.placehog; flag: $00008000)
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
    66
            , (name: 'sharedammo'; param: @tmpScheme.sharedammo; flag: $00010000)
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
    67
            , (name: 'disablegirders'; param: @tmpScheme.disablegirders; flag: $00020000)
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
    68
            , (name: 'disablewind'; param: @tmpScheme.disablewind; flag: $00800000)
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
    69
            , (name: 'morewind'; param: @tmpScheme.morewind; flag: $01000000)
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
    70
            , (name: 'tagteam'; param: @tmpScheme.tagteam; flag: $02000000)
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
    71
            , (name: 'bottomborder'; param: @tmpScheme.bottomborder; flag: $04000000)
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
    72
            , (name: 'disablelandobjects'; param: @tmpScheme.disablelandobjects; flag: $00040000)
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
    73
            , (name: 'aisurvival'; param: @tmpScheme.aisurvival; flag: $00080000)
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
    74
            , (name: 'infattack'; param: @tmpScheme.infattack; flag: $00100000)
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
    75
            , (name: 'resetweps'; param: @tmpScheme.resetweps; flag: $00200000)
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
    76
            , (name: 'perhogammo'; param: @tmpScheme.perhogammo; flag: $00400000)
10757
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    77
              );
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    78
10616
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    79
procedure loadSchemes;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    80
var f: PFSFile;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    81
    schemes: PSchemeArray;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    82
    s: shortstring;
10757
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    83
    l, i, ii: Longword;
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    84
    isFound: boolean;
10616
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    85
begin
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    86
    f:= pfsOpenRead('/Config/schemes.ini');
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    87
    schemesNumber:= 0;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    88
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    89
    if f <> nil then
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    90
    begin
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    91
        while (not pfsEOF(f)) and (schemesNumber = 0) do
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    92
        begin
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    93
            pfsReadLn(f, s);
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    94
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    95
            if copy(s, 1, 5) = 'size=' then
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    96
                schemesNumber:= strToInt(midStr(s, 6));
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    97
        end;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    98
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    99
        //inc(schemesNumber); // add some default schemes
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   100
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   101
        schemesList:= GetMem(sizeof(schemesList^) * (schemesNumber + 1));
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   102
        schemes:= PSchemeArray(schemesList);
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   103
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   104
        while (not pfsEOF(f)) do
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   105
        begin
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   106
            pfsReadLn(f, s);
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   107
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   108
            i:= 1;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   109
            while(i <= length(s)) and (s[i] <> '\') do inc(i);
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   110
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   111
            if i < length(s) then
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   112
            begin
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   113
                l:= strToInt(copy(s, 1, i - 1));
10757
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   114
                delete(s, 1, i);
10616
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   115
10757
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   116
                if (l <= schemesNumber) and (l > 0) then
10616
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   117
                begin
10757
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   118
                    if copy(s, 1, 5) = 'name=' then
10821
efb861d1489e Fix schemes loading
unc0rr
parents: 10819
diff changeset
   119
                        schemes^[l - 1].schemeName:= midStr(s, 6)
10757
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   120
                    else if copy(s, 1, 12) = 'scriptparam=' then
10821
efb861d1489e Fix schemes loading
unc0rr
parents: 10819
diff changeset
   121
                        schemes^[l - 1].scriptparam:= midStr(s, 13) else
10757
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   122
                    begin
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   123
                        ii:= 0;
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   124
                        repeat
10821
efb861d1489e Fix schemes loading
unc0rr
parents: 10819
diff changeset
   125
                            isFound:= readInt(ints[ii].name, s, PLongInt(ints[ii].param - @tmpScheme + @schemes^[l - 1])^);
10757
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   126
                            inc(ii)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   127
                        until isFound or (ii > High(ints));
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   128
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   129
                        if not isFound then
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   130
                            begin
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   131
                                ii:= 0;
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   132
                                repeat
10821
efb861d1489e Fix schemes loading
unc0rr
parents: 10819
diff changeset
   133
                                    isFound:= readBool(bools[ii].name, s, PBoolean(bools[ii].param - @tmpScheme + @schemes^[l - 1])^);
10757
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   134
                                    inc(ii)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   135
                                until isFound or (ii > High(bools));
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   136
                            end;
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   137
                    end;
10616
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   138
                end;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   139
            end;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   140
        end;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   141
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   142
        pfsClose(f)
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   143
    end;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   144
end;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   145
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   146
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   147
function getSchemesList: PPChar; cdecl;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   148
var i, t, l: Longword;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   149
    scheme: PScheme;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   150
begin
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   151
    if schemesList = nil then
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   152
        loadSchemes;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   153
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   154
    t:= schemesNumber;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   155
    if t >= MAX_SCHEME_NAMES then 
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   156
        t:= MAX_SCHEME_NAMES;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   157
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   158
    scheme:= schemesList;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   159
    for i:= 0 to Pred(t) do
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   160
    begin
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   161
        l:= length(scheme^.schemeName);
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   162
        if l >= 255 then l:= 254;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   163
        scheme^.schemeName[l + 1]:= #0;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   164
        listOfSchemeNames[i]:= @scheme^.schemeName[1];
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   165
        inc(scheme)
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   166
    end;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   167
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   168
    listOfSchemeNames[t]:= nil;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   169
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   170
    getSchemesList:= listOfSchemeNames
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   171
end;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   172
10819
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   173
function schemeByName(s: shortstring): PScheme;
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   174
var i: Longword;
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   175
    scheme: PScheme;
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   176
begin
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   177
    scheme:= schemesList;
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   178
    i:= 0;
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   179
    while (i < schemesNumber) and (scheme^.schemeName <> s) do
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   180
    begin
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   181
        inc(scheme);
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   182
        inc(i)
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   183
    end;
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   184
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   185
    if i < schemesNumber then schemeByName:= scheme else schemeByName:= nil
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   186
end;
10616
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   187
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   188
procedure freeSchemesList;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   189
begin
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   190
    if schemesList <> nil then
10757
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   191
        FreeMem(schemesList, sizeof(schemesList^) * (schemesNumber + 1))
10616
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   192
end;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   193
10819
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   194
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   195
procedure sendSchemeConfig(var scheme: TScheme);
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   196
var i: Longword;
11463
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   197
    gf: Longword;
10819
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   198
begin
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   199
    with scheme do
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   200
    begin
11463
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   201
        if turntime <> 45 then
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   202
            ipcToEngine('e$turntime ' + inttostr(turntime * 1000));
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   203
        if minesnum <> 4 then
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   204
            ipcToEngine('e$minesnum ' + inttostr(minesnum));
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   205
        if damagefactor <> 100 then
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   206
            ipcToEngine('e$damagepct ' + inttostr(damagefactor));
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   207
        if worldedge > 0 then
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   208
            ipcToEngine('e$worldedge ' + inttostr(worldedge));
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   209
        if length(scriptparam) > 0 then
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   210
            ipcToEngine('e$scriptparam ' + scriptparam);
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   211
        if suddendeath <> 15 then
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   212
            ipcToEngine('e$sd_turns ' + inttostr(suddendeath));
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   213
        if waterrise <> 47 then
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   214
            ipcToEngine('e$waterrise ' + inttostr(waterrise));
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   215
        if ropepct <> 100 then
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   216
            ipcToEngine('e$ropepct ' + inttostr(ropepct));
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   217
        if getawaytime <> 100 then
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   218
            ipcToEngine('e$getawaytime ' + inttostr(getawaytime));
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   219
        if caseprobability <> 5 then
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   220
            ipcToEngine('e$casefreq ' + inttostr(caseprobability));
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   221
        if healthprobability <> 35 then
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   222
            ipcToEngine('e$healthprob ' + inttostr(healthprobability));
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   223
        if minestime <> 3 then
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   224
            ipcToEngine('e$minestime ' + inttostr(minestime * 1000));
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   225
        if minedudpct <> 0 then
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   226
            ipcToEngine('e$minedudpct ' + inttostr(minedudpct));
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   227
        if explosives <> 2 then
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   228
            ipcToEngine('e$explosives ' + inttostr(explosives));
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   229
        if airmines <> 0 then
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   230
            ipcToEngine('e$airmines ' + inttostr(airmines));
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   231
        if healthcaseamount <> 25 then
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   232
            ipcToEngine('e$hcaseamount ' + inttostr(healthcaseamount));
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   233
        if healthdecrease <> 5 then
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   234
            ipcToEngine('e$healthdec ' + inttostr(healthdecrease));
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   235
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   236
        gf:= 0;
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   237
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   238
        for i:= Low(bools) to High(bools) do
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   239
            if PBoolean(bools[i].param - @tmpScheme + @scheme)^ then
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   240
                gf:= gf or bools[i].flag;
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   241
8318e841648f Send full game config to the engine
unc0rr
parents: 11461
diff changeset
   242
        ipcToEngine('e$gmflags ' + inttostr(gf));
10819
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   243
    end
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   244
end;
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   245
10616
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   246
end.