
#include "dbconn.h"
#include "fortress_skelet.h"

#ifdef _DEBUG
#ifndef DEBUG_NEW
#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
#define new DEBUG_NEW
#endif
#endif

/* indexy pro fortressy - INSERT dotaz */
#define DB_INDEX_FORTRESS_INSERT_QUERY_IDFORTRESS                                 1
#define DB_INDEX_FORTRESS_INSERT_QUERY_IDREALM                                    2
#define DB_INDEX_FORTRESS_INSERT_QUERY_FORTRESSNAME                               3
#define DB_INDEX_FORTRESS_INSERT_QUERY_WEIGHT                                     4
#define DB_INDEX_FORTRESS_INSERT_QUERY_TSINTEGRITY                                5
#define DB_INDEX_FORTRESS_INSERT_QUERY_SINTEGRITY                                 6
#define DB_INDEX_FORTRESS_INSERT_QUERY_LENGTH                                     7
#define DB_INDEX_FORTRESS_INSERT_QUERY_WIDTH                                      8
#define DB_INDEX_FORTRESS_INSERT_QUERY_HEIGHT                                     9
#define DB_INDEX_FORTRESS_INSERT_QUERY_QGPLASMA                                  10
#define DB_INDEX_FORTRESS_INSERT_QUERY_ULREA                                     11
#define DB_INDEX_FORTRESS_INSERT_QUERY_HEAVYWATER                                12
#define DB_INDEX_FORTRESS_INSERT_QUERY_DEUTERIUM                                 13
#define DB_INDEX_FORTRESS_INSERT_QUERY_ZCRYSTAL                                  14
#define DB_INDEX_FORTRESS_INSERT_QUERY_ENERGY                                    15
#define DB_INDEX_FORTRESS_INSERT_QUERY_ILMENITE                                  16
#define DB_INDEX_FORTRESS_INSERT_QUERY_TITANIUM                                  17
#define DB_INDEX_FORTRESS_INSERT_QUERY_QGPLASMAGRAD                              18
#define DB_INDEX_FORTRESS_INSERT_QUERY_ULREAGRAD                                 19
#define DB_INDEX_FORTRESS_INSERT_QUERY_HEAVYWATERGRAD                            20
#define DB_INDEX_FORTRESS_INSERT_QUERY_DEUTERIUMGRAD                             21
#define DB_INDEX_FORTRESS_INSERT_QUERY_ZCRYSTALGRAD                              22
#define DB_INDEX_FORTRESS_INSERT_QUERY_ENERGYGRAD                                23
#define DB_INDEX_FORTRESS_INSERT_QUERY_ILMENITEGRAD                              24
#define DB_INDEX_FORTRESS_INSERT_QUERY_TITANIUMGRAD                              25
#define DB_INDEX_FORTRESS_INSERT_QUERY_UPDQGPLASMA                               26
#define DB_INDEX_FORTRESS_INSERT_QUERY_UPDULREA                                  27
#define DB_INDEX_FORTRESS_INSERT_QUERY_UPDCONRES                                 28
#define DB_INDEX_FORTRESS_INSERT_QUERY_UPDENERGY                                 29
#define DB_INDEX_FORTRESS_INSERT_QUERY_QGPLASMATRIGGER                           30
#define DB_INDEX_FORTRESS_INSERT_QUERY_CRTRIGGER                                 31
#define DB_INDEX_FORTRESS_INSERT_QUERY_ENERGYTRIGGER                             32
#define DB_INDEX_FORTRESS_INSERT_QUERY_TARGET                                    33
#define DB_INDEX_FORTRESS_INSERT_QUERY_LTAIMTIME                                 34
#define DB_INDEX_FORTRESS_INSERT_QUERY_FORTRESSTYPE                             138

/* ENE */
#define DB_INDEX_FORTRESS_INSERT_QUERY_ENE_ACCUMULATOR                           35
#define DB_INDEX_FORTRESS_INSERT_QUERY_ENE_ESC_ENERGY                            36
#define DB_INDEX_FORTRESS_INSERT_QUERY_ENE_ESC_TENERGY                           37

/* DEF */
#define DB_INDEX_FORTRESS_INSERT_QUERY_DEF_SHIELDGENERATOR                       38
#define DB_INDEX_FORTRESS_INSERT_QUERY_DEF_ESC1_ENERGY                           39
#define DB_INDEX_FORTRESS_INSERT_QUERY_DEF_ESC1_TENERGY                          40
#define DB_INDEX_FORTRESS_INSERT_QUERY_DEF_EDC_PRIORITY                          41
#define DB_INDEX_FORTRESS_INSERT_QUERY_DEF_EDC_RATIO                             42
#define DB_INDEX_FORTRESS_INSERT_QUERY_DEF_EDC_MPD                               43
#define DB_INDEX_FORTRESS_INSERT_QUERY_DEF_EDC_SDOEL                             44

/* WEP */
#define DB_INDEX_FORTRESS_INSERT_QUERY_WEP_ENERGYCIRCUIT                         45
#define DB_INDEX_FORTRESS_INSERT_QUERY_WEP_DRONEMISSILES                         46
#define DB_INDEX_FORTRESS_INSERT_QUERY_WEP_EDC_PRIORITY                          47
#define DB_INDEX_FORTRESS_INSERT_QUERY_WEP_EDC_RATIO                             48
#define DB_INDEX_FORTRESS_INSERT_QUERY_WEP_EDC_MPD                               49
#define DB_INDEX_FORTRESS_INSERT_QUERY_WEP_EDC_SDOEL                             50

/* TBM */
#define DB_INDEX_FORTRESS_INSERT_QUERY_TBM_GENERATOR                             51
#define DB_INDEX_FORTRESS_INSERT_QUERY_TBM_ESC_ENERGY                            52
#define DB_INDEX_FORTRESS_INSERT_QUERY_TBM_ESC_TENERGY                           53
#define DB_INDEX_FORTRESS_INSERT_QUERY_TBM_EDC_PRIORITY                          54
#define DB_INDEX_FORTRESS_INSERT_QUERY_TBM_EDC_RATIO                             55
#define DB_INDEX_FORTRESS_INSERT_QUERY_TBM_EDC_MPD                               56
#define DB_INDEX_FORTRESS_INSERT_QUERY_TBM_EDC_SDOEL                             57

/* MIN */
#define DB_INDEX_FORTRESS_INSERT_QUERY_MIN_MAGCOLLECTORS                         58
#define DB_INDEX_FORTRESS_INSERT_QUERY_MIN_FILTRATIONTANK                        59
#define DB_INDEX_FORTRESS_INSERT_QUERY_MIN_MININGMACHINE                         60
#define DB_INDEX_FORTRESS_INSERT_QUERY_MIN_DRILLINGMACHINE                       61
#define DB_INDEX_FORTRESS_INSERT_QUERY_MIN_QGQUARRYING                           62
#define DB_INDEX_FORTRESS_INSERT_QUERY_MIN_DEQUARRYING                           63
#define DB_INDEX_FORTRESS_INSERT_QUERY_MIN_ZCQUARRYING                           64
#define DB_INDEX_FORTRESS_INSERT_QUERY_MIN_ILQUARRYING                           65

/* SEN */
#define DB_INDEX_FORTRESS_INSERT_QUERY_SEN_HIRESSENSORS                          66
#define DB_INDEX_FORTRESS_INSERT_QUERY_SEN_LONGRANGESENSORS                      67
#define DB_INDEX_FORTRESS_INSERT_QUERY_SEN_PSC1_STATE                            68
#define DB_INDEX_FORTRESS_INSERT_QUERY_SEN_PSC1_CHARGING                         69
#define DB_INDEX_FORTRESS_INSERT_QUERY_SEN_EDC1_PRIORITY                         70
#define DB_INDEX_FORTRESS_INSERT_QUERY_SEN_EDC1_RATIO                            71
#define DB_INDEX_FORTRESS_INSERT_QUERY_SEN_EDC1_MPD                              72
#define DB_INDEX_FORTRESS_INSERT_QUERY_SEN_EDC1_SDOEL                            73
#define DB_INDEX_FORTRESS_INSERT_QUERY_SEN_PSC2_STATE                            74
#define DB_INDEX_FORTRESS_INSERT_QUERY_SEN_PSC2_CHARGING                         75
#define DB_INDEX_FORTRESS_INSERT_QUERY_SEN_EDC2_PRIORITY                         76
#define DB_INDEX_FORTRESS_INSERT_QUERY_SEN_EDC2_RATIO                            77
#define DB_INDEX_FORTRESS_INSERT_QUERY_SEN_EDC2_MPD                              78
#define DB_INDEX_FORTRESS_INSERT_QUERY_SEN_EDC2_SDOEL                            79

/* CLO */ 
#define DB_INDEX_FORTRESS_INSERT_QUERY_CLO_CLOAKINGDEVICE                        80
#define DB_INDEX_FORTRESS_INSERT_QUERY_CLO_PSC_STATE                             81
#define DB_INDEX_FORTRESS_INSERT_QUERY_CLO_PSC_CHARGING                          82
#define DB_INDEX_FORTRESS_INSERT_QUERY_CLO_EDC_PRIORITY                          83
#define DB_INDEX_FORTRESS_INSERT_QUERY_CLO_EDC_RATIO                             84
#define DB_INDEX_FORTRESS_INSERT_QUERY_CLO_EDC_MPD                               85
#define DB_INDEX_FORTRESS_INSERT_QUERY_CLO_EDC_SDOEL                             86

/* CRE */
#define DB_INDEX_FORTRESS_INSERT_QUERY_CRE_CREW_CAPITAN                          87
#define DB_INDEX_FORTRESS_INSERT_QUERY_CRE_CREW_DOCTOR                           88
#define DB_INDEX_FORTRESS_INSERT_QUERY_CRE_CREW_OFFICER                          89
#define DB_INDEX_FORTRESS_INSERT_QUERY_CRE_CREW_ENGINEER                         90
#define DB_INDEX_FORTRESS_INSERT_QUERY_CRE_CREW_PILOT                            91
#define DB_INDEX_FORTRESS_INSERT_QUERY_CRE_CREW_SCIENTIST                        92
#define DB_INDEX_FORTRESS_INSERT_QUERY_CRE_CREW_PASSENGER                        93

#define DB_INDEX_FORTRESS_INSERT_QUERY_CRE_WOUNDED_CAPITAN                       94
#define DB_INDEX_FORTRESS_INSERT_QUERY_CRE_WOUNDED_DOCTOR                        95
#define DB_INDEX_FORTRESS_INSERT_QUERY_CRE_WOUNDED_OFFICER                       96
#define DB_INDEX_FORTRESS_INSERT_QUERY_CRE_WOUNDED_ENGINEER                      97
#define DB_INDEX_FORTRESS_INSERT_QUERY_CRE_WOUNDED_PILOT                         98
#define DB_INDEX_FORTRESS_INSERT_QUERY_CRE_WOUNDED_SCIENTIST                     99
#define DB_INDEX_FORTRESS_INSERT_QUERY_CRE_WOUNDED_PASSENGER                    100

/* ACC */
#define DB_INDEX_FORTRESS_INSERT_QUERY_ACC_LUXURYAPARTMENTS                     101
#define DB_INDEX_FORTRESS_INSERT_QUERY_ACC_COMFORTABLEROOMS                     102
#define DB_INDEX_FORTRESS_INSERT_QUERY_ACC_COMMONCABINS                         103
#define DB_INDEX_FORTRESS_INSERT_QUERY_ACC_WAREHOUSES                           104

/* MEC */
#define DB_INDEX_FORTRESS_INSERT_QUERY_MEC_ANDROIDS                             105
#define DB_INDEX_FORTRESS_INSERT_QUERY_MEC_PSC_STATE                            106
#define DB_INDEX_FORTRESS_INSERT_QUERY_MEC_PSC_CHARGING                         107
#define DB_INDEX_FORTRESS_INSERT_QUERY_MEC_EDC_PRIORITY                         108
#define DB_INDEX_FORTRESS_INSERT_QUERY_MEC_EDC_RATIO                            109
#define DB_INDEX_FORTRESS_INSERT_QUERY_MEC_EDC_MPD                              110
#define DB_INDEX_FORTRESS_INSERT_QUERY_MEC_EDC_SDOEL                            111
#define DB_INDEX_FORTRESS_INSERT_QUERY_MEC_MAX_WORK_ANDR                        164
#define DB_INDEX_FORTRESS_INSERT_QUERY_MEC_MAX_REPA_ANDR                        165
#define DB_INDEX_FORTRESS_INSERT_QUERY_MEC_ACT_REPA_ANDR                        166
#define DB_INDEX_FORTRESS_INSERT_QUERY_MEC_ACT_CONS_ANDR 	                    167

/* WAR */
#define DB_INDEX_FORTRESS_INSERT_QUERY_WAR_MAGNETICALGRID                       112
#define DB_INDEX_FORTRESS_INSERT_QUERY_WAR_CONTAINER                            113
#define DB_INDEX_FORTRESS_INSERT_QUERY_WAR_ENERGETICCELL                        114

/* OTH */
#define DB_INDEX_FORTRESS_INSERT_QUERY_OTH_PLASMAFILTER                         115
#define DB_INDEX_FORTRESS_INSERT_QUERY_OTH_LABS                                 116
#define DB_INDEX_FORTRESS_INSERT_QUERY_OTH_LIFESUPPORT                          117
#define DB_INDEX_FORTRESS_INSERT_QUERY_OTH_TRANSMITTER                          118
#define DB_INDEX_FORTRESS_INSERT_QUERY_OTH_EDC_PRIORITY                         119
#define DB_INDEX_FORTRESS_INSERT_QUERY_OTH_EDC_RATIO                            120
#define DB_INDEX_FORTRESS_INSERT_QUERY_OTH_EDC_MPD                              121
#define DB_INDEX_FORTRESS_INSERT_QUERY_OTH_EDC_SDOEL                            122

/* MAI */
#define DB_INDEX_FORTRESS_INSERT_QUERY_MAI_MAINFRAME                            123
#define DB_INDEX_FORTRESS_INSERT_QUERY_MAI_EDC_PRIORITY                         124
#define DB_INDEX_FORTRESS_INSERT_QUERY_MAI_EDC_RATIO                            125
#define DB_INDEX_FORTRESS_INSERT_QUERY_MAI_EDC_MPD                              126
#define DB_INDEX_FORTRESS_INSERT_QUERY_MAI_EDC_SDOEL                            127

/* SUB */
#define DB_INDEX_FORTRESS_INSERT_QUERY_SUB_COMPUTER                             128
#define DB_INDEX_FORTRESS_INSERT_QUERY_SUB_QGCORE                               129
#define DB_INDEX_FORTRESS_INSERT_QUERY_SUB_BEACON                               130
#define DB_INDEX_FORTRESS_INSERT_QUERY_SUB_DAMPERS                              131
#define DB_INDEX_FORTRESS_INSERT_QUERY_SUB_ACTUALSPEEDTOC                       162

/* IMP */
#define DB_INDEX_FORTRESS_INSERT_QUERY_IMP_JETENGINE                            132
#define DB_INDEX_FORTRESS_INSERT_QUERY_IMP_MECHDAMPERS                          133

/* FAC */ 
#define DB_INDEX_FORTRESS_INSERT_QUERY_FAC_MAGNETICALFILTER                     134
#define DB_INDEX_FORTRESS_INSERT_QUERY_FAC_DEUTERIUMDECOMP                      135
#define DB_INDEX_FORTRESS_INSERT_QUERY_FAC_ZIRCONIUMREACTOR                     136
#define DB_INDEX_FORTRESS_INSERT_QUERY_FAC_ILMENITEFURNACE                      137

#define DB_INDEX_FORTRESS_INSERT_QUERY_IMP_ACTUALFORCE                          139
#define DB_INDEX_FORTRESS_INSERT_QUERY_POSITIONX                                140
#define DB_INDEX_FORTRESS_INSERT_QUERY_POSITIONY                                141
#define DB_INDEX_FORTRESS_INSERT_QUERY_COURSEX                                  142
#define DB_INDEX_FORTRESS_INSERT_QUERY_COURSEY                                  143
#define DB_INDEX_FORTRESS_INSERT_QUERY_SPEEDNORM                                144
#define DB_INDEX_FORTRESS_INSERT_QUERY_ACCELERATION                             145
#define DB_INDEX_FORTRESS_INSERT_QUERY_SPOBJACTUALLYIN                          146
#define DB_INDEX_FORTRESS_INSERT_QUERY_NEARESTSTAR                              147
#define DB_INDEX_FORTRESS_INSERT_QUERY_WESPOBJ                                  148
#define DB_INDEX_FORTRESS_INSERT_QUERY_MOV_STATE                                149
#define DB_INDEX_FORTRESS_INSERT_QUERY_MOV_WARP_TARGET_X                        150
#define DB_INDEX_FORTRESS_INSERT_QUERY_MOV_WARP_TARGET_Y                        151
#define DB_INDEX_FORTRESS_INSERT_QUERY_MOV_WARP_START                           152
#define DB_INDEX_FORTRESS_INSERT_QUERY_ENGINE_LIMIT                             153
#define DB_INDEX_FORTRESS_INSERT_QUERY_TARGETSPACEOBJECT                        154
#define DB_INDEX_FORTRESS_INSERT_QUERY_TARGETSHIP                               155
#define DB_INDEX_FORTRESS_INSERT_QUERY_TARGETPOSITIONX                          156
#define DB_INDEX_FORTRESS_INSERT_QUERY_TARGETPOSITIONY                          157
#define DB_INDEX_FORTRESS_INSERT_QUERY_LASTACTUALIZATION                        158
#define DB_INDEX_FORTRESS_INSERT_QUERY_SHIPMOVEACTION                           159
#define DB_INDEX_FORTRESS_INSERT_QUERY_SHIPMOVETARGET                           160
#define DB_INDEX_FORTRESS_INSERT_QUERY_FORTRESCLASSCLASS                        161
#define DB_INDEX_FORTRESS_INSERT_QUERY_GRAVSPEEDNORM                            163
#define DB_INDEX_FORTRESS_INSERT_QUERY_STRUCTINTGRAD                            168
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_VOI_ANDR_PRIORITY                     169
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_VOI_ANDR_RATIO                        170
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_VOI_ANDR_ASSIGNED_DROIDS              171
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_ENE_ANDR_PRIORITY                     172
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_ENE_ANDR_RATIO                        173
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_ENE_ANDR_ASSIGNED_DROIDS              174
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_DEF_ANDR_PRIORITY                     175
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_DEF_ANDR_RATIO                        176
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_DEF_ANDR_ASSIGNED_DROIDS              177
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_WEP_ANDR_PRIORITY                     178
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_WEP_ANDR_RATIO                        179
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_WEP_ANDR_ASSIGNED_DROIDS              180
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_TBM_ANDR_PRIORITY                     181
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_TBM_ANDR_RATIO                        182
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_TBM_ANDR_ASSIGNED_DROIDS              183
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_MIN_ANDR_PRIORITY                     184
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_MIN_ANDR_RATIO                        185
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_MIN_ANDR_ASSIGNED_DROIDS              186
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_PRO_ANDR_PRIORITY                     187
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_PRO_ANDR_RATIO                        188
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_PRO_ANDR_ASSIGNED_DROIDS              189
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_SEN_ANDR_PRIORITY                     190
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_SEN_ANDR_RATIO                        191
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_SEN_ANDR_ASSIGNED_DROIDS              192
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_CLO_ANDR_PRIORITY                     193
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_CLO_ANDR_RATIO                        194
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_CLO_ANDR_ASSIGNED_DROIDS              195
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_CRE_ANDR_PRIORITY                     196
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_CRE_ANDR_RATIO                        197
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_CRE_ANDR_ASSIGNED_DROIDS              198
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_ACC_ANDR_PRIORITY                     199
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_ACC_ANDR_RATIO                        200
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_ACC_ANDR_ASSIGNED_DROIDS              201
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_MEC_ANDR_PRIORITY                     202
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_MEC_ANDR_RATIO                        203
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_MEC_ANDR_ASSIGNED_DROIDS              204
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_WAR_ANDR_PRIORITY                     205
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_WAR_ANDR_RATIO                        206
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_WAR_ANDR_ASSIGNED_DROIDS              207
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_OTH_ANDR_PRIORITY                     208
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_OTH_ANDR_RATIO                        209
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_OTH_ANDR_ASSIGNED_DROIDS              210
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_MAI_ANDR_PRIORITY                     211
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_MAI_ANDR_RATIO                        212
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_MAI_ANDR_ASSIGNED_DROIDS              213
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_SUB_ANDR_PRIORITY                     214
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_SUB_ANDR_RATIO                        215
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_SUB_ANDR_ASSIGNED_DROIDS              216
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_IMP_ANDR_PRIORITY                     217
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_IMP_ANDR_RATIO                        218
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_IMP_ANDR_ASSIGNED_DROIDS              219
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_HAN_ANDR_PRIORITY                     220
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_HAN_ANDR_RATIO                        221
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_HAN_ANDR_ASSIGNED_DROIDS              222
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_FAC_ANDR_PRIORITY                     223
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_FAC_ANDR_RATIO                        224
#define DB_INDEX_FORTRESS_INSERT_QUERY_FS_FAC_ANDR_ASSIGNED_DROIDS              225
#define DB_INDEX_FORTRESS_INSERT_QUERY_CONTROLLABLE                             226
#define DB_INDEX_FORTRESS_INSERT_QUERY_BUILDING_PTS                             227

