hedgewars/uFLSchemes.pas
author unc0rr
Sat, 12 Dec 2015 23:38:18 +0300
branchqmlfrontend
changeset 11452 78860824b5a5
parent 11440 330c14f4ba69
child 11456 ab77e2ea2f82
permissions -rw-r--r--
Introduce barriers between messages to different engine instances
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
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    12
uses uFLUtils, uFLIPC, uPhysFSLayer, uFLData;
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
11440
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)
11440
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
              );
11440
330c14f4ba69 Accept scheme from net
unc0rr
parents: 10821
diff changeset
    47
const bools: array[0 .. 25] 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;
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    50
        end = (
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    51
              (name: 'fortsmode'; param: @tmpScheme.fortsmode)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    52
            , (name: 'divteams'; param: @tmpScheme.divteams)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    53
            , (name: 'solidland'; param: @tmpScheme.solidland)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    54
            , (name: 'border'; param: @tmpScheme.border)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    55
            , (name: 'lowgrav'; param: @tmpScheme.lowgrav)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    56
            , (name: 'laser'; param: @tmpScheme.laser)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    57
            , (name: 'invulnerability'; param: @tmpScheme.invulnerability)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    58
            , (name: 'mines'; param: @tmpScheme.mines)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    59
            , (name: 'vampiric'; param: @tmpScheme.vampiric)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    60
            , (name: 'karma'; param: @tmpScheme.karma)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    61
            , (name: 'artillery'; param: @tmpScheme.artillery)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    62
            , (name: 'randomorder'; param: @tmpScheme.randomorder)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    63
            , (name: 'king'; param: @tmpScheme.king)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    64
            , (name: 'placehog'; param: @tmpScheme.placehog)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    65
            , (name: 'sharedammo'; param: @tmpScheme.sharedammo)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    66
            , (name: 'disablegirders'; param: @tmpScheme.disablegirders)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    67
            , (name: 'disablewind'; param: @tmpScheme.disablewind)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    68
            , (name: 'morewind'; param: @tmpScheme.morewind)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    69
            , (name: 'tagteam'; param: @tmpScheme.tagteam)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    70
            , (name: 'bottomborder'; param: @tmpScheme.bottomborder)
11440
330c14f4ba69 Accept scheme from net
unc0rr
parents: 10821
diff changeset
    71
            , (name: 'resethealth'; param: @tmpScheme.resethealth)
330c14f4ba69 Accept scheme from net
unc0rr
parents: 10821
diff changeset
    72
            , (name: 'disablelandobjects'; param: @tmpScheme.disablelandobjects)
330c14f4ba69 Accept scheme from net
unc0rr
parents: 10821
diff changeset
    73
            , (name: 'aisurvival'; param: @tmpScheme.aisurvival)
330c14f4ba69 Accept scheme from net
unc0rr
parents: 10821
diff changeset
    74
            , (name: 'infattack'; param: @tmpScheme.infattack)
330c14f4ba69 Accept scheme from net
unc0rr
parents: 10821
diff changeset
    75
            , (name: 'resetweps'; param: @tmpScheme.resetweps)
330c14f4ba69 Accept scheme from net
unc0rr
parents: 10821
diff changeset
    76
            , (name: 'perhogammo'; param: @tmpScheme.perhogammo)
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
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    80
procedure loadSchemes;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    81
var f: PFSFile;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    82
    scheme: PScheme;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    83
    schemes: PSchemeArray;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    84
    s: shortstring;
10757
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    85
    l, i, ii: Longword;
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
    86
    isFound: boolean;
10616
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    87
begin
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    88
    f:= pfsOpenRead('/Config/schemes.ini');
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    89
    schemesNumber:= 0;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    90
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    91
    if f <> nil then
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
        while (not pfsEOF(f)) and (schemesNumber = 0) do
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    94
        begin
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    95
            pfsReadLn(f, s);
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    96
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    97
            if copy(s, 1, 5) = 'size=' then
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    98
                schemesNumber:= strToInt(midStr(s, 6));
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
    99
        end;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   100
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   101
        //inc(schemesNumber); // add some default schemes
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   102
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   103
        schemesList:= GetMem(sizeof(schemesList^) * (schemesNumber + 1));
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   104
        schemes:= PSchemeArray(schemesList);
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   105
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   106
        while (not pfsEOF(f)) do
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   107
        begin
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   108
            pfsReadLn(f, s);
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   109
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   110
            i:= 1;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   111
            while(i <= length(s)) and (s[i] <> '\') do inc(i);
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   112
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   113
            if i < length(s) then
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   114
            begin
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   115
                l:= strToInt(copy(s, 1, i - 1));
10757
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   116
                delete(s, 1, i);
10616
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   117
10757
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   118
                if (l <= schemesNumber) and (l > 0) then
10616
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   119
                begin
10757
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   120
                    if copy(s, 1, 5) = 'name=' then
10821
efb861d1489e Fix schemes loading
unc0rr
parents: 10819
diff changeset
   121
                        schemes^[l - 1].schemeName:= midStr(s, 6)
10757
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   122
                    else if copy(s, 1, 12) = 'scriptparam=' then
10821
efb861d1489e Fix schemes loading
unc0rr
parents: 10819
diff changeset
   123
                        schemes^[l - 1].scriptparam:= midStr(s, 13) else
10757
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   124
                    begin
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   125
                        ii:= 0;
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   126
                        repeat
10821
efb861d1489e Fix schemes loading
unc0rr
parents: 10819
diff changeset
   127
                            isFound:= readInt(ints[ii].name, s, PLongInt(ints[ii].param - @tmpScheme + @schemes^[l - 1])^);
10757
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   128
                            inc(ii)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   129
                        until isFound or (ii > High(ints));
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   130
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   131
                        if not isFound then
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   132
                            begin
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   133
                                ii:= 0;
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   134
                                repeat
10821
efb861d1489e Fix schemes loading
unc0rr
parents: 10819
diff changeset
   135
                                    isFound:= readBool(bools[ii].name, s, PBoolean(bools[ii].param - @tmpScheme + @schemes^[l - 1])^);
10757
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   136
                                    inc(ii)
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   137
                                until isFound or (ii > High(bools));
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   138
                            end;
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   139
                    end;
10616
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
            end;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   142
        end;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   143
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   144
        pfsClose(f)
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   145
    end;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   146
end;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   147
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   148
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   149
function getSchemesList: PPChar; cdecl;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   150
var i, t, l: Longword;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   151
    scheme: PScheme;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   152
begin
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   153
    if schemesList = nil then
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   154
        loadSchemes;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   155
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   156
    t:= schemesNumber;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   157
    if t >= MAX_SCHEME_NAMES then 
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   158
        t:= MAX_SCHEME_NAMES;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   159
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   160
    scheme:= schemesList;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   161
    for i:= 0 to Pred(t) do
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   162
    begin
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   163
        l:= length(scheme^.schemeName);
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   164
        if l >= 255 then l:= 254;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   165
        scheme^.schemeName[l + 1]:= #0;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   166
        listOfSchemeNames[i]:= @scheme^.schemeName[1];
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   167
        inc(scheme)
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   168
    end;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   169
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   170
    listOfSchemeNames[t]:= nil;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   171
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   172
    getSchemesList:= listOfSchemeNames
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   173
end;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   174
10819
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   175
function schemeByName(s: shortstring): PScheme;
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   176
var i: Longword;
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   177
    scheme: PScheme;
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   178
begin
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   179
    scheme:= schemesList;
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   180
    i:= 0;
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   181
    while (i < schemesNumber) and (scheme^.schemeName <> s) do
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   182
    begin
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   183
        inc(scheme);
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   184
        inc(i)
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   185
    end;
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   186
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   187
    if i < schemesNumber then schemeByName:= scheme else schemeByName:= nil
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   188
end;
10616
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   189
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   190
procedure freeSchemesList;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   191
begin
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   192
    if schemesList <> nil then
10757
f71275973737 Scheme parsing
unc0rr
parents: 10754
diff changeset
   193
        FreeMem(schemesList, sizeof(schemesList^) * (schemesNumber + 1))
10616
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   194
end;
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   195
10819
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   196
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   197
procedure sendSchemeConfig(var scheme: TScheme);
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   198
var i: Longword;
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   199
begin
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   200
    with scheme do
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   201
    begin
10821
efb861d1489e Fix schemes loading
unc0rr
parents: 10819
diff changeset
   202
        if scheme.turntime <> 45 then
efb861d1489e Fix schemes loading
unc0rr
parents: 10819
diff changeset
   203
            ipcToEngine('e$turntime ' + inttostr(scheme.turntime * 1000));
efb861d1489e Fix schemes loading
unc0rr
parents: 10819
diff changeset
   204
        if scheme.minesnum <> 4 then
efb861d1489e Fix schemes loading
unc0rr
parents: 10819
diff changeset
   205
            ipcToEngine('e$minesnum ' + inttostr(scheme.minesnum));
10819
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   206
    end
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   207
end;
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10757
diff changeset
   208
10616
20a2d5e6930a Schemes list combobox with their names
unc0rr
parents:
diff changeset
   209
end.