author | rubidium |
Sun, 05 Aug 2007 23:06:58 +0000 | |
branch | NewGRF_ports |
changeset 6758 | 1545d187ab64 |
parent 6751 | 08176dfe64b7 |
child 6782 | 1d546cb63611 |
permissions | -rw-r--r-- |
6751
08176dfe64b7
(svn r10790) [NewGRF_ports] -Codechange: constify the fsmblockmaps where possible.
rubidium
parents:
6739
diff
changeset
|
1 |
/* $Id$ */ |
6739
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
diff
changeset
|
2 |
|
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
diff
changeset
|
3 |
/** @file FSMblockmap.h Definition of FSMblockmap class for use in state machines*/ |
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
diff
changeset
|
4 |
|
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
diff
changeset
|
5 |
#ifndef FSMBLOCKMAP_H |
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
diff
changeset
|
6 |
#define FSMBLOCKMAP_H |
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
diff
changeset
|
7 |
|
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
diff
changeset
|
8 |
#include "stdafx.h" |
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
diff
changeset
|
9 |
|
6751
08176dfe64b7
(svn r10790) [NewGRF_ports] -Codechange: constify the fsmblockmaps where possible.
rubidium
parents:
6739
diff
changeset
|
10 |
uint64 inline GetBlockAsBits(byte blocknumber) |
6739
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
diff
changeset
|
11 |
{ |
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
diff
changeset
|
12 |
if (blocknumber == 0) return 0ULL; |
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
diff
changeset
|
13 |
if (blocknumber > 63) blocknumber -= 64; |
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
diff
changeset
|
14 |
uint64 result = 1ULL << blocknumber; |
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
diff
changeset
|
15 |
return result; |
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
diff
changeset
|
16 |
} |
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
diff
changeset
|
17 |
|
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
diff
changeset
|
18 |
/** |
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
diff
changeset
|
19 |
* This class provides functions and internal storage for blockmaps used in Finite State Machine |
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
diff
changeset
|
20 |
* |
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
diff
changeset
|
21 |
*/ |
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
diff
changeset
|
22 |
struct FSMblockmap { |
6758
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
23 |
public: |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
24 |
void inline ResetAll() |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
25 |
{ |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
26 |
blocks[0] = 0x0000000000000000; |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
27 |
blocks[1] = 0x0000000000000000; |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
28 |
}; |
6739
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
diff
changeset
|
29 |
|
6758
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
30 |
void Initialise(const byte *blocklist, int num_bytes) |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
31 |
{ |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
32 |
ResetAll(); |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
33 |
for (int i = 0; i < num_bytes; i++) { |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
34 |
blocks[(blocklist[i] < 64) ? 0 : 1] |= GetBlockAsBits(blocklist[i]); |
6739
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
diff
changeset
|
35 |
} |
6758
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
36 |
} |
6739
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
diff
changeset
|
37 |
|
6758
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
38 |
uint64 inline GetLower() const |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
39 |
{ |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
40 |
return blocks[0]; |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
41 |
} |
6739
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
diff
changeset
|
42 |
|
6758
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
43 |
uint64 inline GetUpper() const |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
44 |
{ |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
45 |
return blocks[1]; |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
46 |
} |
6739
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
diff
changeset
|
47 |
|
6758
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
48 |
void inline ReserveBlocks(const FSMblockmap *blockmap) |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
49 |
{ |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
50 |
/* OR with blockmap to reserve blocks */ |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
51 |
blocks[0] |= blockmap->GetLower(); |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
52 |
blocks[1] |= blockmap->GetUpper(); |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
53 |
} |
6739
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
diff
changeset
|
54 |
|
6758
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
55 |
void inline ReleaseBlocks(const FSMblockmap *blockmap) |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
56 |
{ |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
57 |
/* AND with ones-complement to clear set bits in blockmap from block_lower and block_upper */ |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
58 |
blocks[0] &= ~blockmap->GetLower(); |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
59 |
blocks[1] &= ~blockmap->GetUpper(); |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
60 |
} |
6751
08176dfe64b7
(svn r10790) [NewGRF_ports] -Codechange: constify the fsmblockmaps where possible.
rubidium
parents:
6739
diff
changeset
|
61 |
|
6758
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
62 |
bool inline BlocksAreFree(const FSMblockmap *blockmap) const |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
63 |
{ |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
64 |
uint64 test_lower = blockmap->GetLower(); |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
65 |
uint64 test_upper = blockmap->GetUpper(); |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
66 |
|
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
67 |
if ((~blocks[0] & test_lower) != test_lower) return false; |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
68 |
if ((~blocks[1] & test_upper) != test_upper) return false; |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
69 |
|
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
70 |
return true; |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
71 |
} |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
72 |
|
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
73 |
bool inline HasBlocks(const FSMblockmap *blockmap) const |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
74 |
{ |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
75 |
uint64 test_lower = blockmap->GetLower(); |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
76 |
uint64 test_upper = blockmap->GetUpper(); |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
77 |
|
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
78 |
if ((blocks[0] & test_lower) != test_lower) return false; |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
79 |
if ((blocks[1] & test_upper) != test_upper) return false; |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
80 |
|
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
81 |
return true; |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
82 |
} |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
83 |
|
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
84 |
bool inline HasBlock(byte blocknumber) const |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
85 |
{ |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
86 |
FSMblockmap test_blockmap; |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
87 |
test_blockmap.Initialise(&blocknumber, 1); |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
88 |
return HasBlocks(&test_blockmap); |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
89 |
} |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
90 |
|
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
91 |
//bool inline HasBlock(byte blocknumber) |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
92 |
//{ |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
93 |
// uint64 test_block = GetBlockAsBits(blocknumber); |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
94 |
// if (blocknumber < 64) return ((block_lower & test_block) == test_block); |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
95 |
// return ((block_upper & test_block) == test_block); |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
96 |
//} |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
97 |
|
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
98 |
bool inline IsNotZero(void) const |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
99 |
{ |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
100 |
return ((blocks[0] != 0) || (blocks[1] != 0)); |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
101 |
} |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
102 |
|
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
103 |
void PrintBlock(bool newline = true) const; |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
104 |
|
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
105 |
/** |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
106 |
* Needed for an ugly hack: |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
107 |
* - vehicles and stations need to store fsmblocks, so they use FSMBlock as container |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
108 |
* - this internals of the container should be protected, e.g. private (or protected) by C++ |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
109 |
* - for saving/loading we need to pass pointer to objects |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
110 |
* -> so *if* the pointer to the FSMBlock is the same as the pointer to the blocks array |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
111 |
* encapsulated in the FSMBlock, we can just pass the FSMBlock as "offset". |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
112 |
* Normally we would then just add the offset of the blocks variable within the class |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
113 |
* but that is not possible because the variable is private. Furthermore we are not sure |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
114 |
* that this works on all platforms, we need to check whether the offset is actually 0. |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
115 |
* This cannot be done compile time, because the variable is private. So we need to write |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
116 |
* a function that does actually check the offset runtime and call it somewhere where it |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
117 |
* is always called but it should not be called often. |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
118 |
*/ |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
119 |
static void AssertOnWrongBlockOffset(); |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
120 |
|
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
121 |
private: |
1545d187ab64
(svn r10800) [NewGRF_ports] -Add: saving of FSMblockmaps.
rubidium
parents:
6751
diff
changeset
|
122 |
uint64 blocks[2]; |
6739
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
diff
changeset
|
123 |
}; |
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
diff
changeset
|
124 |
|
6751
08176dfe64b7
(svn r10790) [NewGRF_ports] -Codechange: constify the fsmblockmaps where possible.
rubidium
parents:
6739
diff
changeset
|
125 |
FSMblockmap* SetFSMSingleBlock(const byte *blocklist); |
6739
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
diff
changeset
|
126 |
|
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
diff
changeset
|
127 |
#endif /* FSMBLOCKMAP_H */ |