// ################################
// ################################
// ################################
// ################################

/* indexy pro fortressy - SELECT dotaz */
#define DB_INDEX_FORTRESS_SELECT_QUERY_IDFORTRESS                                 1
#define DB_INDEX_FORTRESS_SELECT_QUERY_IDREALM                                    2
#define DB_INDEX_FORTRESS_SELECT_QUERY_FORTRESSNAME                               3
#define DB_INDEX_FORTRESS_SELECT_QUERY_WEIGHT                                     4
#define DB_INDEX_FORTRESS_SELECT_QUERY_TSINTEGRITY                                5
#define DB_INDEX_FORTRESS_SELECT_QUERY_SINTEGRITY                                 6
#define DB_INDEX_FORTRESS_SELECT_QUERY_LENGTH                                     7
#define DB_INDEX_FORTRESS_SELECT_QUERY_WIDTH                                      8
#define DB_INDEX_FORTRESS_SELECT_QUERY_HEIGHT                                     9
#define DB_INDEX_FORTRESS_SELECT_QUERY_QGPLASMA                                  10
#define DB_INDEX_FORTRESS_SELECT_QUERY_ULREA                                     11
#define DB_INDEX_FORTRESS_SELECT_QUERY_HEAVYWATER                                12
#define DB_INDEX_FORTRESS_SELECT_QUERY_DEUTERIUM                                 13
#define DB_INDEX_FORTRESS_SELECT_QUERY_ZCRYSTAL                                  14
#define DB_INDEX_FORTRESS_SELECT_QUERY_ENERGY                                    15
#define DB_INDEX_FORTRESS_SELECT_QUERY_ILMENITE                                  16
#define DB_INDEX_FORTRESS_SELECT_QUERY_TITANIUM                                  17
#define DB_INDEX_FORTRESS_SELECT_QUERY_QGPLASMAGRAD                              18
#define DB_INDEX_FORTRESS_SELECT_QUERY_ULREAGRAD                                 19
#define DB_INDEX_FORTRESS_SELECT_QUERY_HEAVYWATERGRAD                            20
#define DB_INDEX_FORTRESS_SELECT_QUERY_DEUTERIUMGRAD                             21
#define DB_INDEX_FORTRESS_SELECT_QUERY_ZCRYSTALGRAD                              22
#define DB_INDEX_FORTRESS_SELECT_QUERY_ENERGYGRAD                                23
#define DB_INDEX_FORTRESS_SELECT_QUERY_ILMENITEGRAD                              24
#define DB_INDEX_FORTRESS_SELECT_QUERY_TITANIUMGRAD                              25
#define DB_INDEX_FORTRESS_SELECT_QUERY_UPDQGPLASMA                               26
#define DB_INDEX_FORTRESS_SELECT_QUERY_UPDULREA                                  27
#define DB_INDEX_FORTRESS_SELECT_QUERY_UPDCONRES                                 28
#define DB_INDEX_FORTRESS_SELECT_QUERY_UPDENERGY                                 29
#define DB_INDEX_FORTRESS_SELECT_QUERY_QGPLASMATRIGGER                           30
#define DB_INDEX_FORTRESS_SELECT_QUERY_CRTRIGGER                                 31
#define DB_INDEX_FORTRESS_SELECT_QUERY_ENERGYTRIGGER                             32
#define DB_INDEX_FORTRESS_SELECT_QUERY_TARGET                                    33
#define DB_INDEX_FORTRESS_SELECT_QUERY_LTAIMTIME                                 34
#define DB_INDEX_FORTRESS_SELECT_QUERY_FORTRESSTYPE                             138

/* ENE */
#define DB_INDEX_FORTRESS_SELECT_QUERY_ENE_ACCUMULATOR                           35
#define DB_INDEX_FORTRESS_SELECT_QUERY_ENE_ESC_ENERGY                            36
#define DB_INDEX_FORTRESS_SELECT_QUERY_ENE_ESC_TENERGY                           37

/* DEF */
#define DB_INDEX_FORTRESS_SELECT_QUERY_DEF_SHIELDGENERATOR                       38
#define DB_INDEX_FORTRESS_SELECT_QUERY_DEF_ESC1_ENERGY                           39
#define DB_INDEX_FORTRESS_SELECT_QUERY_DEF_ESC1_TENERGY                          40
#define DB_INDEX_FORTRESS_SELECT_QUERY_DEF_EDC_PRIORITY                          41
#define DB_INDEX_FORTRESS_SELECT_QUERY_DEF_EDC_RATIO                             42
#define DB_INDEX_FORTRESS_SELECT_QUERY_DEF_EDC_MPD                               43
#define DB_INDEX_FORTRESS_SELECT_QUERY_DEF_EDC_SDOEL                             44

/* WEP */
#define DB_INDEX_FORTRESS_SELECT_QUERY_WEP_ENERGYCIRCUIT                         45
#define DB_INDEX_FORTRESS_SELECT_QUERY_WEP_DRONEMISSILES                         46
#define DB_INDEX_FORTRESS_SELECT_QUERY_WEP_EDC_PRIORITY                          47
#define DB_INDEX_FORTRESS_SELECT_QUERY_WEP_EDC_RATIO                             48
#define DB_INDEX_FORTRESS_SELECT_QUERY_WEP_EDC_MPD                               49
#define DB_INDEX_FORTRESS_SELECT_QUERY_WEP_EDC_SDOEL                             50

/* TBM */
#define DB_INDEX_FORTRESS_SELECT_QUERY_TBM_GENERATOR                             51
#define DB_INDEX_FORTRESS_SELECT_QUERY_TBM_ESC_ENERGY                            52
#define DB_INDEX_FORTRESS_SELECT_QUERY_TBM_ESC_TENERGY                           53
#define DB_INDEX_FORTRESS_SELECT_QUERY_TBM_EDC_PRIORITY                          54
#define DB_INDEX_FORTRESS_SELECT_QUERY_TBM_EDC_RATIO                             55
#define DB_INDEX_FORTRESS_SELECT_QUERY_TBM_EDC_MPD                               56
#define DB_INDEX_FORTRESS_SELECT_QUERY_TBM_EDC_SDOEL                             57

/* MIN */
#define DB_INDEX_FORTRESS_SELECT_QUERY_MIN_MAGCOLLECTORS                         58
#define DB_INDEX_FORTRESS_SELECT_QUERY_MIN_FILTRATIONTANK                        59
#define DB_INDEX_FORTRESS_SELECT_QUERY_MIN_MININGMACHINE                         60
#define DB_INDEX_FORTRESS_SELECT_QUERY_MIN_DRILLINGMACHINE                       61
#define DB_INDEX_FORTRESS_SELECT_QUERY_MIN_QGQUARRYING                           62
#define DB_INDEX_FORTRESS_SELECT_QUERY_MIN_DEQUARRYING                           63
#define DB_INDEX_FORTRESS_SELECT_QUERY_MIN_ZCQUARRYING                           64
#define DB_INDEX_FORTRESS_SELECT_QUERY_MIN_ILQUARRYING                           65

/* SEN */
#define DB_INDEX_FORTRESS_SELECT_QUERY_SEN_HIRESSENSORS                          66
#define DB_INDEX_FORTRESS_SELECT_QUERY_SEN_LONGRANGESENSORS                      67
#define DB_INDEX_FORTRESS_SELECT_QUERY_SEN_PSC1_STATE                            68
#define DB_INDEX_FORTRESS_SELECT_QUERY_SEN_PSC1_CHARGING                         69
#define DB_INDEX_FORTRESS_SELECT_QUERY_SEN_EDC1_PRIORITY                         70
#define DB_INDEX_FORTRESS_SELECT_QUERY_SEN_EDC1_RATIO                            71
#define DB_INDEX_FORTRESS_SELECT_QUERY_SEN_EDC1_MPD                              72
#define DB_INDEX_FORTRESS_SELECT_QUERY_SEN_EDC1_SDOEL                            73
#define DB_INDEX_FORTRESS_SELECT_QUERY_SEN_PSC2_STATE                            74
#define DB_INDEX_FORTRESS_SELECT_QUERY_SEN_PSC2_CHARGING                         75
#define DB_INDEX_FORTRESS_SELECT_QUERY_SEN_EDC2_PRIORITY                         76
#define DB_INDEX_FORTRESS_SELECT_QUERY_SEN_EDC2_RATIO                            77
#define DB_INDEX_FORTRESS_SELECT_QUERY_SEN_EDC2_MPD                              78
#define DB_INDEX_FORTRESS_SELECT_QUERY_SEN_EDC2_SDOEL                            79

/* CLO */ 
#define DB_INDEX_FORTRESS_SELECT_QUERY_CLO_CLOAKINGDEVICE                        80
#define DB_INDEX_FORTRESS_SELECT_QUERY_CLO_PSC_STATE                             81
#define DB_INDEX_FORTRESS_SELECT_QUERY_CLO_PSC_CHARGING                          82
#define DB_INDEX_FORTRESS_SELECT_QUERY_CLO_EDC_PRIORITY                          83
#define DB_INDEX_FORTRESS_SELECT_QUERY_CLO_EDC_RATIO                             84
#define DB_INDEX_FORTRESS_SELECT_QUERY_CLO_EDC_MPD                               85
#define DB_INDEX_FORTRESS_SELECT_QUERY_CLO_EDC_SDOEL                             86

/* CRE */
#define DB_INDEX_FORTRESS_SELECT_QUERY_CRE_CREW_CAPITAN                          87
#define DB_INDEX_FORTRESS_SELECT_QUERY_CRE_CREW_DOCTOR                           88
#define DB_INDEX_FORTRESS_SELECT_QUERY_CRE_CREW_OFFICER                          89
#define DB_INDEX_FORTRESS_SELECT_QUERY_CRE_CREW_ENGINEER                         90
#define DB_INDEX_FORTRESS_SELECT_QUERY_CRE_CREW_PILOT                            91
#define DB_INDEX_FORTRESS_SELECT_QUERY_CRE_CREW_SCIENTIST                        92
#define DB_INDEX_FORTRESS_SELECT_QUERY_CRE_CREW_PASSENGER                        93

#define DB_INDEX_FORTRESS_SELECT_QUERY_CRE_WOUNDED_CAPITAN                       94
#define DB_INDEX_FORTRESS_SELECT_QUERY_CRE_WOUNDED_DOCTOR                        95
#define DB_INDEX_FORTRESS_SELECT_QUERY_CRE_WOUNDED_OFFICER                       96
#define DB_INDEX_FORTRESS_SELECT_QUERY_CRE_WOUNDED_ENGINEER                      97
#define DB_INDEX_FORTRESS_SELECT_QUERY_CRE_WOUNDED_PILOT                         98
#define DB_INDEX_FORTRESS_SELECT_QUERY_CRE_WOUNDED_SCIENTIST                     99
#define DB_INDEX_FORTRESS_SELECT_QUERY_CRE_WOUNDED_PASSENGER                    100

/* ACC */
#define DB_INDEX_FORTRESS_SELECT_QUERY_ACC_LUXURYAPARTMENTS                     101
#define DB_INDEX_FORTRESS_SELECT_QUERY_ACC_COMFORTABLEROOMS                     102
#define DB_INDEX_FORTRESS_SELECT_QUERY_ACC_COMMONCABINS                         103
#define DB_INDEX_FORTRESS_SELECT_QUERY_ACC_WAREHOUSES                           104

/* MEC */
#define DB_INDEX_FORTRESS_SELECT_QUERY_MEC_ANDROIDS                             105
#define DB_INDEX_FORTRESS_SELECT_QUERY_MEC_PSC_STATE                            106
#define DB_INDEX_FORTRESS_SELECT_QUERY_MEC_PSC_CHARGING                         107
#define DB_INDEX_FORTRESS_SELECT_QUERY_MEC_EDC_PRIORITY                         108
#define DB_INDEX_FORTRESS_SELECT_QUERY_MEC_EDC_RATIO                            109
#define DB_INDEX_FORTRESS_SELECT_QUERY_MEC_EDC_MPD                              110
#define DB_INDEX_FORTRESS_SELECT_QUERY_MEC_EDC_SDOEL                            111
#define DB_INDEX_FORTRESS_SELECT_QUERY_MEC_MAX_WORK_ANDR                        164
#define DB_INDEX_FORTRESS_SELECT_QUERY_MEC_MAX_REPA_ANDR                        165
#define DB_INDEX_FORTRESS_SELECT_QUERY_MEC_ACT_REPA_ANDR                        166
#define DB_INDEX_FORTRESS_SELECT_QUERY_MEC_ACT_CONS_ANDR 	                    167

/* WAR */
#define DB_INDEX_FORTRESS_SELECT_QUERY_WAR_MAGNETICALGRID                       112
#define DB_INDEX_FORTRESS_SELECT_QUERY_WAR_CONTAINER                            113
#define DB_INDEX_FORTRESS_SELECT_QUERY_WAR_ENERGETICCELL                        114

/* OTH */
#define DB_INDEX_FORTRESS_SELECT_QUERY_OTH_PLASMAFILTER                         115
#define DB_INDEX_FORTRESS_SELECT_QUERY_OTH_LABS                                 116
#define DB_INDEX_FORTRESS_SELECT_QUERY_OTH_LIFESUPPORT                          117
#define DB_INDEX_FORTRESS_SELECT_QUERY_OTH_TRANSMITTER                          118
#define DB_INDEX_FORTRESS_SELECT_QUERY_OTH_EDC_PRIORITY                         119
#define DB_INDEX_FORTRESS_SELECT_QUERY_OTH_EDC_RATIO                            120
#define DB_INDEX_FORTRESS_SELECT_QUERY_OTH_EDC_MPD                              121
#define DB_INDEX_FORTRESS_SELECT_QUERY_OTH_EDC_SDOEL                            122

/* MAI */
#define DB_INDEX_FORTRESS_SELECT_QUERY_MAI_MAINFRAME                            123
#define DB_INDEX_FORTRESS_SELECT_QUERY_MAI_EDC_PRIORITY                         124
#define DB_INDEX_FORTRESS_SELECT_QUERY_MAI_EDC_RATIO                            125
#define DB_INDEX_FORTRESS_SELECT_QUERY_MAI_EDC_MPD                              126
#define DB_INDEX_FORTRESS_SELECT_QUERY_MAI_EDC_SDOEL                            127

/* SUB */
#define DB_INDEX_FORTRESS_SELECT_QUERY_SUB_COMPUTER                             128
#define DB_INDEX_FORTRESS_SELECT_QUERY_SUB_QGCORE                               129
#define DB_INDEX_FORTRESS_SELECT_QUERY_SUB_BEACON                               130
#define DB_INDEX_FORTRESS_SELECT_QUERY_SUB_DAMPERS                              131
#define DB_INDEX_FORTRESS_SELECT_QUERY_SUB_ACTUALSPEEDTOC                       162

/* IMP */
#define DB_INDEX_FORTRESS_SELECT_QUERY_IMP_JETENGINE                            132
#define DB_INDEX_FORTRESS_SELECT_QUERY_IMP_MECHDAMPERS                          133

/* FAC */ 
#define DB_INDEX_FORTRESS_SELECT_QUERY_FAC_MAGNETICALFILTER                     134
#define DB_INDEX_FORTRESS_SELECT_QUERY_FAC_DEUTERIUMDECOMP                      135
#define DB_INDEX_FORTRESS_SELECT_QUERY_FAC_ZIRCONIUMREACTOR                     136
#define DB_INDEX_FORTRESS_SELECT_QUERY_FAC_ILMENITEFURNACE                      137

#define DB_INDEX_FORTRESS_SELECT_QUERY_IMP_ACTUALFORCE                          139
#define DB_INDEX_FORTRESS_SELECT_QUERY_POSITIONX                                140
#define DB_INDEX_FORTRESS_SELECT_QUERY_POSITIONY                                141
#define DB_INDEX_FORTRESS_SELECT_QUERY_COURSEX                                  142
#define DB_INDEX_FORTRESS_SELECT_QUERY_COURSEY                                  143
#define DB_INDEX_FORTRESS_SELECT_QUERY_SPEEDNORM                                144
#define DB_INDEX_FORTRESS_SELECT_QUERY_ACCELERATION                             145
#define DB_INDEX_FORTRESS_SELECT_QUERY_SPOBJACTUALLYIN                          146
#define DB_INDEX_FORTRESS_SELECT_QUERY_NEARESTSTAR                              147
#define DB_INDEX_FORTRESS_SELECT_QUERY_WESPOBJ                                  148
#define DB_INDEX_FORTRESS_SELECT_QUERY_MOV_STATE                                149
#define DB_INDEX_FORTRESS_SELECT_QUERY_MOV_WARP_TARGET_X                        150
#define DB_INDEX_FORTRESS_SELECT_QUERY_MOV_WARP_TARGET_Y                        151
#define DB_INDEX_FORTRESS_SELECT_QUERY_MOV_WARP_START                           152
#define DB_INDEX_FORTRESS_SELECT_QUERY_ENGINE_LIMIT                             153
#define DB_INDEX_FORTRESS_SELECT_QUERY_TARGETSPACEOBJECT                        154
#define DB_INDEX_FORTRESS_SELECT_QUERY_TARGETSHIP                               155
#define DB_INDEX_FORTRESS_SELECT_QUERY_TARGETPOSITIONX                          156
#define DB_INDEX_FORTRESS_SELECT_QUERY_TARGETPOSITIONY                          157
#define DB_INDEX_FORTRESS_SELECT_QUERY_LASTACTUALIZATION                        158
#define DB_INDEX_FORTRESS_SELECT_QUERY_SHIPMOVEACTION                           159
#define DB_INDEX_FORTRESS_SELECT_QUERY_SHIPMOVETARGET                           160
#define DB_INDEX_FORTRESS_SELECT_QUERY_FORTRESCLASSCLASS                        161
#define DB_INDEX_FORTRESS_SELECT_QUERY_GRAVSPEEDNORM                            163
#define DB_INDEX_FORTRESS_SELECT_QUERY_STRUCTINTGRAD                            168
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_VOI_ANDR_PRIORITY                     169
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_VOI_ANDR_RATIO                        170
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_VOI_ANDR_ASSIGNED_DROIDS              171
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_ENE_ANDR_PRIORITY                     172
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_ENE_ANDR_RATIO                        173
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_ENE_ANDR_ASSIGNED_DROIDS              174
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_DEF_ANDR_PRIORITY                     175
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_DEF_ANDR_RATIO                        176
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_DEF_ANDR_ASSIGNED_DROIDS              177
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_WEP_ANDR_PRIORITY                     178
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_WEP_ANDR_RATIO                        179
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_WEP_ANDR_ASSIGNED_DROIDS              180
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_TBM_ANDR_PRIORITY                     181
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_TBM_ANDR_RATIO                        182
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_TBM_ANDR_ASSIGNED_DROIDS              183
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_MIN_ANDR_PRIORITY                     184
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_MIN_ANDR_RATIO                        185
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_MIN_ANDR_ASSIGNED_DROIDS              186
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_PRO_ANDR_PRIORITY                     187
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_PRO_ANDR_RATIO                        188
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_PRO_ANDR_ASSIGNED_DROIDS              189
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_SEN_ANDR_PRIORITY                     190
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_SEN_ANDR_RATIO                        191
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_SEN_ANDR_ASSIGNED_DROIDS              192
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_CLO_ANDR_PRIORITY                     193
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_CLO_ANDR_RATIO                        194
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_CLO_ANDR_ASSIGNED_DROIDS              195
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_CRE_ANDR_PRIORITY                     196
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_CRE_ANDR_RATIO                        197
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_CRE_ANDR_ASSIGNED_DROIDS              198
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_ACC_ANDR_PRIORITY                     199
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_ACC_ANDR_RATIO                        200
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_ACC_ANDR_ASSIGNED_DROIDS              201
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_MEC_ANDR_PRIORITY                     202
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_MEC_ANDR_RATIO                        203
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_MEC_ANDR_ASSIGNED_DROIDS              204
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_WAR_ANDR_PRIORITY                     205
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_WAR_ANDR_RATIO                        206
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_WAR_ANDR_ASSIGNED_DROIDS              207
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_OTH_ANDR_PRIORITY                     208
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_OTH_ANDR_RATIO                        209
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_OTH_ANDR_ASSIGNED_DROIDS              210
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_MAI_ANDR_PRIORITY                     211
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_MAI_ANDR_RATIO                        212
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_MAI_ANDR_ASSIGNED_DROIDS              213
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_SUB_ANDR_PRIORITY                     214
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_SUB_ANDR_RATIO                        215
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_SUB_ANDR_ASSIGNED_DROIDS              216
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_IMP_ANDR_PRIORITY                     217
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_IMP_ANDR_RATIO                        218
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_IMP_ANDR_ASSIGNED_DROIDS              219
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_HAN_ANDR_PRIORITY                     220
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_HAN_ANDR_RATIO                        221
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_HAN_ANDR_ASSIGNED_DROIDS              222
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_FAC_ANDR_PRIORITY                     223
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_FAC_ANDR_RATIO                        224
#define DB_INDEX_FORTRESS_SELECT_QUERY_FS_FAC_ANDR_ASSIGNED_DROIDS              225
#define DB_INDEX_FORTRESS_SELECT_QUERY_CONTROLLABLE                             226
#define DB_INDEX_FORTRESS_SELECT_QUERY_BUILDING_PTS                             227

#define DB_INDEX_FORTRESS_SELECT_QUERY_IDFORTRESS_WHERE                           1

// ################################
// ################################
// ################################
// ################################

/* indexy pro fortressy - DELETE dotaz */
#define DB_INDEX_FORTRESS_DELETE_QUERY_IDFORTRESS                                 1

// ################################
// ################################
// ################################
// ################################

/* indexy pro fortressy - UPDATE dotaz */
#define DB_INDEX_FORTRESS_UPDATE_QUERY_IDFORTRESS                               227
#define DB_INDEX_FORTRESS_UPDATE_QUERY_IDREALM                                    1
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FORTRESSNAME                               2
#define DB_INDEX_FORTRESS_UPDATE_QUERY_WEIGHT                                     3
#define DB_INDEX_FORTRESS_UPDATE_QUERY_TSINTEGRITY                                4
#define DB_INDEX_FORTRESS_UPDATE_QUERY_SINTEGRITY                                 5
#define DB_INDEX_FORTRESS_UPDATE_QUERY_LENGTH                                     6
#define DB_INDEX_FORTRESS_UPDATE_QUERY_WIDTH                                      7
#define DB_INDEX_FORTRESS_UPDATE_QUERY_HEIGHT                                     8
#define DB_INDEX_FORTRESS_UPDATE_QUERY_QGPLASMA                                   9
#define DB_INDEX_FORTRESS_UPDATE_QUERY_ULREA                                     10
#define DB_INDEX_FORTRESS_UPDATE_QUERY_HEAVYWATER                                11
#define DB_INDEX_FORTRESS_UPDATE_QUERY_DEUTERIUM                                 12
#define DB_INDEX_FORTRESS_UPDATE_QUERY_ZCRYSTAL                                  13
#define DB_INDEX_FORTRESS_UPDATE_QUERY_ENERGY                                    14
#define DB_INDEX_FORTRESS_UPDATE_QUERY_ILMENITE                                  15
#define DB_INDEX_FORTRESS_UPDATE_QUERY_TITANIUM                                  16
#define DB_INDEX_FORTRESS_UPDATE_QUERY_QGPLASMAGRAD                              17
#define DB_INDEX_FORTRESS_UPDATE_QUERY_ULREAGRAD                                 18
#define DB_INDEX_FORTRESS_UPDATE_QUERY_HEAVYWATERGRAD                            19
#define DB_INDEX_FORTRESS_UPDATE_QUERY_DEUTERIUMGRAD                             20
#define DB_INDEX_FORTRESS_UPDATE_QUERY_ZCRYSTALGRAD                              21
#define DB_INDEX_FORTRESS_UPDATE_QUERY_ENERGYGRAD                                22
#define DB_INDEX_FORTRESS_UPDATE_QUERY_ILMENITEGRAD                              23
#define DB_INDEX_FORTRESS_UPDATE_QUERY_TITANIUMGRAD                              24
#define DB_INDEX_FORTRESS_UPDATE_QUERY_UPDQGPLASMA                               25
#define DB_INDEX_FORTRESS_UPDATE_QUERY_UPDULREA                                  26
#define DB_INDEX_FORTRESS_UPDATE_QUERY_UPDCONRES                                 27
#define DB_INDEX_FORTRESS_UPDATE_QUERY_UPDENERGY                                 28
#define DB_INDEX_FORTRESS_UPDATE_QUERY_QGPLASMATRIGGER                           29
#define DB_INDEX_FORTRESS_UPDATE_QUERY_CRTRIGGER                                 30
#define DB_INDEX_FORTRESS_UPDATE_QUERY_ENERGYTRIGGER                             31
#define DB_INDEX_FORTRESS_UPDATE_QUERY_TARGET                                    32
#define DB_INDEX_FORTRESS_UPDATE_QUERY_LTAIMTIME                                 33
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FORTRESSTYPE                             137

/* ENE */
#define DB_INDEX_FORTRESS_UPDATE_QUERY_ENE_ACCUMULATOR                           34
#define DB_INDEX_FORTRESS_UPDATE_QUERY_ENE_ESC_ENERGY                            35
#define DB_INDEX_FORTRESS_UPDATE_QUERY_ENE_ESC_TENERGY                           36

/* DEF */
#define DB_INDEX_FORTRESS_UPDATE_QUERY_DEF_SHIELDGENERATOR                       37
#define DB_INDEX_FORTRESS_UPDATE_QUERY_DEF_ESC1_ENERGY                           38
#define DB_INDEX_FORTRESS_UPDATE_QUERY_DEF_ESC1_TENERGY                          39
#define DB_INDEX_FORTRESS_UPDATE_QUERY_DEF_EDC_PRIORITY                          40
#define DB_INDEX_FORTRESS_UPDATE_QUERY_DEF_EDC_RATIO                             41
#define DB_INDEX_FORTRESS_UPDATE_QUERY_DEF_EDC_MPD                               42
#define DB_INDEX_FORTRESS_UPDATE_QUERY_DEF_EDC_SDOEL                             43

/* WEP */
#define DB_INDEX_FORTRESS_UPDATE_QUERY_WEP_ENERGYCIRCUIT                         44
#define DB_INDEX_FORTRESS_UPDATE_QUERY_WEP_DRONEMISSILES                         45
#define DB_INDEX_FORTRESS_UPDATE_QUERY_WEP_EDC_PRIORITY                          46
#define DB_INDEX_FORTRESS_UPDATE_QUERY_WEP_EDC_RATIO                             47
#define DB_INDEX_FORTRESS_UPDATE_QUERY_WEP_EDC_MPD                               48
#define DB_INDEX_FORTRESS_UPDATE_QUERY_WEP_EDC_SDOEL                             49

/* TBM */
#define DB_INDEX_FORTRESS_UPDATE_QUERY_TBM_GENERATOR                             50
#define DB_INDEX_FORTRESS_UPDATE_QUERY_TBM_ESC_ENERGY                            51
#define DB_INDEX_FORTRESS_UPDATE_QUERY_TBM_ESC_TENERGY                           52
#define DB_INDEX_FORTRESS_UPDATE_QUERY_TBM_EDC_PRIORITY                          53
#define DB_INDEX_FORTRESS_UPDATE_QUERY_TBM_EDC_RATIO                             54
#define DB_INDEX_FORTRESS_UPDATE_QUERY_TBM_EDC_MPD                               55
#define DB_INDEX_FORTRESS_UPDATE_QUERY_TBM_EDC_SDOEL                             56

/* MIN */
#define DB_INDEX_FORTRESS_UPDATE_QUERY_MIN_MAGCOLLECTORS                         57
#define DB_INDEX_FORTRESS_UPDATE_QUERY_MIN_FILTRATIONTANK                        58
#define DB_INDEX_FORTRESS_UPDATE_QUERY_MIN_MININGMACHINE                         59
#define DB_INDEX_FORTRESS_UPDATE_QUERY_MIN_DRILLINGMACHINE                       60
#define DB_INDEX_FORTRESS_UPDATE_QUERY_MIN_QGQUARRYING                           61
#define DB_INDEX_FORTRESS_UPDATE_QUERY_MIN_DEQUARRYING                           62
#define DB_INDEX_FORTRESS_UPDATE_QUERY_MIN_ZCQUARRYING                           63
#define DB_INDEX_FORTRESS_UPDATE_QUERY_MIN_ILQUARRYING                           64

/* SEN */
#define DB_INDEX_FORTRESS_UPDATE_QUERY_SEN_HIRESSENSORS                          65
#define DB_INDEX_FORTRESS_UPDATE_QUERY_SEN_LONGRANGESENSORS                      66
#define DB_INDEX_FORTRESS_UPDATE_QUERY_SEN_PSC1_STATE                            67
#define DB_INDEX_FORTRESS_UPDATE_QUERY_SEN_PSC1_CHARGING                         68
#define DB_INDEX_FORTRESS_UPDATE_QUERY_SEN_EDC1_PRIORITY                         69
#define DB_INDEX_FORTRESS_UPDATE_QUERY_SEN_EDC1_RATIO                            70
#define DB_INDEX_FORTRESS_UPDATE_QUERY_SEN_EDC1_MPD                              71
#define DB_INDEX_FORTRESS_UPDATE_QUERY_SEN_EDC1_SDOEL                            72
#define DB_INDEX_FORTRESS_UPDATE_QUERY_SEN_PSC2_STATE                            73
#define DB_INDEX_FORTRESS_UPDATE_QUERY_SEN_PSC2_CHARGING                         74
#define DB_INDEX_FORTRESS_UPDATE_QUERY_SEN_EDC2_PRIORITY                         75
#define DB_INDEX_FORTRESS_UPDATE_QUERY_SEN_EDC2_RATIO                            76
#define DB_INDEX_FORTRESS_UPDATE_QUERY_SEN_EDC2_MPD                              77
#define DB_INDEX_FORTRESS_UPDATE_QUERY_SEN_EDC2_SDOEL                            78

/* CLO */ 
#define DB_INDEX_FORTRESS_UPDATE_QUERY_CLO_CLOAKINGDEVICE                        79
#define DB_INDEX_FORTRESS_UPDATE_QUERY_CLO_PSC_STATE                             80
#define DB_INDEX_FORTRESS_UPDATE_QUERY_CLO_PSC_CHARGING                          81
#define DB_INDEX_FORTRESS_UPDATE_QUERY_CLO_EDC_PRIORITY                          82
#define DB_INDEX_FORTRESS_UPDATE_QUERY_CLO_EDC_RATIO                             83
#define DB_INDEX_FORTRESS_UPDATE_QUERY_CLO_EDC_MPD                               84
#define DB_INDEX_FORTRESS_UPDATE_QUERY_CLO_EDC_SDOEL                             85

/* CRE */
#define DB_INDEX_FORTRESS_UPDATE_QUERY_CRE_CREW_CAPITAN                          86
#define DB_INDEX_FORTRESS_UPDATE_QUERY_CRE_CREW_DOCTOR                           87
#define DB_INDEX_FORTRESS_UPDATE_QUERY_CRE_CREW_OFFICER                          88
#define DB_INDEX_FORTRESS_UPDATE_QUERY_CRE_CREW_ENGINEER                         89
#define DB_INDEX_FORTRESS_UPDATE_QUERY_CRE_CREW_PILOT                            90
#define DB_INDEX_FORTRESS_UPDATE_QUERY_CRE_CREW_SCIENTIST                        91
#define DB_INDEX_FORTRESS_UPDATE_QUERY_CRE_CREW_PASSENGER                        92

#define DB_INDEX_FORTRESS_UPDATE_QUERY_CRE_WOUNDED_CAPITAN                       93
#define DB_INDEX_FORTRESS_UPDATE_QUERY_CRE_WOUNDED_DOCTOR                        94
#define DB_INDEX_FORTRESS_UPDATE_QUERY_CRE_WOUNDED_OFFICER                       95
#define DB_INDEX_FORTRESS_UPDATE_QUERY_CRE_WOUNDED_ENGINEER                      96
#define DB_INDEX_FORTRESS_UPDATE_QUERY_CRE_WOUNDED_PILOT                         97
#define DB_INDEX_FORTRESS_UPDATE_QUERY_CRE_WOUNDED_SCIENTIST                     98
#define DB_INDEX_FORTRESS_UPDATE_QUERY_CRE_WOUNDED_PASSENGER                     99

/* ACC */
#define DB_INDEX_FORTRESS_UPDATE_QUERY_ACC_LUXURYAPARTMENTS                     100
#define DB_INDEX_FORTRESS_UPDATE_QUERY_ACC_COMFORTABLEROOMS                     101
#define DB_INDEX_FORTRESS_UPDATE_QUERY_ACC_COMMONCABINS                         102
#define DB_INDEX_FORTRESS_UPDATE_QUERY_ACC_WAREHOUSES                           103

/* MEC */
#define DB_INDEX_FORTRESS_UPDATE_QUERY_MEC_ANDROIDS                             104
#define DB_INDEX_FORTRESS_UPDATE_QUERY_MEC_PSC_STATE                            105
#define DB_INDEX_FORTRESS_UPDATE_QUERY_MEC_PSC_CHARGING                         106
#define DB_INDEX_FORTRESS_UPDATE_QUERY_MEC_EDC_PRIORITY                         107
#define DB_INDEX_FORTRESS_UPDATE_QUERY_MEC_EDC_RATIO                            108
#define DB_INDEX_FORTRESS_UPDATE_QUERY_MEC_EDC_MPD                              109
#define DB_INDEX_FORTRESS_UPDATE_QUERY_MEC_EDC_SDOEL                            110
#define DB_INDEX_FORTRESS_UPDATE_QUERY_MEC_MAX_WORK_ANDR                        163
#define DB_INDEX_FORTRESS_UPDATE_QUERY_MEC_MAX_REPA_ANDR                        164
#define DB_INDEX_FORTRESS_UPDATE_QUERY_MEC_ACT_REPA_ANDR                        165
#define DB_INDEX_FORTRESS_UPDATE_QUERY_MEC_ACT_CONS_ANDR 	                    166

/* WAR */
#define DB_INDEX_FORTRESS_UPDATE_QUERY_WAR_MAGNETICALGRID                       111
#define DB_INDEX_FORTRESS_UPDATE_QUERY_WAR_CONTAINER                            112
#define DB_INDEX_FORTRESS_UPDATE_QUERY_WAR_ENERGETICCELL                        113

/* OTH */
#define DB_INDEX_FORTRESS_UPDATE_QUERY_OTH_PLASMAFILTER                         114
#define DB_INDEX_FORTRESS_UPDATE_QUERY_OTH_LABS                                 115
#define DB_INDEX_FORTRESS_UPDATE_QUERY_OTH_LIFESUPPORT                          116
#define DB_INDEX_FORTRESS_UPDATE_QUERY_OTH_TRANSMITTER                          117
#define DB_INDEX_FORTRESS_UPDATE_QUERY_OTH_EDC_PRIORITY                         118
#define DB_INDEX_FORTRESS_UPDATE_QUERY_OTH_EDC_RATIO                            119
#define DB_INDEX_FORTRESS_UPDATE_QUERY_OTH_EDC_MPD                              120
#define DB_INDEX_FORTRESS_UPDATE_QUERY_OTH_EDC_SDOEL                            121

/* MAI */
#define DB_INDEX_FORTRESS_UPDATE_QUERY_MAI_MAINFRAME                            122
#define DB_INDEX_FORTRESS_UPDATE_QUERY_MAI_EDC_PRIORITY                         123
#define DB_INDEX_FORTRESS_UPDATE_QUERY_MAI_EDC_RATIO                            124
#define DB_INDEX_FORTRESS_UPDATE_QUERY_MAI_EDC_MPD                              125
#define DB_INDEX_FORTRESS_UPDATE_QUERY_MAI_EDC_SDOEL                            126

/* SUB */
#define DB_INDEX_FORTRESS_UPDATE_QUERY_SUB_COMPUTER                             127
#define DB_INDEX_FORTRESS_UPDATE_QUERY_SUB_QGCORE                               128
#define DB_INDEX_FORTRESS_UPDATE_QUERY_SUB_BEACON                               129
#define DB_INDEX_FORTRESS_UPDATE_QUERY_SUB_DAMPERS                              130
#define DB_INDEX_FORTRESS_UPDATE_QUERY_SUB_ACTUALSPEEDTOC                       161

/* IMP */
#define DB_INDEX_FORTRESS_UPDATE_QUERY_IMP_JETENGINE                            131
#define DB_INDEX_FORTRESS_UPDATE_QUERY_IMP_MECHDAMPERS                          132

/* FAC */ 
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FAC_MAGNETICALFILTER                     133
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FAC_DEUTERIUMDECOMP                      134
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FAC_ZIRCONIUMREACTOR                     135
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FAC_ILMENITEFURNACE                      136

#define DB_INDEX_FORTRESS_UPDATE_QUERY_IMP_ACTUALFORCE                          138
#define DB_INDEX_FORTRESS_UPDATE_QUERY_POSITIONX                                139
#define DB_INDEX_FORTRESS_UPDATE_QUERY_POSITIONY                                140
#define DB_INDEX_FORTRESS_UPDATE_QUERY_COURSEX                                  141
#define DB_INDEX_FORTRESS_UPDATE_QUERY_COURSEY                                  142
#define DB_INDEX_FORTRESS_UPDATE_QUERY_SPEEDNORM                                143
#define DB_INDEX_FORTRESS_UPDATE_QUERY_ACCELERATION                             144
#define DB_INDEX_FORTRESS_UPDATE_QUERY_SPOBJACTUALLYIN                          145
#define DB_INDEX_FORTRESS_UPDATE_QUERY_NEARESTSTAR                              146
#define DB_INDEX_FORTRESS_UPDATE_QUERY_WESPOBJ                                  147
#define DB_INDEX_FORTRESS_UPDATE_QUERY_MOV_STATE                                148
#define DB_INDEX_FORTRESS_UPDATE_QUERY_MOV_WARP_TARGET_X                        149
#define DB_INDEX_FORTRESS_UPDATE_QUERY_MOV_WARP_TARGET_Y                        150
#define DB_INDEX_FORTRESS_UPDATE_QUERY_MOV_WARP_START                           151
#define DB_INDEX_FORTRESS_UPDATE_QUERY_ENGINE_LIMIT                             152
#define DB_INDEX_FORTRESS_UPDATE_QUERY_TARGETSPACEOBJECT                        153
#define DB_INDEX_FORTRESS_UPDATE_QUERY_TARGETSHIP                               154
#define DB_INDEX_FORTRESS_UPDATE_QUERY_TARGETPOSITIONX                          155
#define DB_INDEX_FORTRESS_UPDATE_QUERY_TARGETPOSITIONY                          156
#define DB_INDEX_FORTRESS_UPDATE_QUERY_LASTACTUALIZATION                        157
#define DB_INDEX_FORTRESS_UPDATE_QUERY_SHIPMOVEACTION                           158
#define DB_INDEX_FORTRESS_UPDATE_QUERY_SHIPMOVETARGET                           159
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FORTRESCLASSCLASS                        160
#define DB_INDEX_FORTRESS_UPDATE_QUERY_GRAVSPEEDNORM                            162
#define DB_INDEX_FORTRESS_UPDATE_QUERY_STRUCTINTGRAD                            167
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_VOI_ANDR_PRIORITY                     168
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_VOI_ANDR_RATIO                        169
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_VOI_ANDR_ASSIGNED_DROIDS              170
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_ENE_ANDR_PRIORITY                     171
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_ENE_ANDR_RATIO                        172
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_ENE_ANDR_ASSIGNED_DROIDS              173
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_DEF_ANDR_PRIORITY                     174
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_DEF_ANDR_RATIO                        175
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_DEF_ANDR_ASSIGNED_DROIDS              176
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_WEP_ANDR_PRIORITY                     177
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_WEP_ANDR_RATIO                        178
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_WEP_ANDR_ASSIGNED_DROIDS              179
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_TBM_ANDR_PRIORITY                     180
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_TBM_ANDR_RATIO                        181
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_TBM_ANDR_ASSIGNED_DROIDS              182
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_MIN_ANDR_PRIORITY                     183
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_MIN_ANDR_RATIO                        184
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_MIN_ANDR_ASSIGNED_DROIDS              185
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_PRO_ANDR_PRIORITY                     186
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_PRO_ANDR_RATIO                        187
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_PRO_ANDR_ASSIGNED_DROIDS              188
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_SEN_ANDR_PRIORITY                     189
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_SEN_ANDR_RATIO                        190
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_SEN_ANDR_ASSIGNED_DROIDS              191
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_CLO_ANDR_PRIORITY                     192
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_CLO_ANDR_RATIO                        193
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_CLO_ANDR_ASSIGNED_DROIDS              194
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_CRE_ANDR_PRIORITY                     195
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_CRE_ANDR_RATIO                        196
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_CRE_ANDR_ASSIGNED_DROIDS              197
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_ACC_ANDR_PRIORITY                     198
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_ACC_ANDR_RATIO                        199
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_ACC_ANDR_ASSIGNED_DROIDS              200
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_MEC_ANDR_PRIORITY                     201
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_MEC_ANDR_RATIO                        202
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_MEC_ANDR_ASSIGNED_DROIDS              203
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_WAR_ANDR_PRIORITY                     204
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_WAR_ANDR_RATIO                        205
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_WAR_ANDR_ASSIGNED_DROIDS              206
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_OTH_ANDR_PRIORITY                     207
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_OTH_ANDR_RATIO                        208
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_OTH_ANDR_ASSIGNED_DROIDS              209
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_MAI_ANDR_PRIORITY                     210
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_MAI_ANDR_RATIO                        211
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_MAI_ANDR_ASSIGNED_DROIDS              212
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_SUB_ANDR_PRIORITY                     213
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_SUB_ANDR_RATIO                        214
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_SUB_ANDR_ASSIGNED_DROIDS              215
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_IMP_ANDR_PRIORITY                     216
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_IMP_ANDR_RATIO                        217
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_IMP_ANDR_ASSIGNED_DROIDS              218
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_HAN_ANDR_PRIORITY                     219
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_HAN_ANDR_RATIO                        220
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_HAN_ANDR_ASSIGNED_DROIDS              221
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_FAC_ANDR_PRIORITY                     222
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_FAC_ANDR_RATIO                        223
#define DB_INDEX_FORTRESS_UPDATE_QUERY_FS_FAC_ANDR_ASSIGNED_DROIDS              224
#define DB_INDEX_FORTRESS_UPDATE_QUERY_CONTROLLABLE                             225
#define DB_INDEX_FORTRESS_UPDATE_QUERY_BUILDING_PTS                             226

// ################################

// --------------------------------

#define DB_FORTRESS_INITIALIZE_QUERY "SELECT IDFORTRESS FROM FORTRESSES ORDER BY IDFORTRESS DESC"

#define DB_INDEX_FORTRESS_INITIALIZE_IDITEM                            1

// --------------------------------

void cacheFortressesListClass :: DB_Initialize()
{
    // priprav cache list a i nahraj data do indexu
    IBPP :: Database& db    = actx->db.getDatabase();
    IBPP :: Transaction& tr = actx->db.getTransaction();
    
    IBPP :: Statement s = IBPP :: StatementFactory(db, tr, DB_FORTRESS_INITIALIZE_QUERY);

	try
	{
        s->Execute();

        // nacteme, jak velky potrebujeme ten list
        if (s->Fetch())
        {
            int64_t d;
            s->Get(DB_INDEX_FORTRESS_INITIALIZE_IDITEM, d);
            expand((unsigned long)d + 1, identifiersReusable());       
        
            // postupne nacitame polozky
            do
            {
                int64_t itemId;
                s->Get(DB_INDEX_FORTRESS_INITIALIZE_IDITEM,    itemId);

                // pote oznacime polozku v listu, ze je v databazi
                data[(unsigned long)itemId].first = DATA_IN_DATABASE_ONLY;
                freeIDs.erase((dtIdentifier)itemId);
            } while (s->Fetch());
        }

        s->Close();
	}
	catch (std :: bad_alloc e)
	{
		errExceptionError(e.what());
	}   
	catch (IBPP :: Exception& e)
	{
		errExceptionError( e.what());
	}
}

// --------------------------------

void cacheFortressesListClass :: DB_IternalLoadFromQuery( unsigned long ID )
{
	// nahraj data itemu 
    IBPP :: Statement& s = actx->db.getFortressQuerySELECT();

	try
	{
		dataListObjectClass* obj = NULL;

        int64_t i;
        fortressesTypes fortressType;
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_FORTRESSTYPE, i);        fortressType = (fortressesTypes)i;

		// rozlisime, ktery druh fortressu nahrat, vytvorime ten objekt a nahrajeme ho
		switch (fortressType)
		{
        case FT_BASE: obj = new baseClass(); break;
        case FT_SHIP: obj = new shipClass(); break;
		default:
			obj = NULL;
		}

		if (obj != NULL)
		{
			obj->DB_Load(ID);
			data[ID] = make_pair(DATA_SYNCHRONIZED, obj);
		}
		else
		{
			errLogicalError( "Bad fortress index in items table");
		}
	}
	catch (std :: bad_alloc e)
	{
		errExceptionError( e.what());
	}
	catch (IBPP :: Exception& e)
	{
		errExceptionError( e.what());
	}
}

// --------------------------------

void cacheFortressesListClass :: DB_Load( unsigned long ID )
{
	// nahraj data itemu 
	IBPP :: Statement& s = actx->db.getFortressQuerySELECT();

	try
	{
        s->Set(DB_INDEX_FORTRESS_SELECT_QUERY_IDFORTRESS_WHERE, (int64_t)ID);
		s->Execute();

		// jestli je to v databazi, nahraj to, jinak oznam chybu 
		if (s->Fetch()) 
		{
			DB_IternalLoadFromQuery(ID);
		} else
		{
			errExceptionError( "Fortress load failed - no record in DB");
		}
	}
	catch (IBPP :: Exception& e)
	{
		errExceptionError( e.what());
	}
}

// --------------------------------

void cacheFortressesListClass :: DB_Remove( unsigned long ID )
{
	/* smaz vsechny uzly uzivatele */
	IBPP :: Statement& s = actx->db.getFortressQueryDELETE();	
    s->Set(DB_INDEX_FORTRESS_DELETE_QUERY_IDFORTRESS, (int64_t)ID);
	try
	{
		s->Execute();
	}
	catch (IBPP :: Exception& e)
	{
		errExceptionError( e.what());
	}
}

// --------------------------------

#define DB_INDEX_FORTRESS_SELECT_LIST_WHERE                     1
#define DB_INDEX_FORTRESS_SELECT_LIST_IDITEMOFLIST              1

// --------------------------------

static void __load_dtIdentifiersList_from_dblist(dtIdentifier ID, dbFortressList& fl, dtIdentifierList& il)
{
    /* nacteme query a smazeme idetifier list */
    IBPP :: Statement& s = fl.getFL_SELECT();
    il.clear();

	try
	{
        s->Set(DB_INDEX_FORTRESS_SELECT_LIST_WHERE, (int64_t)ID);
		s->Execute();

        while (s->Fetch())
        {
            int64_t data;
            s->Get(DB_INDEX_FORTRESS_SELECT_LIST_IDITEMOFLIST, data); il.push_back((dtIdentifier)data);
        }

	}
	catch (IBPP :: Exception& e)
	{
		errExceptionError( e.what());
	}
}

// --------------------------------

static void __load_dtIdentifiersList_from_dblist(dtIdentifier ID, dbFortressList& fl, dtIdentifierDeque& il)
{
    /* nacteme query a smazeme idetifier list */
    IBPP :: Statement& s = fl.getFL_SELECT();
    il.clear();

	try
	{
        s->Set(DB_INDEX_FORTRESS_SELECT_LIST_WHERE, (int64_t)ID);
		s->Execute();

        while (s->Fetch())
        {
            int64_t data;
            s->Get(DB_INDEX_FORTRESS_SELECT_LIST_IDITEMOFLIST, data); il.push_back((dtIdentifier)data);
        }

	}
	catch (IBPP :: Exception& e)
	{
		errExceptionError( e.what());
	}
}

// --------------------------------

#define DB_INDEX_FORTRESS_DELETE_LIST_WHERE                     1
#define DB_INDEX_FORTRESS_INSERT_LIST_IDFORTRESS                1
#define DB_INDEX_FORTRESS_INSERT_LIST_IDITEMOFLIST              2

// --------------------------------

static void __store_dtIdentifiersList_to_dblist(dtIdentifier ID, dbFortressList& fl, dtIdentifierDeque& il)
{
    /* nacteme query a smazeme idetifier list */
    IBPP :: Statement& r = fl.getFL_DELETE();
    IBPP :: Statement& i = fl.getFL_INSERT();

	try
	{
        r->Set(DB_INDEX_FORTRESS_DELETE_LIST_WHERE, (int64_t)ID);
		r->Execute();

        for (dtIdentifierDeque :: const_iterator iter = il.begin(); iter != il.end(); iter++)
        {
            i->Set(DB_INDEX_FORTRESS_INSERT_LIST_IDFORTRESS,    (int64_t)ID);
            i->Set(DB_INDEX_FORTRESS_INSERT_LIST_IDITEMOFLIST,  (int64_t)(*iter));
            i->Execute();
        }
	}
	catch (IBPP :: Exception& e)
	{
		errExceptionError( e.what());
	}
}

// --------------------------------

static void __store_dtIdentifiersList_to_dblist(dtIdentifier ID, dbFortressList& fl, dtIdentifierList& il)
{
    /* nacteme query a smazeme idetifier list */
    IBPP :: Statement& r = fl.getFL_DELETE();
    IBPP :: Statement& i = fl.getFL_INSERT();

	try
	{
        r->Set(DB_INDEX_FORTRESS_DELETE_LIST_WHERE, (int64_t)ID);
		r->Execute();

        for (dtIdentifierList :: const_iterator iter = il.begin(); iter != il.end(); iter++)
        {
            i->Set(DB_INDEX_FORTRESS_INSERT_LIST_IDFORTRESS,    (int64_t)ID);
            i->Set(DB_INDEX_FORTRESS_INSERT_LIST_IDITEMOFLIST,  (int64_t)(*iter));
            i->Execute();
        }
	}
	catch (IBPP :: Exception& e)
	{
		errExceptionError( e.what());
	}
}

// --------------------------------

static void __load_fortressSectionClass_from_query(IBPP :: Statement& query, int priority, int ratio, int assignedDroids, fortressSectionClass& fs)
{
    int64_t data;
    query->Get(priority,        data);      fs.androidsAssignment.priority          = (unsigned char) data;
    query->Get(ratio,           data);      fs.androidsAssignment.ratio             = (unsigned int)  data;
    query->Get(assignedDroids,  data);      fs.androidsAssignment.assignedDroids    = (unsigned long long) data;
}

// --------------------------------

static void __store_fortressSectionClass_to_query(IBPP :: Statement& query, int priority, int ratio, int assignedDroids, const fortressSectionClass& fs)
{
    query->Set(priority,        (int64_t)fs.androidsAssignment.priority);             
    query->Set(ratio,           (int64_t)fs.androidsAssignment.ratio);               
    query->Set(assignedDroids,  (int64_t)fs.androidsAssignment.assignedDroids );       
}

// --------------------------------

static void __store_fortressSectionClassNULL_to_query(IBPP :: Statement& query, int priority, int ratio, int assignedDroids)
{
    query->SetNull(priority);             
    query->SetNull(ratio);               
    query->SetNull(assignedDroids);       
}

// --------------------------------

static void __load_energyStateClass_from_query(IBPP :: Statement& query, int e, int te, energyStateClass& esc)
{
    int64_t data;
    query->Get(e,   data);           esc.energy       = (unsigned long long)data;
    query->Get(te,  data);           esc.targetEnergy = (unsigned long long)data;
}

// --------------------------------

static void __load_energyDivisionClass_from_query(IBPP :: Statement& query, int p, int r, int m, int s, energyDivisionClass& edc)
{
    int64_t data;
    query->Get(p, data);             edc.priority               = (unsigned char) data;
    query->Get(r, data);             edc.ratio                  = (unsigned int)  data;
    query->Get(m, edc.maxPowerDrain);      
    query->Get(s, data);             edc.shutDownOnEnergyLack   = data != 0;
}

// --------------------------------

static void __load_powerStateClass_from_query(IBPP :: Statement& query, int s, int n, powerStateClass& ps)
{
    int64_t data;
    double fdata;
    query->Get(s, data);
    query->Get(n, fdata);
    ps.DB_Init((powerState)data, fdata);
}

// --------------------------------

static void __store_energyStateClass_to_query(IBPP :: Statement& query, int e, int te, const energyStateClass& esc)
{
    query->Set(e,   (int64_t)esc.energy);                
    query->Set(te,  (int64_t)esc.targetEnergy);           
}

// --------------------------------

static void __store_energyDivisionClass_to_query(IBPP :: Statement& query, int p, int r, int m, int s, energyDivisionClass& edc)
{
    query->Set(p, (int64_t)edc.priority);                          
    query->Set(r, (int64_t)edc.ratio);                             
    query->Set(m, edc.maxPowerDrain );                      
    query->Set(s, (int64_t)(edc.shutDownOnEnergyLack ? 1 : 0));              
}

// --------------------------------

static void __store_powerStateClass_to_query(IBPP :: Statement& query, int s, int n, powerStateClass& ps)
{
    query->Set(s, (int64_t)ps.getState());
    query->Set(n, (double)(ps.getNarrowCharging()));
}

// --------------------------------

#define DB_INDEX_FORTRESS_SELECT_LISTES_WHERE                     1
#define DB_INDEX_FORTRESS_SELECT_LISTES_IDITEMOFLIST              1
#define DB_INDEX_FORTRESS_SELECT_LISTES_ENERGY                    2
#define DB_INDEX_FORTRESS_SELECT_LISTES_TARGETENERGY              3

static void __load_dtIdentifiersESList_from_dblist(dtIdentifier ID, dbFortressList& fl, dtIdentifierEnergyStatePairDeque& il)
{
    /* nacteme query a smazeme idetifier list */
    IBPP :: Statement& s = fl.getFL_SELECT();
    il.clear();

	try
	{
        s->Set(DB_INDEX_FORTRESS_SELECT_LISTES_WHERE, (int64_t)ID);
		s->Execute();

        while (s->Fetch())
        {
            int64_t itemID;
            s->Get(DB_INDEX_FORTRESS_SELECT_LISTES_IDITEMOFLIST, itemID); 

            // nacteme EnergyStateClass
            energyStateClass esc;
            __load_energyStateClass_from_query(s, DB_INDEX_FORTRESS_SELECT_LISTES_ENERGY,
                DB_INDEX_FORTRESS_SELECT_LISTES_TARGETENERGY, esc);

            il.push_back(std :: make_pair((dtIdentifier)itemID, esc));
        }

	}
	catch (IBPP :: Exception& e)
	{
		errExceptionError( e.what());
	}
}

// --------------------------------

#define DB_INDEX_FORTRESS_DELETE_LISTLE_WHERE       1
#define DB_INDEX_FORTRESS_INSERT_LISTLE_IDFORTRESS                1
#define DB_INDEX_FORTRESS_INSERT_LISTLE_IDITEMOFLIST              2
#define DB_INDEX_FORTRESS_INSERT_LISTLE_ENERGY                    3
#define DB_INDEX_FORTRESS_INSERT_LISTLE_TARGETENERGY              4

// --------------------------------

static void __store_dtIdentifiersESList_to_dblist(dtIdentifier ID, dbFortressList& fl, dtIdentifierEnergyStatePairDeque& il)
{
    /* nacteme query a smazeme idetifier list */
    IBPP :: Statement& r = fl.getFL_DELETE();
    IBPP :: Statement& i = fl.getFL_INSERT();

	try
	{
        r->Set(DB_INDEX_FORTRESS_DELETE_LISTLE_WHERE, (int64_t)ID);
		r->Execute();

        for (dtIdentifierEnergyStatePairDeque :: const_iterator iter = il.begin(); iter != il.end(); iter++)
        {
            i->Set(DB_INDEX_FORTRESS_INSERT_LISTLE_IDFORTRESS,    (int64_t)ID);
            i->Set(DB_INDEX_FORTRESS_INSERT_LISTLE_IDITEMOFLIST,  (int64_t)(iter->first));
            __store_energyStateClass_to_query(i, DB_INDEX_FORTRESS_INSERT_LISTLE_ENERGY,
                DB_INDEX_FORTRESS_INSERT_LISTLE_TARGETENERGY, iter->second);
            i->Execute();
        }
	}
	catch (IBPP :: Exception& e)
	{
		errExceptionError( e.what());
	}
}

// --------------------------------

void fortressClass :: DB_Load(unsigned long ID)
{
	// predpokladame, ze dotaz je pripraveny pro cteni dat
	IBPP :: Statement& s = actx->db.getFortressQuerySELECT();

	setID(ID);

    try
    {
	    int64_t data = 0;
        double floatData = 0.0;

	    // nacteme zakladni data 
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_IDREALM,              data);             realmID_                             = (dtIdentifier) data;
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_FORTRESSNAME ,        fortressName_);  
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_WEIGHT,               data);             weight_                              = (unsigned long long) data;
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_TSINTEGRITY,          data);             totalStructuralIntegrity_            = (unsigned long long) data;
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_SINTEGRITY,           data);             structuralIntegrity_                 = (unsigned long long) data;
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_LENGTH,               length_);          
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_WIDTH,                width_);            
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_HEIGHT,               height_);   

        // nacteme suroviny 
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_QGPLASMA,             quarkGluonPlasma_);            
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_ULREA,                ulrea_);            
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_HEAVYWATER,           heavyWater_);             
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_DEUTERIUM,            deuterium_);            
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_ZCRYSTAL,             zirconiumCrystal_);          
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_ENERGY,               energy_);            
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_ILMENITE,             ilmenite_);                   
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_TITANIUM,             titanium_);   

        // gradienty surovin
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_QGPLASMAGRAD,         floatData);             quarkGluonPlasmaGradient_       = floatData;    
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_ULREAGRAD,            floatData);             ulreaGradient_                  = floatData;             
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_HEAVYWATERGRAD,       floatData);             heavyWaterGradient_             = floatData;    
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_DEUTERIUMGRAD,        floatData);             deuteriumGradient_              = floatData;    
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_ZCRYSTALGRAD,         floatData);             zirconiumCrystalGradient_       = floatData;    
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_ENERGYGRAD,           floatData);             energyGradient_                 = floatData;     
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_ILMENITEGRAD,         floatData);             ilmeniteGradient_               = floatData;   
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_TITANIUMGRAD,         floatData);             titaniumGradient_               = floatData;     

        // upgrady surovin
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_UPDQGPLASMA,          floatData);             quarkGluonPlasmaUpdate_         = floatData;          
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_UPDULREA,             floatData);             ulreaUpdate_                    = floatData;            
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_UPDCONRES,            floatData);             containeredResourcesUpdate_     = floatData;                   
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_UPDENERGY,            floatData);             energyUpdate_                   = floatData;  

        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_QGPLASMATRIGGER,      floatData);             quarkGluonPlasmaTrigger_        = floatData;            
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_CRTRIGGER,            floatData);             containeredResourcesTrigger_    = floatData;                   
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_ENERGYTRIGGER,        floatData);             energyTrigger_                  = floatData;  

        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_TARGET,               data);                  targetOfWeapons_                = (dtIdentifier) data;
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_LTAIMTIME,            floatData);             lastTargetAimTime_              = floatData;

        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_FORTRESCLASSCLASS,    data);                  fortressClassID_                = (dtIdentifier) data;

        // ENE
        energeticSystem.__internal_DB_Load(s);

        // DEF
        deflectorShields.__internal_DB_Load(s);

        // WEP
        weapons.__internal_DB_Load(ID, s);

        // TBM
        transportBeam.__internal_DB_Load(s);

        // MIN
        miningDevices.__internal_DB_Load(s);

        // PRO
        probeDevices.__internal_DB_Load(ID, s);

        // SEN
        sensors.__internal_DB_Load(s);

        // CLO
        cloaking.__internal_DB_Load(s);

        // CRE
        crew.__internal_DB_Load(s);

        // ACC
        accommodations.__internal_DB_Load(s);

        // MEC
        mechanics.__internal_DB_Load(s);

        // WAR
        warehouse.__internal_DB_Load(ID, s);

        // OTH
        otherEquipment.__internal_DB_Load(s);

        // MAI
        mainframeSystem.__internal_DB_Load(s);

        // nacteme androidy
        __load_fortressSectionClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_FS_VOI_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_SELECT_QUERY_FS_VOI_ANDR_RATIO, DB_INDEX_FORTRESS_SELECT_QUERY_FS_VOI_ANDR_ASSIGNED_DROIDS,
            structuralIntegrityVoidSection);
        __load_fortressSectionClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_FS_ENE_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_SELECT_QUERY_FS_ENE_ANDR_RATIO, DB_INDEX_FORTRESS_SELECT_QUERY_FS_ENE_ANDR_ASSIGNED_DROIDS,
            energeticSystem);
        __load_fortressSectionClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_FS_DEF_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_SELECT_QUERY_FS_DEF_ANDR_RATIO, DB_INDEX_FORTRESS_SELECT_QUERY_FS_DEF_ANDR_ASSIGNED_DROIDS,
            deflectorShields);
        __load_fortressSectionClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_FS_WEP_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_SELECT_QUERY_FS_WEP_ANDR_RATIO, DB_INDEX_FORTRESS_SELECT_QUERY_FS_WEP_ANDR_ASSIGNED_DROIDS,
            weapons);
        __load_fortressSectionClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_FS_TBM_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_SELECT_QUERY_FS_TBM_ANDR_RATIO, DB_INDEX_FORTRESS_SELECT_QUERY_FS_TBM_ANDR_ASSIGNED_DROIDS,
            transportBeam);
        __load_fortressSectionClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_FS_MIN_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_SELECT_QUERY_FS_MIN_ANDR_RATIO, DB_INDEX_FORTRESS_SELECT_QUERY_FS_MIN_ANDR_ASSIGNED_DROIDS,
            miningDevices);
        __load_fortressSectionClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_FS_PRO_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_SELECT_QUERY_FS_PRO_ANDR_RATIO, DB_INDEX_FORTRESS_SELECT_QUERY_FS_PRO_ANDR_ASSIGNED_DROIDS,
            probeDevices);
        __load_fortressSectionClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_FS_SEN_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_SELECT_QUERY_FS_SEN_ANDR_RATIO, DB_INDEX_FORTRESS_SELECT_QUERY_FS_SEN_ANDR_ASSIGNED_DROIDS,
            sensors);
        __load_fortressSectionClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_FS_CLO_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_SELECT_QUERY_FS_CLO_ANDR_RATIO, DB_INDEX_FORTRESS_SELECT_QUERY_FS_CLO_ANDR_ASSIGNED_DROIDS,
            cloaking);
        __load_fortressSectionClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_FS_CRE_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_SELECT_QUERY_FS_CRE_ANDR_RATIO, DB_INDEX_FORTRESS_SELECT_QUERY_FS_CRE_ANDR_ASSIGNED_DROIDS,
            crew);
        __load_fortressSectionClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_FS_ACC_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_SELECT_QUERY_FS_ACC_ANDR_RATIO, DB_INDEX_FORTRESS_SELECT_QUERY_FS_ACC_ANDR_ASSIGNED_DROIDS,
            accommodations);
        __load_fortressSectionClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_FS_MEC_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_SELECT_QUERY_FS_MEC_ANDR_RATIO, DB_INDEX_FORTRESS_SELECT_QUERY_FS_MEC_ANDR_ASSIGNED_DROIDS,
            mechanics);
        __load_fortressSectionClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_FS_WAR_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_SELECT_QUERY_FS_WAR_ANDR_RATIO, DB_INDEX_FORTRESS_SELECT_QUERY_FS_WAR_ANDR_ASSIGNED_DROIDS,
            warehouse);
        __load_fortressSectionClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_FS_OTH_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_SELECT_QUERY_FS_OTH_ANDR_RATIO, DB_INDEX_FORTRESS_SELECT_QUERY_FS_OTH_ANDR_ASSIGNED_DROIDS,
            otherEquipment);
        __load_fortressSectionClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_FS_MAI_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_SELECT_QUERY_FS_MAI_ANDR_RATIO, DB_INDEX_FORTRESS_SELECT_QUERY_FS_MAI_ANDR_ASSIGNED_DROIDS,
            mainframeSystem);
    }
	catch (IBPP :: Exception& e)
	{
		errExceptionError( e.what());
	}
}

// --------------------------------
// --------------------------------

void fortressClass :: DB_Insert(unsigned long ID)
{
	// predpokladame, ze dotaz je pripraveny pro cteni dat
	IBPP :: Statement& s = actx->db.getFortressQueryINSERT();

    setID(ID);

    try
    {
        // ulozime data fortressu
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_IDFORTRESS,   (int64_t)ID);
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_FORTRESSTYPE, (int64_t)getFortressType());

	    // ulozime zakladni data 
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_IDREALM,              (int64_t)realmID_);                                         
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_FORTRESSNAME ,        fortressName_);  
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_WEIGHT,               (int64_t)weight_);                                           
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_TSINTEGRITY,          (int64_t)totalStructuralIntegrity_);                        
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_SINTEGRITY,           (int64_t)structuralIntegrity_);                          
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_LENGTH,               length_);          
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_WIDTH,                width_);            
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_HEIGHT,               height_);   

        // ulozime suroviny 
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_QGPLASMA,             quarkGluonPlasma_);            
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_ULREA,                ulrea_);            
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_HEAVYWATER,           heavyWater_);             
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_DEUTERIUM,            deuterium_);            
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_ZCRYSTAL,             zirconiumCrystal_);          
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_ENERGY,               energy_);            
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_ILMENITE,             ilmenite_);                   
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_TITANIUM,             titanium_);   

        // gradienty surovin
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_QGPLASMAGRAD,         quarkGluonPlasmaGradient_);            
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_ULREAGRAD,            ulreaGradient_);            
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_HEAVYWATERGRAD,       heavyWaterGradient_);             
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_DEUTERIUMGRAD,        deuteriumGradient_);            
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_ZCRYSTALGRAD,         zirconiumCrystalGradient_);          
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_ENERGYGRAD,           energyGradient_);            
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_ILMENITEGRAD,         ilmeniteGradient_);                   
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_TITANIUMGRAD,         titaniumGradient_);   

        // upgrady surovin
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_UPDQGPLASMA,          (double)quarkGluonPlasmaUpdate_);                              
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_UPDULREA,             (double)ulreaUpdate_);                                         
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_UPDCONRES,            (double)containeredResourcesUpdate_);                                   
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_UPDENERGY,            (double)energyUpdate_);                                

        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_QGPLASMATRIGGER,      (double)quarkGluonPlasmaTrigger_);                                
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_CRTRIGGER,            (double)containeredResourcesTrigger_);                                  
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_ENERGYTRIGGER,        (double)energyTrigger_);                               

        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_TARGET,               (int64_t)targetOfWeapons_);                                 
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_LTAIMTIME,            (double)lastTargetAimTime_);    

        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_FORTRESCLASSCLASS,    (int64_t)fortressClassID_);

        // ENE
        energeticSystem.__internal_DB_Insert(s);

        // DEF
        deflectorShields.__internal_DB_Insert(s);

        // WEP
        weapons.__internal_DB_Insert(ID, s);

        // TBM
        transportBeam.__internal_DB_Insert(s);

        // MIN
        miningDevices.__internal_DB_Insert(s);

        // PRO
        probeDevices.__internal_DB_Insert(ID, s);

        // SEN
        sensors.__internal_DB_Insert(s);

        // CLO
        cloaking.__internal_DB_Insert(s);

        // CRE
        crew.__internal_DB_Insert(s);

        // ACC
        accommodations.__internal_DB_Insert(s);

        // MEC
        mechanics.__internal_DB_Insert(s);

        // WAR
        warehouse.__internal_DB_Insert(ID, s);

        // OTH
        otherEquipment.__internal_DB_Insert(s);

        // MAI
        mainframeSystem.__internal_DB_Insert(s);

        // ulozime androidy
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_FS_VOI_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_INSERT_QUERY_FS_VOI_ANDR_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_FS_VOI_ANDR_ASSIGNED_DROIDS,
            structuralIntegrityVoidSection);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_FS_ENE_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_INSERT_QUERY_FS_ENE_ANDR_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_FS_ENE_ANDR_ASSIGNED_DROIDS,
            energeticSystem);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_FS_DEF_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_INSERT_QUERY_FS_DEF_ANDR_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_FS_DEF_ANDR_ASSIGNED_DROIDS,
            deflectorShields);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_FS_WEP_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_INSERT_QUERY_FS_WEP_ANDR_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_FS_WEP_ANDR_ASSIGNED_DROIDS,
            weapons);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_FS_TBM_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_INSERT_QUERY_FS_TBM_ANDR_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_FS_TBM_ANDR_ASSIGNED_DROIDS,
            transportBeam);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_FS_MIN_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_INSERT_QUERY_FS_MIN_ANDR_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_FS_MIN_ANDR_ASSIGNED_DROIDS,
            miningDevices);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_FS_PRO_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_INSERT_QUERY_FS_PRO_ANDR_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_FS_PRO_ANDR_ASSIGNED_DROIDS,
            probeDevices);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_FS_SEN_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_INSERT_QUERY_FS_SEN_ANDR_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_FS_SEN_ANDR_ASSIGNED_DROIDS,
            sensors);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_FS_CLO_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_INSERT_QUERY_FS_CLO_ANDR_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_FS_CLO_ANDR_ASSIGNED_DROIDS,
            cloaking);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_FS_CRE_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_INSERT_QUERY_FS_CRE_ANDR_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_FS_CRE_ANDR_ASSIGNED_DROIDS,
            crew);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_FS_ACC_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_INSERT_QUERY_FS_ACC_ANDR_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_FS_ACC_ANDR_ASSIGNED_DROIDS,
            accommodations);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_FS_MEC_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_INSERT_QUERY_FS_MEC_ANDR_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_FS_MEC_ANDR_ASSIGNED_DROIDS,
            mechanics);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_FS_WAR_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_INSERT_QUERY_FS_WAR_ANDR_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_FS_WAR_ANDR_ASSIGNED_DROIDS,
            warehouse);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_FS_OTH_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_INSERT_QUERY_FS_OTH_ANDR_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_FS_OTH_ANDR_ASSIGNED_DROIDS,
            otherEquipment);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_FS_MAI_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_INSERT_QUERY_FS_MAI_ANDR_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_FS_MAI_ANDR_ASSIGNED_DROIDS,
            mainframeSystem);
    }
	catch (IBPP :: Exception& e)
	{
		errExceptionError( e.what());
	}
}

// --------------------------------
// --------------------------------

void fortressClass :: DB_Save(unsigned long ID)
{
	// predpokladame, ze dotaz je pripraveny pro cteni dat
	IBPP :: Statement& s = actx->db.getFortressQueryUPDATE();

    setID(ID);

    try
    {
        // ulozime data fortressu
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_IDFORTRESS,   (int64_t)ID);
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_FORTRESSTYPE, (int64_t)getFortressType());

	    // ulozime zakladni data 
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_IDREALM,              (int64_t)realmID_);                                         
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_FORTRESSNAME ,        fortressName_);  
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_WEIGHT,               (int64_t)weight_);                                           
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_TSINTEGRITY,          (int64_t)totalStructuralIntegrity_);                        
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_SINTEGRITY,           (int64_t)structuralIntegrity_);                          
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_LENGTH,               length_);          
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_WIDTH,                width_);            
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_HEIGHT,               height_);   

        // ulozime suroviny 
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_QGPLASMA,             quarkGluonPlasma_);            
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_ULREA,                ulrea_);            
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_HEAVYWATER,           heavyWater_);             
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_DEUTERIUM,            deuterium_);            
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_ZCRYSTAL,             zirconiumCrystal_);          
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_ENERGY,               energy_);            
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_ILMENITE,             ilmenite_);                   
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_TITANIUM,             titanium_);   

        // gradienty surovin
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_QGPLASMAGRAD,         quarkGluonPlasmaGradient_);            
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_ULREAGRAD,            ulreaGradient_);            
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_HEAVYWATERGRAD,       heavyWaterGradient_);             
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_DEUTERIUMGRAD,        deuteriumGradient_);            
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_ZCRYSTALGRAD,         zirconiumCrystalGradient_);          
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_ENERGYGRAD,           energyGradient_);            
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_ILMENITEGRAD,         ilmeniteGradient_);                   
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_TITANIUMGRAD,         titaniumGradient_);   

        // upgrady surovin
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_UPDQGPLASMA,          (double)quarkGluonPlasmaUpdate_);                              
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_UPDULREA,             (double)ulreaUpdate_);                                         
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_UPDCONRES,            (double)containeredResourcesUpdate_);                                   
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_UPDENERGY,            (double)energyUpdate_);                                

        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_QGPLASMATRIGGER,      (double)quarkGluonPlasmaTrigger_);                                
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_CRTRIGGER,            (double)containeredResourcesTrigger_);                                  
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_ENERGYTRIGGER,        (double)energyTrigger_);                               

        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_TARGET,               (int64_t)targetOfWeapons_);                                 
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_LTAIMTIME,            (double)lastTargetAimTime_); 

        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_FORTRESCLASSCLASS,    (int64_t)fortressClassID_);

        // ENE
        energeticSystem.__internal_DB_Save(s);

        // DEF
        deflectorShields.__internal_DB_Save(s);

        // WEP
        weapons.__internal_DB_Save(ID, s);

        // TBM
        transportBeam.__internal_DB_Save(s);

        // MIN
        miningDevices.__internal_DB_Save(s);

        // PRO
        probeDevices.__internal_DB_Save(ID, s);

        // SEN
        sensors.__internal_DB_Save(s);

        // CLO
        cloaking.__internal_DB_Save(s);

        // CRE
        crew.__internal_DB_Save(s);

        // ACC
        accommodations.__internal_DB_Save(s);

        // MEC
        mechanics.__internal_DB_Save(s);

        // WAR
        warehouse.__internal_DB_Save(ID, s);

        // OTH
        otherEquipment.__internal_DB_Save(s);

        // MAI
        mainframeSystem.__internal_DB_Save(s);

        // ulozime androidy
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_VOI_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_UPDATE_QUERY_FS_VOI_ANDR_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_VOI_ANDR_ASSIGNED_DROIDS,
            structuralIntegrityVoidSection);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_ENE_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_UPDATE_QUERY_FS_ENE_ANDR_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_ENE_ANDR_ASSIGNED_DROIDS,
            energeticSystem);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_DEF_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_UPDATE_QUERY_FS_DEF_ANDR_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_DEF_ANDR_ASSIGNED_DROIDS,
            deflectorShields);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_WEP_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_UPDATE_QUERY_FS_WEP_ANDR_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_WEP_ANDR_ASSIGNED_DROIDS,
            weapons);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_TBM_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_UPDATE_QUERY_FS_TBM_ANDR_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_TBM_ANDR_ASSIGNED_DROIDS,
            transportBeam);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_MIN_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_UPDATE_QUERY_FS_MIN_ANDR_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_MIN_ANDR_ASSIGNED_DROIDS,
            miningDevices);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_PRO_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_UPDATE_QUERY_FS_PRO_ANDR_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_PRO_ANDR_ASSIGNED_DROIDS,
            probeDevices);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_SEN_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_UPDATE_QUERY_FS_SEN_ANDR_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_SEN_ANDR_ASSIGNED_DROIDS,
            sensors);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_CLO_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_UPDATE_QUERY_FS_CLO_ANDR_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_CLO_ANDR_ASSIGNED_DROIDS,
            cloaking);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_CRE_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_UPDATE_QUERY_FS_CRE_ANDR_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_CRE_ANDR_ASSIGNED_DROIDS,
            crew);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_ACC_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_UPDATE_QUERY_FS_ACC_ANDR_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_ACC_ANDR_ASSIGNED_DROIDS,
            accommodations);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_MEC_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_UPDATE_QUERY_FS_MEC_ANDR_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_MEC_ANDR_ASSIGNED_DROIDS,
            mechanics);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_WAR_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_UPDATE_QUERY_FS_WAR_ANDR_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_WAR_ANDR_ASSIGNED_DROIDS,
            warehouse);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_OTH_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_UPDATE_QUERY_FS_OTH_ANDR_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_OTH_ANDR_ASSIGNED_DROIDS,
            otherEquipment);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_MAI_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_UPDATE_QUERY_FS_MAI_ANDR_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_MAI_ANDR_ASSIGNED_DROIDS,
            mainframeSystem);
    }
	catch (IBPP :: Exception& e)
	{
		errExceptionError( e.what());
	}
}

// --------------------------------
// --------------------------------


void factoriesClass :: __internal_DB_Load(  IBPP :: Statement& s )
{
    // FAC 
    int64_t data;

    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_FAC_MAGNETICALFILTER,         data);                  
    magneticalFilterID_            = (dtIdentifier)data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_FAC_DEUTERIUMDECOMP,          data);                  
    deuteriumDecomposerID_         = (dtIdentifier)data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_FAC_ZIRCONIUMREACTOR,         data);                  
    zirconiumReactorID_            = (dtIdentifier)data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_FAC_ILMENITEFURNACE,          data);                  
    ilmeniteFurnaceID_             = (dtIdentifier)data;
}

// --------------------------------

void hangarsPortClass :: __internal_DB_Load(dtIdentifier ID, IBPP :: Statement& s )
{
    // HAN 
    __load_dtIdentifiersList_from_dblist(ID, actx->db.getHAN_HANGARS_fortress_list(), hangarsIDs_);
}

// --------------------------------

void impulsDriveClass :: __internal_DB_Load(  IBPP :: Statement& s )
{
    // IMP 
    int64_t data;

    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_IMP_JETENGINE,         data);                  
    impulsJetEngineID_            = (dtIdentifier)data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_IMP_MECHDAMPERS,       data);                  
    mechanicalDampersID_          = (dtIdentifier)data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_IMP_ACTUALFORCE,       data);
    actualJetForce_               = (unsigned long)data;
}

// --------------------------------

void subspaceDriveClass :: __internal_DB_Load(  IBPP :: Statement& s )
{
    // SUB 
    int64_t data;

    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_SUB_COMPUTER,         data);                  
    navigationComputerID_            = (dtIdentifier)data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_SUB_QGCORE,           data);                  
    quarkGluonCoreID_                = (dtIdentifier)data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_SUB_BEACON,           data);                  
    subspaceBeaconID_                = (dtIdentifier)data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_SUB_DAMPERS,          data);                  
    inertialDampersID_               = (dtIdentifier)data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_SUB_ACTUALSPEEDTOC,   actualSpeedToC_);
}

// --------------------------------

void mainframeSystemClass :: __internal_DB_Load(  IBPP :: Statement& s )
{
    // MAI 
    int64_t data;

    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_MAI_MAINFRAME,         data);                  
    mainframeID_                = (dtIdentifier)data;

    __load_energyDivisionClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_MAI_EDC_PRIORITY,
        DB_INDEX_FORTRESS_SELECT_QUERY_MAI_EDC_RATIO, DB_INDEX_FORTRESS_SELECT_QUERY_MAI_EDC_MPD,
        DB_INDEX_FORTRESS_SELECT_QUERY_MAI_EDC_SDOEL, mainframeEnergyDivision);
}

// --------------------------------

void otherEquipmentClass :: __internal_DB_Load(  IBPP :: Statement& s )
{
    // WAR 
    int64_t data;

    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_OTH_PLASMAFILTER,         data);                  
    plasmaFilterID_               = (dtIdentifier)data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_OTH_LABS,              data);                  
    scientificLabID_              = (dtIdentifier)data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_OTH_LIFESUPPORT,          data);                  
    lifeSupportID_                = (dtIdentifier)data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_OTH_TRANSMITTER,          data);                  
    subspaceTransmitterID_        = (dtIdentifier)data;

    __load_energyDivisionClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_OTH_EDC_PRIORITY,
        DB_INDEX_FORTRESS_SELECT_QUERY_OTH_EDC_RATIO, DB_INDEX_FORTRESS_SELECT_QUERY_OTH_EDC_MPD,
        DB_INDEX_FORTRESS_SELECT_QUERY_OTH_EDC_SDOEL, lifeSupportEnergyDivision);
}

// --------------------------------

void warehouseClass :: __internal_DB_Load( dtIdentifier ID, IBPP :: Statement& s )
{
    // WAR 
    int64_t data;

    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_WAR_MAGNETICALGRID,         data);                  
    magneticalGridID_               = (dtIdentifier)data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_WAR_CONTAINER,              data);                  
    transportContainerID_           = (dtIdentifier)data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_WAR_ENERGETICCELL,          data);                  
    energeticCellID_                = (dtIdentifier)data;

    __load_dtIdentifiersList_from_dblist(ID, actx->db.getWAR_STORAGE_fortress_list(), storageIDs_);
}

// --------------------------------

void mechanicsClass :: __internal_DB_Load(  IBPP :: Statement& s )
{
    // MEC 
    int64_t data;

    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_MEC_ANDROIDS,             data);      androidsID_                 = (dtIdentifier)  data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_MEC_MAX_WORK_ANDR,        data);      maxWorkingAndroids_         = (unsigned long long) data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_MEC_MAX_REPA_ANDR,        data);      maxRepairingAndroids_       = (unsigned long long) data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_MEC_ACT_REPA_ANDR,        data);      actualRepairingAndroids_    = (unsigned long long) data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_MEC_ACT_CONS_ANDR,        data);      actualConstructingAndroids_ = (unsigned long long) data;   

    __load_powerStateClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_MEC_PSC_STATE,
        DB_INDEX_FORTRESS_SELECT_QUERY_MEC_PSC_CHARGING, androidsPowerState);
    __load_energyDivisionClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_MEC_EDC_PRIORITY,
        DB_INDEX_FORTRESS_SELECT_QUERY_MEC_EDC_RATIO, DB_INDEX_FORTRESS_SELECT_QUERY_MEC_EDC_MPD,
        DB_INDEX_FORTRESS_SELECT_QUERY_MEC_EDC_SDOEL, androidsEnergyDivision);
}

// --------------------------------

void accommodationsClass :: __internal_DB_Load(  IBPP :: Statement& s )
{
    // ACC 
    int64_t data;

    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_ACC_LUXURYAPARTMENTS,             data);                  
    luxuryApartments_           = (unsigned long)data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_ACC_COMFORTABLEROOMS,              data);                  
    comfortableRooms_           = (unsigned long)data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_ACC_COMMONCABINS,             data);                  
    commonCabins_               = (unsigned long)data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_ACC_WAREHOUSES,            data);                  
    warehousesWithLifeSupport_  = (unsigned long)data;
}

// --------------------------------

void crewClass :: __internal_DB_Load(  IBPP :: Statement& s )
{
    // CRE 
    int64_t data;

    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_CRE_CREW_CAPITAN,             data);                  
    ableCrew_[CREW_CAPITAN]     = (unsigned long)data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_CRE_CREW_DOCTOR,              data);                  
    ableCrew_[CREW_DOCTOR]      = (unsigned long)data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_CRE_CREW_OFFICER,             data);                  
    ableCrew_[CREW_OFFICER]     = (unsigned long)data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_CRE_CREW_ENGINEER,            data);                  
    ableCrew_[CREW_ENGINEER]    = (unsigned long)data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_CRE_CREW_PILOT,               data);                  
    ableCrew_[CREW_PILOT]       = (unsigned long)data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_CRE_CREW_SCIENTIST,           data);                  
    ableCrew_[CREW_SCIENTIST]   = (unsigned long)data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_CRE_CREW_PASSENGER,           data);                  
    ableCrew_[CREW_PASSENGER]   = (unsigned long)data;

    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_CRE_WOUNDED_CAPITAN,          data);                  
    woundedCrew_[CREW_CAPITAN]     = (unsigned long)data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_CRE_WOUNDED_DOCTOR,          data);                  
    woundedCrew_[CREW_DOCTOR]      = (unsigned long)data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_CRE_WOUNDED_OFFICER,         data);                  
    woundedCrew_[CREW_OFFICER]     = (unsigned long)data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_CRE_WOUNDED_ENGINEER,        data);                  
    woundedCrew_[CREW_ENGINEER]    = (unsigned long)data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_CRE_WOUNDED_PILOT,           data);                  
    woundedCrew_[CREW_PILOT]       = (unsigned long)data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_CRE_WOUNDED_SCIENTIST,       data);                  
    woundedCrew_[CREW_SCIENTIST]   = (unsigned long)data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_CRE_WOUNDED_PASSENGER,       data);                  
    woundedCrew_[CREW_PASSENGER]   = (unsigned long)data;
}

// --------------------------------

void cloakingClass :: __internal_DB_Load(  IBPP :: Statement& s )
{
    // CLO 
    int64_t data;

    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_CLO_CLOAKINGDEVICE,             data);                  
    cloakingDeviceID_ = (dtIdentifier) data;
    __load_powerStateClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_CLO_PSC_STATE,
        DB_INDEX_FORTRESS_SELECT_QUERY_CLO_PSC_CHARGING, cloakingPowerState);
    __load_energyDivisionClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_CLO_EDC_PRIORITY,
        DB_INDEX_FORTRESS_SELECT_QUERY_CLO_EDC_RATIO, DB_INDEX_FORTRESS_SELECT_QUERY_CLO_EDC_MPD,
        DB_INDEX_FORTRESS_SELECT_QUERY_CLO_EDC_SDOEL, cloakingEnergyDivision);
}

// --------------------------------

void sensorsClass :: __internal_DB_Load(  IBPP :: Statement& s )
{
    // SEN 
    int64_t data;

    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_SEN_HIRESSENSORS,             data);                  
    highResolutionSensorsID_ = (dtIdentifier) data;
    __load_powerStateClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_SEN_PSC1_STATE,
        DB_INDEX_FORTRESS_SELECT_QUERY_SEN_PSC1_CHARGING, sensorsHRPowerState);
    __load_energyDivisionClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_SEN_EDC1_PRIORITY,
        DB_INDEX_FORTRESS_SELECT_QUERY_SEN_EDC1_RATIO, DB_INDEX_FORTRESS_SELECT_QUERY_SEN_EDC1_MPD,
        DB_INDEX_FORTRESS_SELECT_QUERY_SEN_EDC1_SDOEL, sensorsHREnergyDivision);

    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_SEN_LONGRANGESENSORS,         data);                  
    longRangeSensorsID_ = (dtIdentifier) data;
    __load_powerStateClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_SEN_PSC2_STATE,
        DB_INDEX_FORTRESS_SELECT_QUERY_SEN_PSC2_CHARGING, sensorsLRPowerState);
    __load_energyDivisionClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_SEN_EDC2_PRIORITY,
        DB_INDEX_FORTRESS_SELECT_QUERY_SEN_EDC2_RATIO, DB_INDEX_FORTRESS_SELECT_QUERY_SEN_EDC2_MPD,
        DB_INDEX_FORTRESS_SELECT_QUERY_SEN_EDC2_SDOEL, sensorsLREnergyDivision);
}

// --------------------------------


void probeDevicesClass :: __internal_DB_Load( dtIdentifier ID, IBPP :: Statement& s )
{
    // PRO 
    __load_dtIdentifiersList_from_dblist(ID, actx->db.getPRO_PROBES_fortress_list(), probesIDs_);
}

// --------------------------------

void miningDevicesClass :: __internal_DB_Load(  IBPP :: Statement& s )
{
    // MIN 
    int64_t data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_MIN_MAGCOLLECTORS,      data);                  
    magneticalCollectorsOfPlasmaID_ = (dtIdentifier) data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_MIN_FILTRATIONTANK,     data);                  
    submersibleFiltrationTankID_    = (dtIdentifier) data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_MIN_MININGMACHINE,      data);                  
    submarineMiningMachineID_       = (dtIdentifier) data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_MIN_DRILLINGMACHINE,    data);                  
    undergroundDrillingMachineID_   = (dtIdentifier) data;

    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_MIN_QGQUARRYING, quarkGluonPlasmaQuarrying_);
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_MIN_DEQUARRYING, heavyWaterQuarrying_);
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_MIN_ZCQUARRYING, zirconiumCrystalQuarrying_);
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_MIN_ILQUARRYING, ilmeniteQuarrying_);
}

// --------------------------------

void transportBeamClass :: __internal_DB_Load(  IBPP :: Statement& s )
{
    // TBM 
    int64_t data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_TBM_GENERATOR,      data);                  
    transportBeamGeneratorID_ = (dtIdentifier) data;
    __load_energyStateClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_TBM_ESC_ENERGY,
        DB_INDEX_FORTRESS_SELECT_QUERY_TBM_ESC_TENERGY, tBeamEnergyState);
    __load_energyDivisionClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_TBM_EDC_PRIORITY,
        DB_INDEX_FORTRESS_SELECT_QUERY_TBM_EDC_RATIO, DB_INDEX_FORTRESS_SELECT_QUERY_TBM_EDC_MPD,
        DB_INDEX_FORTRESS_SELECT_QUERY_TBM_EDC_SDOEL, tBeamEnergyDivision);
}

// --------------------------------

void weaponsClass :: __internal_DB_Load( dtIdentifier ID, IBPP :: Statement& s )
{
    // DEF 
    int64_t data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_WEP_ENERGYCIRCUIT,      data);                  
    weaponEnergyCircuitID_ = (dtIdentifier) data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_WEP_DRONEMISSILES,      data);                  
    droneMissilesID_ = (dtIdentifier) data;
    __load_energyDivisionClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_WEP_EDC_PRIORITY,
        DB_INDEX_FORTRESS_SELECT_QUERY_WEP_EDC_RATIO, DB_INDEX_FORTRESS_SELECT_QUERY_WEP_EDC_MPD,
        DB_INDEX_FORTRESS_SELECT_QUERY_WEP_EDC_SDOEL, weaponsEnergyDivision);
    __load_dtIdentifiersESList_from_dblist(ID, actx->db.getWEP_DRONE_fortress_list(), droneMissileLaunchersIDs_);
    __load_dtIdentifiersESList_from_dblist(ID, actx->db.getWEP_LASER_fortress_list(), laserGunsIDs_);
}

// --------------------------------

void deflectorShieldsClass :: __internal_DB_Load(  IBPP :: Statement& s )
{
    // DEF 
    int64_t data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_DEF_SHIELDGENERATOR,      data);                  
    deflectorShieldsGeneratorID_ = (dtIdentifier) data;
    __load_energyStateClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_DEF_ESC1_ENERGY,
        DB_INDEX_FORTRESS_SELECT_QUERY_DEF_ESC1_TENERGY, deflectorShieldsEnergyState);
    __load_energyDivisionClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_DEF_EDC_PRIORITY,
        DB_INDEX_FORTRESS_SELECT_QUERY_DEF_EDC_RATIO, DB_INDEX_FORTRESS_SELECT_QUERY_DEF_EDC_MPD,
        DB_INDEX_FORTRESS_SELECT_QUERY_DEF_EDC_SDOEL, deflectorsEnergyDivision);
}

// --------------------------------

void energeticSystemClass :: __internal_DB_Load(  IBPP :: Statement& s )
{
    // ENE 
    int64_t data;
    s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_ENE_ACCUMULATOR,      data);                  
    energeticAccumulatorID_  = (dtIdentifier) data;
    __load_energyStateClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_ENE_ESC_ENERGY,
        DB_INDEX_FORTRESS_SELECT_QUERY_ENE_ESC_TENERGY, energeticAccumulatorEnergyState);
}

// --------------------------------
// --------------------------------

void factoriesClass :: __internal_DB_Insert(  IBPP :: Statement& s )
{
    // FAC 

    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_FAC_MAGNETICALFILTER,         (int64_t)magneticalFilterID_);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_FAC_DEUTERIUMDECOMP,          (int64_t)deuteriumDecomposerID_);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_FAC_ZIRCONIUMREACTOR,         (int64_t)zirconiumReactorID_);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_FAC_ILMENITEFURNACE,          (int64_t)ilmeniteFurnaceID_);                  
}

// --------------------------------

void hangarsPortClass :: __internal_DB_Insert( dtIdentifier ID, IBPP :: Statement& s )
{
    // HAN 
    __store_dtIdentifiersList_to_dblist(ID, actx->db.getHAN_HANGARS_fortress_list(), hangarsIDs_);
}

// --------------------------------

void impulsDriveClass :: __internal_DB_Insert(  IBPP :: Statement& s )
{
    // IMP 

    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_IMP_JETENGINE,         (int64_t)impulsJetEngineID_);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_IMP_MECHDAMPERS,       (int64_t)mechanicalDampersID_);   
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_IMP_ACTUALFORCE,       (int64_t)actualJetForce_);
}

// --------------------------------

void subspaceDriveClass :: __internal_DB_Insert(  IBPP :: Statement& s )
{
    // SUB 

    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_SUB_COMPUTER,         (int64_t)navigationComputerID_);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_SUB_QGCORE,           (int64_t)quarkGluonCoreID_);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_SUB_BEACON,           (int64_t)subspaceBeaconID_);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_SUB_DAMPERS,          (int64_t)inertialDampersID_);   
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_SUB_ACTUALSPEEDTOC,   actualSpeedToC_);
}

// --------------------------------

void mainframeSystemClass :: __internal_DB_Insert(  IBPP :: Statement& s )
{
    // MAI 

    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_MAI_MAINFRAME,         (int64_t)mainframeID_);                  

    __store_energyDivisionClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_MAI_EDC_PRIORITY,
        DB_INDEX_FORTRESS_INSERT_QUERY_MAI_EDC_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_MAI_EDC_MPD,
        DB_INDEX_FORTRESS_INSERT_QUERY_MAI_EDC_SDOEL, mainframeEnergyDivision);
}

// --------------------------------

void otherEquipmentClass :: __internal_DB_Insert(  IBPP :: Statement& s )
{
    // WAR 

    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_OTH_PLASMAFILTER,         (int64_t)plasmaFilterID_);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_OTH_LABS,                 (int64_t)scientificLabID_);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_OTH_LIFESUPPORT,          (int64_t)lifeSupportID_);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_OTH_TRANSMITTER,          (int64_t)subspaceTransmitterID_);                  

    __store_energyDivisionClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_OTH_EDC_PRIORITY,
        DB_INDEX_FORTRESS_INSERT_QUERY_OTH_EDC_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_OTH_EDC_MPD,
        DB_INDEX_FORTRESS_INSERT_QUERY_OTH_EDC_SDOEL, lifeSupportEnergyDivision);
}

// --------------------------------

void warehouseClass :: __internal_DB_Insert( dtIdentifier ID, IBPP :: Statement& s )
{
    // WAR 

    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_WAR_MAGNETICALGRID,         (int64_t)magneticalGridID_);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_WAR_CONTAINER,              (int64_t)transportContainerID_);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_WAR_ENERGETICCELL,          (int64_t)energeticCellID_);  

    __store_dtIdentifiersList_to_dblist(ID, actx->db.getWAR_STORAGE_fortress_list(), storageIDs_);
}

// --------------------------------

void mechanicsClass :: __internal_DB_Insert(  IBPP :: Statement& s )
{
    // MEC 

    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_MEC_ANDROIDS,             (int64_t)androidsID_); 
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_MEC_MAX_WORK_ANDR,        (int64_t)maxWorkingAndroids_);             
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_MEC_MAX_REPA_ANDR,        (int64_t)maxRepairingAndroids_);          
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_MEC_ACT_REPA_ANDR,        (int64_t)actualRepairingAndroids_);          
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_MEC_ACT_CONS_ANDR,        (int64_t)actualConstructingAndroids_);     
    __store_powerStateClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_MEC_PSC_STATE,
        DB_INDEX_FORTRESS_INSERT_QUERY_MEC_PSC_CHARGING, androidsPowerState);
    __store_energyDivisionClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_MEC_EDC_PRIORITY,
        DB_INDEX_FORTRESS_INSERT_QUERY_MEC_EDC_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_MEC_EDC_MPD,
        DB_INDEX_FORTRESS_INSERT_QUERY_MEC_EDC_SDOEL, androidsEnergyDivision);
}

// --------------------------------

void accommodationsClass :: __internal_DB_Insert(  IBPP :: Statement& s )
{
    // ACC 

    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_ACC_LUXURYAPARTMENTS,             (int64_t)luxuryApartments_);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_ACC_COMFORTABLEROOMS,             (int64_t)comfortableRooms_);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_ACC_COMMONCABINS,                 (int64_t)commonCabins_);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_ACC_WAREHOUSES,                   (int64_t)warehousesWithLifeSupport_);                  
}

// --------------------------------

void crewClass :: __internal_DB_Insert(  IBPP :: Statement& s )
{
    // CRE 

    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_CRE_CREW_CAPITAN,             (int64_t)ableCrew_[CREW_CAPITAN]);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_CRE_CREW_DOCTOR,              (int64_t)ableCrew_[CREW_DOCTOR]);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_CRE_CREW_OFFICER,             (int64_t)ableCrew_[CREW_OFFICER]);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_CRE_CREW_ENGINEER,            (int64_t)ableCrew_[CREW_ENGINEER]);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_CRE_CREW_PILOT,               (int64_t)ableCrew_[CREW_PILOT]);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_CRE_CREW_SCIENTIST,           (int64_t)ableCrew_[CREW_SCIENTIST]);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_CRE_CREW_PASSENGER,           (int64_t)ableCrew_[CREW_PASSENGER]);                  

    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_CRE_WOUNDED_CAPITAN,          (int64_t)woundedCrew_[CREW_CAPITAN]);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_CRE_WOUNDED_DOCTOR,           (int64_t)woundedCrew_[CREW_DOCTOR]);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_CRE_WOUNDED_OFFICER,          (int64_t)woundedCrew_[CREW_OFFICER]);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_CRE_WOUNDED_ENGINEER,         (int64_t)woundedCrew_[CREW_ENGINEER]);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_CRE_WOUNDED_PILOT,            (int64_t)woundedCrew_[CREW_PILOT]);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_CRE_WOUNDED_SCIENTIST,        (int64_t)woundedCrew_[CREW_SCIENTIST]);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_CRE_WOUNDED_PASSENGER,        (int64_t)woundedCrew_[CREW_PASSENGER]);                  
}

// --------------------------------

void cloakingClass :: __internal_DB_Insert(  IBPP :: Statement& s )
{
    // CLO 

    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_CLO_CLOAKINGDEVICE,             (int64_t)cloakingDeviceID_);                  
    __store_powerStateClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_CLO_PSC_STATE,
        DB_INDEX_FORTRESS_INSERT_QUERY_CLO_PSC_CHARGING, cloakingPowerState);
    __store_energyDivisionClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_CLO_EDC_PRIORITY,
        DB_INDEX_FORTRESS_INSERT_QUERY_CLO_EDC_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_CLO_EDC_MPD,
        DB_INDEX_FORTRESS_INSERT_QUERY_CLO_EDC_SDOEL, cloakingEnergyDivision);
}

// --------------------------------

void sensorsClass :: __internal_DB_Insert(  IBPP :: Statement& s )
{
    // SEN 

    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_SEN_HIRESSENSORS,             (int64_t)highResolutionSensorsID_);                  
    __store_powerStateClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_SEN_PSC1_STATE,
        DB_INDEX_FORTRESS_INSERT_QUERY_SEN_PSC1_CHARGING, sensorsHRPowerState);
    __store_energyDivisionClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_SEN_EDC1_PRIORITY,
        DB_INDEX_FORTRESS_INSERT_QUERY_SEN_EDC1_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_SEN_EDC1_MPD,
        DB_INDEX_FORTRESS_INSERT_QUERY_SEN_EDC1_SDOEL, sensorsHREnergyDivision);

    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_SEN_LONGRANGESENSORS,         (int64_t)longRangeSensorsID_);                  
    __store_powerStateClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_SEN_PSC2_STATE,
        DB_INDEX_FORTRESS_INSERT_QUERY_SEN_PSC2_CHARGING, sensorsLRPowerState);
    __store_energyDivisionClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_SEN_EDC2_PRIORITY,
        DB_INDEX_FORTRESS_INSERT_QUERY_SEN_EDC2_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_SEN_EDC2_MPD,
        DB_INDEX_FORTRESS_INSERT_QUERY_SEN_EDC2_SDOEL, sensorsLREnergyDivision);
}

// --------------------------------


void probeDevicesClass :: __internal_DB_Insert( dtIdentifier ID, IBPP :: Statement& s )
{
    // PRO 
    __store_dtIdentifiersList_to_dblist(ID, actx->db.getPRO_PROBES_fortress_list(), probesIDs_);
}

// --------------------------------

void miningDevicesClass :: __internal_DB_Insert(  IBPP :: Statement& s )
{
    // MIN 
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_MIN_MAGCOLLECTORS,      (int64_t)magneticalCollectorsOfPlasmaID_);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_MIN_FILTRATIONTANK,     (int64_t)submersibleFiltrationTankID_);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_MIN_MININGMACHINE,      (int64_t)submarineMiningMachineID_);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_MIN_DRILLINGMACHINE,    (int64_t)undergroundDrillingMachineID_);                  

    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_MIN_QGQUARRYING, quarkGluonPlasmaQuarrying_);
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_MIN_DEQUARRYING, heavyWaterQuarrying_);
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_MIN_ZCQUARRYING, zirconiumCrystalQuarrying_);
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_MIN_ILQUARRYING, ilmeniteQuarrying_);
}

// --------------------------------

void transportBeamClass :: __internal_DB_Insert(  IBPP :: Statement& s )
{
    // TBM 
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_TBM_GENERATOR,      (int64_t)transportBeamGeneratorID_);                  
    __store_energyStateClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_TBM_ESC_ENERGY,
        DB_INDEX_FORTRESS_INSERT_QUERY_TBM_ESC_TENERGY, tBeamEnergyState);
    __store_energyDivisionClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_TBM_EDC_PRIORITY,
        DB_INDEX_FORTRESS_INSERT_QUERY_TBM_EDC_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_TBM_EDC_MPD,
        DB_INDEX_FORTRESS_INSERT_QUERY_TBM_EDC_SDOEL, tBeamEnergyDivision);
}

// --------------------------------

void weaponsClass :: __internal_DB_Insert( dtIdentifier ID, IBPP :: Statement& s )
{
    // DEF 
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_WEP_ENERGYCIRCUIT,      (int64_t)weaponEnergyCircuitID_);                  
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_WEP_DRONEMISSILES,      (int64_t)droneMissilesID_);                  
    __store_energyDivisionClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_WEP_EDC_PRIORITY,
        DB_INDEX_FORTRESS_INSERT_QUERY_WEP_EDC_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_WEP_EDC_MPD,
        DB_INDEX_FORTRESS_INSERT_QUERY_WEP_EDC_SDOEL, weaponsEnergyDivision);
    __store_dtIdentifiersESList_to_dblist(ID, actx->db.getWEP_DRONE_fortress_list(), droneMissileLaunchersIDs_);
    __store_dtIdentifiersESList_to_dblist(ID, actx->db.getWEP_LASER_fortress_list(), laserGunsIDs_);
}

// --------------------------------

void deflectorShieldsClass :: __internal_DB_Insert(  IBPP :: Statement& s )
{
    // DEF 
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_DEF_SHIELDGENERATOR,     (int64_t)deflectorShieldsGeneratorID_);                  
    __store_energyStateClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_DEF_ESC1_ENERGY,
        DB_INDEX_FORTRESS_INSERT_QUERY_DEF_ESC1_TENERGY, deflectorShieldsEnergyState);
    __store_energyDivisionClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_DEF_EDC_PRIORITY,
        DB_INDEX_FORTRESS_INSERT_QUERY_DEF_EDC_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_DEF_EDC_MPD,
        DB_INDEX_FORTRESS_INSERT_QUERY_DEF_EDC_SDOEL, deflectorsEnergyDivision);
}

// --------------------------------

void energeticSystemClass :: __internal_DB_Insert(  IBPP :: Statement& s )
{
    // ENE 
    s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_ENE_ACCUMULATOR,      (int64_t)energeticAccumulatorID_);                  
    __store_energyStateClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_ENE_ESC_ENERGY,
        DB_INDEX_FORTRESS_INSERT_QUERY_ENE_ESC_TENERGY, energeticAccumulatorEnergyState);
}

// --------------------------------
// --------------------------------

// --------------------------------

void factoriesClass :: __internal_DB_Save(  IBPP :: Statement& s )
{
    // FAC 

    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_FAC_MAGNETICALFILTER,         (int64_t)magneticalFilterID_);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_FAC_DEUTERIUMDECOMP,          (int64_t)deuteriumDecomposerID_);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_FAC_ZIRCONIUMREACTOR,         (int64_t)zirconiumReactorID_);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_FAC_ILMENITEFURNACE,          (int64_t)ilmeniteFurnaceID_);                  
}

// --------------------------------

void hangarsPortClass :: __internal_DB_Save( dtIdentifier ID, IBPP :: Statement& s )
{
    // HAN 
    __store_dtIdentifiersList_to_dblist(ID, actx->db.getHAN_HANGARS_fortress_list(), hangarsIDs_);
}

// --------------------------------

void impulsDriveClass :: __internal_DB_Save(  IBPP :: Statement& s )
{
    // IMP 

    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_IMP_JETENGINE,         (int64_t)impulsJetEngineID_);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_IMP_MECHDAMPERS,       (int64_t)mechanicalDampersID_);  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_IMP_ACTUALFORCE,       (int64_t)actualJetForce_);
}

// --------------------------------

void subspaceDriveClass :: __internal_DB_Save(  IBPP :: Statement& s )
{
    // SUB 

    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_SUB_COMPUTER,         (int64_t)navigationComputerID_);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_SUB_QGCORE,           (int64_t)quarkGluonCoreID_);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_SUB_BEACON,           (int64_t)subspaceBeaconID_);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_SUB_DAMPERS,          (int64_t)inertialDampersID_);  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_SUB_ACTUALSPEEDTOC,   actualSpeedToC_);
}

// --------------------------------

void mainframeSystemClass :: __internal_DB_Save(  IBPP :: Statement& s )
{
    // MAI 

    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_MAI_MAINFRAME,         (int64_t)mainframeID_);                  

    __store_energyDivisionClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_MAI_EDC_PRIORITY,
        DB_INDEX_FORTRESS_UPDATE_QUERY_MAI_EDC_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_MAI_EDC_MPD,
        DB_INDEX_FORTRESS_UPDATE_QUERY_MAI_EDC_SDOEL, mainframeEnergyDivision);
}

// --------------------------------

void otherEquipmentClass :: __internal_DB_Save(  IBPP :: Statement& s )
{
    // WAR 

    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_OTH_PLASMAFILTER,         (int64_t)plasmaFilterID_);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_OTH_LABS,                 (int64_t)scientificLabID_);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_OTH_LIFESUPPORT,          (int64_t)lifeSupportID_);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_OTH_TRANSMITTER,          (int64_t)subspaceTransmitterID_);                  

    __store_energyDivisionClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_OTH_EDC_PRIORITY,
        DB_INDEX_FORTRESS_UPDATE_QUERY_OTH_EDC_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_OTH_EDC_MPD,
        DB_INDEX_FORTRESS_UPDATE_QUERY_OTH_EDC_SDOEL, lifeSupportEnergyDivision);
}

// --------------------------------

void warehouseClass :: __internal_DB_Save( dtIdentifier ID, IBPP :: Statement& s )
{
    // WAR 

    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_WAR_MAGNETICALGRID,         (int64_t)magneticalGridID_);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_WAR_CONTAINER,              (int64_t)transportContainerID_);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_WAR_ENERGETICCELL,          (int64_t)energeticCellID_); 

    __store_dtIdentifiersList_to_dblist(ID, actx->db.getWAR_STORAGE_fortress_list(), storageIDs_);
}

// --------------------------------

void mechanicsClass :: __internal_DB_Save(  IBPP :: Statement& s )
{
    // MEC 

    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_MEC_ANDROIDS,             (int64_t)androidsID_); 
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_MEC_MAX_WORK_ANDR,        (int64_t)maxWorkingAndroids_);             
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_MEC_MAX_REPA_ANDR,        (int64_t)maxRepairingAndroids_);          
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_MEC_ACT_REPA_ANDR,        (int64_t)actualRepairingAndroids_);          
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_MEC_ACT_CONS_ANDR,        (int64_t)actualConstructingAndroids_);       
    __store_powerStateClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_MEC_PSC_STATE,
        DB_INDEX_FORTRESS_UPDATE_QUERY_MEC_PSC_CHARGING, androidsPowerState);
    __store_energyDivisionClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_MEC_EDC_PRIORITY,
        DB_INDEX_FORTRESS_UPDATE_QUERY_MEC_EDC_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_MEC_EDC_MPD,
        DB_INDEX_FORTRESS_UPDATE_QUERY_MEC_EDC_SDOEL, androidsEnergyDivision);
}

// --------------------------------

void accommodationsClass :: __internal_DB_Save(  IBPP :: Statement& s )
{
    // ACC 

    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_ACC_LUXURYAPARTMENTS,             (int64_t)luxuryApartments_);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_ACC_COMFORTABLEROOMS,             (int64_t)comfortableRooms_);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_ACC_COMMONCABINS,                 (int64_t)commonCabins_);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_ACC_WAREHOUSES,                   (int64_t)warehousesWithLifeSupport_);                  
}

// --------------------------------

void crewClass :: __internal_DB_Save(  IBPP :: Statement& s )
{
    // CRE 

    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_CRE_CREW_CAPITAN,             (int64_t)ableCrew_[CREW_CAPITAN]);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_CRE_CREW_DOCTOR,              (int64_t)ableCrew_[CREW_DOCTOR]);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_CRE_CREW_OFFICER,             (int64_t)ableCrew_[CREW_OFFICER]);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_CRE_CREW_ENGINEER,            (int64_t)ableCrew_[CREW_ENGINEER]);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_CRE_CREW_PILOT,               (int64_t)ableCrew_[CREW_PILOT]);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_CRE_CREW_SCIENTIST,           (int64_t)ableCrew_[CREW_SCIENTIST]);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_CRE_CREW_PASSENGER,           (int64_t)ableCrew_[CREW_PASSENGER]);                  

    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_CRE_WOUNDED_CAPITAN,          (int64_t)woundedCrew_[CREW_CAPITAN]);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_CRE_WOUNDED_DOCTOR,           (int64_t)woundedCrew_[CREW_DOCTOR]);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_CRE_WOUNDED_OFFICER,          (int64_t)woundedCrew_[CREW_OFFICER]);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_CRE_WOUNDED_ENGINEER,         (int64_t)woundedCrew_[CREW_ENGINEER]);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_CRE_WOUNDED_PILOT,            (int64_t)woundedCrew_[CREW_PILOT]);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_CRE_WOUNDED_SCIENTIST,        (int64_t)woundedCrew_[CREW_SCIENTIST]);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_CRE_WOUNDED_PASSENGER,        (int64_t)woundedCrew_[CREW_PASSENGER]);                  
}

// --------------------------------

void cloakingClass :: __internal_DB_Save(  IBPP :: Statement& s )
{
    // CLO 

    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_CLO_CLOAKINGDEVICE,             (int64_t)cloakingDeviceID_);                  
    __store_powerStateClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_CLO_PSC_STATE,
        DB_INDEX_FORTRESS_UPDATE_QUERY_CLO_PSC_CHARGING, cloakingPowerState);
    __store_energyDivisionClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_CLO_EDC_PRIORITY,
        DB_INDEX_FORTRESS_UPDATE_QUERY_CLO_EDC_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_CLO_EDC_MPD,
        DB_INDEX_FORTRESS_UPDATE_QUERY_CLO_EDC_SDOEL, cloakingEnergyDivision);
}

// --------------------------------

void sensorsClass :: __internal_DB_Save(  IBPP :: Statement& s )
{
    // SEN 

    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_SEN_HIRESSENSORS,             (int64_t)highResolutionSensorsID_);                  
    __store_powerStateClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_SEN_PSC1_STATE,
        DB_INDEX_FORTRESS_UPDATE_QUERY_SEN_PSC1_CHARGING, sensorsHRPowerState);
    __store_energyDivisionClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_SEN_EDC1_PRIORITY,
        DB_INDEX_FORTRESS_UPDATE_QUERY_SEN_EDC1_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_SEN_EDC1_MPD,
        DB_INDEX_FORTRESS_UPDATE_QUERY_SEN_EDC1_SDOEL, sensorsHREnergyDivision);

    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_SEN_LONGRANGESENSORS,         (int64_t)longRangeSensorsID_);                  
    __store_powerStateClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_SEN_PSC2_STATE,
        DB_INDEX_FORTRESS_UPDATE_QUERY_SEN_PSC2_CHARGING, sensorsLRPowerState);
    __store_energyDivisionClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_SEN_EDC2_PRIORITY,
        DB_INDEX_FORTRESS_UPDATE_QUERY_SEN_EDC2_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_SEN_EDC2_MPD,
        DB_INDEX_FORTRESS_UPDATE_QUERY_SEN_EDC2_SDOEL, sensorsLREnergyDivision);
}

// --------------------------------


void probeDevicesClass :: __internal_DB_Save( dtIdentifier ID, IBPP :: Statement& s )
{
    // PRO 
    __store_dtIdentifiersList_to_dblist(ID, actx->db.getPRO_PROBES_fortress_list(), probesIDs_);
}

// --------------------------------

void miningDevicesClass :: __internal_DB_Save(  IBPP :: Statement& s )
{
    // MIN 
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_MIN_MAGCOLLECTORS,      (int64_t)magneticalCollectorsOfPlasmaID_);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_MIN_FILTRATIONTANK,     (int64_t)submersibleFiltrationTankID_);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_MIN_MININGMACHINE,      (int64_t)submarineMiningMachineID_);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_MIN_DRILLINGMACHINE,    (int64_t)undergroundDrillingMachineID_);                  

    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_MIN_QGQUARRYING, quarkGluonPlasmaQuarrying_);
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_MIN_DEQUARRYING, heavyWaterQuarrying_);
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_MIN_ZCQUARRYING, zirconiumCrystalQuarrying_);
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_MIN_ILQUARRYING, ilmeniteQuarrying_);
}

// --------------------------------

void transportBeamClass :: __internal_DB_Save(  IBPP :: Statement& s )
{
    // TBM 
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_TBM_GENERATOR,      (int64_t)transportBeamGeneratorID_);                  
    __store_energyStateClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_TBM_ESC_ENERGY,
        DB_INDEX_FORTRESS_UPDATE_QUERY_TBM_ESC_TENERGY, tBeamEnergyState);
    __store_energyDivisionClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_TBM_EDC_PRIORITY,
        DB_INDEX_FORTRESS_UPDATE_QUERY_TBM_EDC_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_TBM_EDC_MPD,
        DB_INDEX_FORTRESS_UPDATE_QUERY_TBM_EDC_SDOEL, tBeamEnergyDivision);
}

// --------------------------------

void weaponsClass :: __internal_DB_Save( dtIdentifier ID, IBPP :: Statement& s )
{
    // DEF 
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_WEP_ENERGYCIRCUIT,      (int64_t)weaponEnergyCircuitID_);                  
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_WEP_DRONEMISSILES,      (int64_t)droneMissilesID_);                  
    __store_energyDivisionClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_WEP_EDC_PRIORITY,
        DB_INDEX_FORTRESS_UPDATE_QUERY_WEP_EDC_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_WEP_EDC_MPD,
        DB_INDEX_FORTRESS_UPDATE_QUERY_WEP_EDC_SDOEL, weaponsEnergyDivision);
    __store_dtIdentifiersESList_to_dblist(ID, actx->db.getWEP_DRONE_fortress_list(), droneMissileLaunchersIDs_);
    __store_dtIdentifiersESList_to_dblist(ID, actx->db.getWEP_LASER_fortress_list(), laserGunsIDs_);
}

// --------------------------------

void deflectorShieldsClass :: __internal_DB_Save(  IBPP :: Statement& s )
{
    // DEF 
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_DEF_SHIELDGENERATOR,     (int64_t)deflectorShieldsGeneratorID_);                  
    __store_energyStateClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_DEF_ESC1_ENERGY,
        DB_INDEX_FORTRESS_UPDATE_QUERY_DEF_ESC1_TENERGY, deflectorShieldsEnergyState);
    __store_energyDivisionClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_DEF_EDC_PRIORITY,
        DB_INDEX_FORTRESS_UPDATE_QUERY_DEF_EDC_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_DEF_EDC_MPD,
        DB_INDEX_FORTRESS_UPDATE_QUERY_DEF_EDC_SDOEL, deflectorsEnergyDivision);
}

// --------------------------------

void energeticSystemClass :: __internal_DB_Save(  IBPP :: Statement& s )
{
    // ENE 
    s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_ENE_ACCUMULATOR,      (int64_t)energeticAccumulatorID_);                  
    __store_energyStateClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_ENE_ESC_ENERGY,
        DB_INDEX_FORTRESS_UPDATE_QUERY_ENE_ESC_TENERGY, energeticAccumulatorEnergyState);
}

// --------------------------------
// --------------------------------

void shipClass :: DB_Load(unsigned long ID)
{
	// predpokladame, ze dotaz je pripraveny pro cteni dat
	IBPP :: Statement& s = actx->db.getFortressQuerySELECT();

    try
    {
        // SUB
        subspaceDrive.__internal_DB_Load(s);

        // IMP
        impulsDrive.__internal_DB_Load(s);

        __load_fortressSectionClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_FS_SUB_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_SELECT_QUERY_FS_SUB_ANDR_RATIO, DB_INDEX_FORTRESS_SELECT_QUERY_FS_SUB_ANDR_ASSIGNED_DROIDS,
            subspaceDrive);
        __load_fortressSectionClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_FS_IMP_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_SELECT_QUERY_FS_IMP_ANDR_RATIO, DB_INDEX_FORTRESS_SELECT_QUERY_FS_IMP_ANDR_ASSIGNED_DROIDS,
            impulsDrive);

        int64_t data;
        double floatData;             
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_POSITIONX,                data);          position.x              = (dist_t)data;                          
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_POSITIONY,                data);          position.y              = (dist_t)data;                     
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_COURSEX,                  floatData);     course.x                = floatData;                                 
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_COURSEY,                  floatData);     course.y                = floatData;                              
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_SPEEDNORM,                data);          speedNorm               = (dist_t)data;                       
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_ACCELERATION,             data);          acceleration            = (dist_t)data;                     
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_SPOBJACTUALLYIN,          data);          spaceObjectActuallyIn   = (dtIdentifier)data;                
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_NEARESTSTAR,              data);          nearestStar             = (dtIdentifier)data;                   
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_WESPOBJ,                  data);          wantEnterSpaceObject    = data != 0;                        
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_MOV_STATE,                data);          movementState_          = (shipMovementState)data;
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_MOV_WARP_TARGET_X,        data);          warpTarget_.x           = (dist_t)data;             
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_MOV_WARP_TARGET_Y,        data);          warpTarget_.y           = (dist_t)data;               
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_MOV_WARP_START,           floatData);     warpStart_              = floatData;
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_ENGINE_LIMIT,             floatData);     engineLimit_            = floatData;
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_TARGETSPACEOBJECT,        data);          targetSpaceObject       = (dtIdentifier)data;              
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_TARGETSHIP,               data);          targetShip              = (dtIdentifier)data;                     
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_TARGETPOSITIONX,          data);          targetPosition.x        = (dist_t)data;               
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_TARGETPOSITIONY,          data);          targetPosition.y        = (dist_t)data;                 
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_LASTACTUALIZATION,        floatData);     lastActualization       = floatData;                   
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_SHIPMOVEACTION,           data);          moveAction              = (shipMoveAction)data;                  
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_SHIPMOVETARGET,           data);          moveTarget              = (shipMoveTarget)data;                 
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_GRAVSPEEDNORM,            floatData);     gravitationSpeedNorm    = floatData;
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_STRUCTINTGRAD,            floatData);     structuralIntegrityVoidSection.setGradient(floatData);
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_CONTROLLABLE,             data);          controllable_           = data != 0;
        
    }
	catch (IBPP :: Exception& e)
	{
		errExceptionError( e.what());
	}

    fortressClass :: DB_Load(ID);
};

// --------------------------------

void shipClass :: DB_Insert(unsigned long ID)
{
	/* uloz data lodi */
	IBPP :: Statement& s = actx->db.getFortressQueryINSERT();

	try
	{
        // SUB
        subspaceDrive.__internal_DB_Insert(s);

        // IMP
        impulsDrive.__internal_DB_Insert(s);

        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_FS_SUB_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_INSERT_QUERY_FS_SUB_ANDR_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_FS_SUB_ANDR_ASSIGNED_DROIDS,
            subspaceDrive);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_FS_IMP_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_INSERT_QUERY_FS_IMP_ANDR_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_FS_IMP_ANDR_ASSIGNED_DROIDS,
            impulsDrive);
        __store_fortressSectionClassNULL_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_FS_HAN_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_INSERT_QUERY_FS_HAN_ANDR_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_FS_HAN_ANDR_ASSIGNED_DROIDS);
        __store_fortressSectionClassNULL_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_FS_FAC_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_INSERT_QUERY_FS_FAC_ANDR_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_FS_FAC_ANDR_ASSIGNED_DROIDS);

        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_POSITIONX,                position.x);
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_POSITIONY,                position.y);
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_COURSEX,                  course.x);
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_COURSEY,                  course.y);
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_SPEEDNORM,                speedNorm);
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_ACCELERATION,             acceleration);
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_SPOBJACTUALLYIN,          (int64_t)spaceObjectActuallyIn);
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_NEARESTSTAR,              (int64_t)nearestStar);
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_WESPOBJ,                  wantEnterSpaceObject ? 1 : 0);
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_MOV_STATE,                movementState_);
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_MOV_WARP_TARGET_X,        warpTarget_.x);
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_MOV_WARP_TARGET_Y,        warpTarget_.y);
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_MOV_WARP_START,           warpStart_);
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_ENGINE_LIMIT,             engineLimit_);
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_TARGETSPACEOBJECT,        (int64_t)targetSpaceObject);
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_TARGETSHIP,               (int64_t)targetShip);
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_TARGETPOSITIONX,          targetPosition.x);
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_TARGETPOSITIONY,          targetPosition.y);
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_LASTACTUALIZATION,        lastActualization);
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_SHIPMOVEACTION,           moveAction);
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_SHIPMOVETARGET,           moveTarget);
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_GRAVSPEEDNORM,            gravitationSpeedNorm);
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_STRUCTINTGRAD,            structuralIntegrityVoidSection.getGradient());  
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_CONTROLLABLE,             (int64_t)(controllable_ ? 1 : 0)                     );

        s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_BUILDING_PTS);

		s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_FAC_MAGNETICALFILTER);    
		s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_FAC_DEUTERIUMDECOMP);
		s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_FAC_ZIRCONIUMREACTOR);
		s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_FAC_ILMENITEFURNACE);

		fortressClass :: DB_Insert(ID);
	
		s->Execute();
	}
	catch (IBPP :: Exception& e)
	{
		errExceptionError( e.what());
	}
}

// --------------------------------

void shipClass :: DB_Save(unsigned long ID)
{
	/* uloz data lodi */
	IBPP :: Statement& s = actx->db.getFortressQueryUPDATE();

	try
	{
        // SUB
        subspaceDrive.__internal_DB_Save(s);

        // IMP
        impulsDrive.__internal_DB_Save(s);

        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_SUB_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_UPDATE_QUERY_FS_SUB_ANDR_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_SUB_ANDR_ASSIGNED_DROIDS,
            subspaceDrive);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_IMP_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_UPDATE_QUERY_FS_IMP_ANDR_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_IMP_ANDR_ASSIGNED_DROIDS,
            impulsDrive);
        __store_fortressSectionClassNULL_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_HAN_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_UPDATE_QUERY_FS_HAN_ANDR_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_HAN_ANDR_ASSIGNED_DROIDS);
        __store_fortressSectionClassNULL_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_FAC_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_UPDATE_QUERY_FS_FAC_ANDR_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_FAC_ANDR_ASSIGNED_DROIDS);

        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_POSITIONX,                position.x);
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_POSITIONY,                position.y);
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_COURSEX,                  course.x);
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_COURSEY,                  course.y);
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_SPEEDNORM,                speedNorm);
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_ACCELERATION,             acceleration);
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_SPOBJACTUALLYIN,          (int64_t)spaceObjectActuallyIn);
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_NEARESTSTAR,              (int64_t)nearestStar);
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_WESPOBJ,                  wantEnterSpaceObject ? 1 : 0);
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_MOV_STATE,                movementState_);
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_MOV_WARP_TARGET_X,        warpTarget_.x);
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_MOV_WARP_TARGET_Y,        warpTarget_.y);
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_MOV_WARP_START,           warpStart_);
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_ENGINE_LIMIT,             engineLimit_);
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_TARGETSPACEOBJECT,        (int64_t)targetSpaceObject);
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_TARGETSHIP,               (int64_t)targetShip);
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_TARGETPOSITIONX,          targetPosition.x);
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_TARGETPOSITIONY,          targetPosition.y);
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_LASTACTUALIZATION,        lastActualization);
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_SHIPMOVEACTION,           moveAction);
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_SHIPMOVETARGET,           moveTarget);
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_GRAVSPEEDNORM,            gravitationSpeedNorm);
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_STRUCTINTGRAD,            structuralIntegrityVoidSection.getGradient());  
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_CONTROLLABLE,             (int64_t)(controllable_ ? 1 : 0)                     );

        s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_BUILDING_PTS);

		s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_FAC_MAGNETICALFILTER);    
		s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_FAC_DEUTERIUMDECOMP);
		s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_FAC_ZIRCONIUMREACTOR);
		s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_FAC_ILMENITEFURNACE);

		fortressClass :: DB_Save(ID);
	
		s->Execute();
	}
	catch (IBPP :: Exception& e)
	{
		errExceptionError( e.what());
	}
};

// --------------------------------

void baseClass :: DB_Load(unsigned long ID)
{
	// predpokladame, ze dotaz je pripraveny pro cteni dat
	IBPP :: Statement& s = actx->db.getFortressQuerySELECT();

    try
    {
        // HAN
        hangarsPort.__internal_DB_Load(ID, s);

        // FAC
        factories.__internal_DB_Load(s);

        __load_fortressSectionClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_FS_HAN_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_SELECT_QUERY_FS_HAN_ANDR_RATIO, DB_INDEX_FORTRESS_SELECT_QUERY_FS_HAN_ANDR_ASSIGNED_DROIDS,
            hangarsPort);
        __load_fortressSectionClass_from_query(s, DB_INDEX_FORTRESS_SELECT_QUERY_FS_FAC_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_SELECT_QUERY_FS_FAC_ANDR_RATIO, DB_INDEX_FORTRESS_SELECT_QUERY_FS_FAC_ANDR_ASSIGNED_DROIDS,
            factories);

        double floatData;
        int64_t data;
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_STRUCTINTGRAD,        floatData);          structuralIntegrityVoidSection.setGradient(floatData);
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_CONTROLLABLE,              data);          controllable_           = data != 0;
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_SPOBJACTUALLYIN,           data);          spaceObjectId_          = (dtIdentifier)data;
        s->Get(DB_INDEX_FORTRESS_SELECT_QUERY_BUILDING_PTS,              data);          buildingPoints_         = (unsigned long long)data;
    }
	catch (IBPP :: Exception& e)
	{
		errExceptionError( e.what());
	}

    fortressClass :: DB_Load(ID);
};

// --------------------------------

void baseClass :: DB_Insert(unsigned long ID)
{
	/* uloz data zakladny */
	IBPP :: Statement& s = actx->db.getFortressQueryINSERT();

	try
	{
        // HAN
        hangarsPort.__internal_DB_Insert(ID, s);

        // FAC
        factories.__internal_DB_Insert(s);

        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_FS_HAN_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_INSERT_QUERY_FS_HAN_ANDR_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_FS_HAN_ANDR_ASSIGNED_DROIDS,
            hangarsPort);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_FS_FAC_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_INSERT_QUERY_FS_FAC_ANDR_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_FS_FAC_ANDR_ASSIGNED_DROIDS,
            factories);
        __store_fortressSectionClassNULL_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_FS_SUB_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_INSERT_QUERY_FS_SUB_ANDR_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_FS_SUB_ANDR_ASSIGNED_DROIDS);
        __store_fortressSectionClassNULL_to_query(s, DB_INDEX_FORTRESS_INSERT_QUERY_FS_IMP_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_INSERT_QUERY_FS_IMP_ANDR_RATIO, DB_INDEX_FORTRESS_INSERT_QUERY_FS_IMP_ANDR_ASSIGNED_DROIDS);

		s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_SUB_COMPUTER);    
		s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_SUB_QGCORE);
		s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_SUB_BEACON);
		s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_SUB_DAMPERS);
        s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_SUB_ACTUALSPEEDTOC);
		s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_IMP_JETENGINE);
		s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_IMP_MECHDAMPERS);
        s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_IMP_ACTUALFORCE);

        s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_POSITIONX);
        s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_POSITIONY);
        s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_COURSEX);
        s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_COURSEY);
        s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_SPEEDNORM);
        s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_ACCELERATION);

        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_SPOBJACTUALLYIN,      (int64_t)spaceObjectId_);

        s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_NEARESTSTAR);
        s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_WESPOBJ);
        s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_MOV_STATE);
        s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_MOV_WARP_TARGET_X);
        s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_MOV_WARP_TARGET_Y);
        s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_MOV_WARP_START);
        s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_ENGINE_LIMIT);
        s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_TARGETSPACEOBJECT);
        s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_TARGETSHIP);
        s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_TARGETPOSITIONX);
        s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_TARGETPOSITIONY);
        s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_LASTACTUALIZATION);
        s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_SHIPMOVEACTION);
        s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_SHIPMOVETARGET);
        s->SetNull(DB_INDEX_FORTRESS_INSERT_QUERY_GRAVSPEEDNORM);

        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_STRUCTINTGRAD,            structuralIntegrityVoidSection.getGradient());  
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_CONTROLLABLE,             (int64_t)(controllable_ ? 1 : 0)                     );
        s->Set(DB_INDEX_FORTRESS_INSERT_QUERY_BUILDING_PTS,             (int64_t)buildingPoints_);

		fortressClass :: DB_Insert(ID);
	
		s->Execute();
	}
	catch (IBPP :: Exception& e)
	{
		errExceptionError( e.what());
	}
};

// --------------------------------

void baseClass :: DB_Save(unsigned long ID)
{
	/* uloz data zakladny */
	IBPP :: Statement& s = actx->db.getFortressQueryUPDATE();

	try
	{
        // HAN
        hangarsPort.__internal_DB_Save(ID, s);

        // FAC
        factories.__internal_DB_Save(s);

        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_HAN_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_UPDATE_QUERY_FS_HAN_ANDR_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_HAN_ANDR_ASSIGNED_DROIDS,
            hangarsPort);
        __store_fortressSectionClass_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_FAC_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_UPDATE_QUERY_FS_FAC_ANDR_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_FAC_ANDR_ASSIGNED_DROIDS,
            factories);
        __store_fortressSectionClassNULL_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_SUB_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_UPDATE_QUERY_FS_SUB_ANDR_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_SUB_ANDR_ASSIGNED_DROIDS);
        __store_fortressSectionClassNULL_to_query(s, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_IMP_ANDR_PRIORITY,
            DB_INDEX_FORTRESS_UPDATE_QUERY_FS_IMP_ANDR_RATIO, DB_INDEX_FORTRESS_UPDATE_QUERY_FS_IMP_ANDR_ASSIGNED_DROIDS);


		s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_SUB_COMPUTER);    
		s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_SUB_QGCORE);
		s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_SUB_BEACON);
		s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_SUB_DAMPERS);
        s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_SUB_ACTUALSPEEDTOC);
		s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_IMP_JETENGINE);
		s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_IMP_MECHDAMPERS);
        s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_IMP_ACTUALFORCE);

        s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_POSITIONX);
        s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_POSITIONY);
        s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_COURSEX);
        s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_COURSEY);
        s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_SPEEDNORM);
        s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_ACCELERATION);

        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_SPOBJACTUALLYIN,      (int64_t)spaceObjectId_);

        s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_NEARESTSTAR);
        s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_WESPOBJ);
        s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_MOV_STATE);
        s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_MOV_WARP_TARGET_X);
        s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_MOV_WARP_TARGET_Y);
        s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_MOV_WARP_START);
        s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_ENGINE_LIMIT);
        s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_TARGETSPACEOBJECT);
        s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_TARGETSHIP);
        s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_TARGETPOSITIONX);
        s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_TARGETPOSITIONY);
        s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_LASTACTUALIZATION);
        s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_SHIPMOVEACTION);
        s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_SHIPMOVETARGET);
        s->SetNull(DB_INDEX_FORTRESS_UPDATE_QUERY_GRAVSPEEDNORM);

        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_STRUCTINTGRAD,            structuralIntegrityVoidSection.getGradient());  
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_CONTROLLABLE,             (int64_t)(controllable_ ? 1 : 0)  );
        s->Set(DB_INDEX_FORTRESS_UPDATE_QUERY_BUILDING_PTS,             (int64_t)buildingPoints_);

		fortressClass :: DB_Save(ID);
	
		s->Execute();
	}
	catch (IBPP :: Exception& e)
	{
		errExceptionError( e.what());
	}
};

// --------------------------------
 