verdbdta.sql 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. set NOCOUNT on
  2. /*
  3. Look for error rows in the data.
  4. */
  5. /*
  6. Object Radius Test
  7. */
  8. declare @cErrors int
  9. select @cErrors = COUNT(*) from expendables where radius <= 0.0
  10. if (@cErrors > 0)
  11. select name, radius from expendables, missiles where (radius <= 0.0)
  12. select @cErrors = COUNT(*) from projectiles where size_cm <= 0
  13. if (@cErrors > 0)
  14. select projectileid, size_cm from projectiles where size_cm <= 0
  15. select @cErrors = COUNT(*) from shiptypes where length <= 0
  16. if (@cErrors > 0)
  17. select shiptypeid, name, length from shiptypes where length <= 0
  18. select @cErrors = COUNT(*) from stationtypes where radius <= 0.0
  19. if (@cErrors > 0)
  20. select stationtypeid, name, radius from stationtypes where radius <= 0
  21. go
  22. /*
  23. Object Mass Test
  24. */
  25. declare @cErrors int
  26. select @cErrors = COUNT(*) from expendables where mass <= 0.0
  27. if (@cErrors > 0)
  28. select expendableid, name, mass from expendables where mass <= 0.0
  29. select @cErrors = COUNT(*) from parts where mass <= 0
  30. if (@cErrors > 0)
  31. select partid, name, mass from parts where mass <= 0
  32. select @cErrors = COUNT(*) from shiptypes where weight <= 0.0
  33. if (@cErrors > 0)
  34. select shiptypeid, name, weight from shiptypes where weight <= 0.0
  35. go
  36. /*
  37. Hit Points Test
  38. */
  39. declare @cErrors int
  40. select @cErrors = COUNT(*) from expendables where hitpoints < 0
  41. if (@cErrors > 0)
  42. select expendableid, name, hitpoints from expendables where hitpoints < 0
  43. select @cErrors = COUNT(*) from projectiles where hitpointsself < 0
  44. if (@cErrors > 0)
  45. select projectileid, hitpointsself from projectiles where hitpointsself < 0
  46. select @cErrors = COUNT(*) from shiptypes where basehitpoints < 0
  47. if (@cErrors > 0)
  48. select shiptypeid, name, basehitpoints from shiptypes where basehitpoints < 0
  49. select @cErrors = COUNT(*) from stationtypes where hitpointsarmor < 0
  50. if (@cErrors > 0)
  51. select stationtypeid, name, hitpointsarmor from stationtypes where hitpointsarmor < 0
  52. select @cErrors = COUNT(*) from stationtypes where hitpointsshield < 0
  53. if (@cErrors > 0)
  54. select stationtypeid, name, hitpointsshield from stationtypes where hitpointsshield < 0
  55. select @cErrors = COUNT(*) from shields where (shields.hitpoints < 0)
  56. if (@cErrors > 0)
  57. select parts.partid, name, shields.hitpoints from parts, shields where (parts.partid = shields.partid) AND (shields.hitpoints < 0)
  58. go
  59. /*
  60. Price Test
  61. */
  62. declare @cErrors int
  63. select @cErrors = COUNT(*) from developments where (price <= 0)
  64. if (@cErrors > 0)
  65. select DevelopmentID, Name, Price from developments where (price <= 0)
  66. select @cErrors = COUNT(*) from drones where (price <= 0) and (DroneType <> 6)
  67. if (@cErrors > 0)
  68. select DroneID, Name, Price from drones where (price <= 0) and (DroneType <> 6)
  69. select @cErrors = COUNT(*) from expendables where (price <= 0)
  70. if (@cErrors > 0)
  71. select ExpendableId, Name, Price from expendables where (price <= 0)
  72. select @cErrors = COUNT(*) from parts where (price <= 0)
  73. if (@cErrors > 0)
  74. select PartID, Name, Price from parts where (price <= 0)
  75. select @cErrors = COUNT(*) from shiptypes where (price <= 0) and (shiptypeid not in (select escapepodshiptypeid from civs))
  76. if (@cErrors > 0)
  77. select ShipTypeID, Name, Price from shiptypes where (price <= 0) and (shiptypeid not in (select escapepodshiptypeid from civs))
  78. select @cErrors = COUNT(*) from stationtypes where (price <= 0)
  79. if (@cErrors > 0)
  80. select StationTypeID, Name, Price from stationtypes where (price <= 0)
  81. go
  82. /*
  83. Drone Test
  84. */
  85. declare @cErrors int
  86. select @cErrors = COUNT(*) from drones where (dronetype > 6) or (dronetype = 5) or (dronetype < 0)
  87. if (@cErrors > 0)
  88. select Name, dronetype from drones where (dronetype > 6) or (dronetype = 5) or (dronetype < 0)
  89. select @cErrors = COUNT(*) from drones, parts p1, parts p2, shiptypes where (drones.shiptypeid = shiptypes.shiptypeid) AND (p1.partid = drones.PartID_Weapon) AND (p2.partid = drones.PartID_Shield) AND (p1.drain + p2.drain > shiptypes.capacity)
  90. if (@cErrors > 0)
  91. select drones.droneid, drones.name, p1.name, p1.drain, p2.name, p2.drain, shiptypes.capacity from drones, parts p1, parts p2, shiptypes where (drones.shiptypeid = shiptypes.shiptypeid) AND (p1.partid = drones.PartID_Weapon) AND (p2.partid = drones.PartID_Shield) AND (p1.drain + p2.drain > shiptypes.capacity)
  92. go
  93. /*
  94. Mine Test
  95. */
  96. declare @cErrors int
  97. select @cErrors = COUNT(*) from mines where (munitioncount > 50)
  98. if (@cErrors > 0)
  99. select expendableid, munitioncount from mines where (munitioncount > 50)
  100. go
  101. /*
  102. Projectile Test
  103. */
  104. declare @cErrors int
  105. select @cErrors = COUNT(*) from projectiles where (timeduration < 250)
  106. if (@cErrors > 0)
  107. select projectileid, timeduration from projectiles where (timeduration < 250)
  108. select @cErrors = COUNT(*) from projectiles where (speedmax < 50) OR (speedmax > 1000)
  109. if (@cErrors > 0)
  110. select projectileid, speedmax from projectiles where (speedmax < 50) OR (speedmax > 1000)
  111. select @cErrors = COUNT(*) from projectiles where (hitpointsinflict < 0)
  112. if (@cErrors > 0)
  113. select projectileid, hitpointsinflict from projectiles where (hitpointsinflict < 0)
  114. go
  115. /*
  116. Shield Test
  117. */
  118. declare @cErrors int
  119. select @cErrors = COUNT(*) from shields where (regenrate < 0)
  120. if (@cErrors > 0)
  121. select parts.partid, name, regenrate from parts, shields where (parts.partid = shields.partid) AND (regenrate < 0)
  122. select @cErrors = COUNT(*) from shields where (percentreflectparticle < 0) OR (percentreflectparticle > 100)
  123. if (@cErrors > 0)
  124. select parts.partid, name, percentreflectparticle from parts, shields where (parts.partid = shields.partid) AND ((percentreflectparticle < 0) OR (percentreflectparticle > 100))
  125. select @cErrors = COUNT(*) from shields where (percentreflectenergy < 0) OR (percentreflectenergy > 100)
  126. if (@cErrors > 0)
  127. select parts.partid, name, percentreflectenergy from parts, shields where (parts.partid = shields.partid) AND ((percentreflectenergy < 0) OR (percentreflectenergy > 100))
  128. select @cErrors = COUNT(*) from shields where (percentleakageparticle < 0) OR (percentleakageparticle > 100)
  129. if (@cErrors > 0)
  130. select parts.partid, name, percentleakageparticle from parts, shields where (parts.partid = shields.partid) AND ((percentleakageparticle < 0) OR (percentleakageparticle > 100))
  131. select @cErrors = COUNT(*) from shields where (percentleakageenergy < 0) OR (percentleakageenergy > 100)
  132. if (@cErrors > 0)
  133. select parts.partid, name, percentleakageenergy from parts, shields where (parts.partid = shields.partid) AND ((percentleakageenergy < 0) OR (percentleakageenergy > 100))
  134. go
  135. /*
  136. Ship Test
  137. */
  138. declare @cErrors int
  139. select @cErrors = COUNT(*) from shiptypes where
  140. (length * length / 4) < (cockpitx * cockpitx) + (cockpity * cockpity) + (cockpitz * cockpitz)
  141. if (@cErrors > 0)
  142. select shiptypeid, name, length / 2, cockpitx, cockpity, cockpitz
  143. from shiptypes where (length * length / 4) < (cockpitx * cockpitx) + (cockpity * cockpity) + (cockpitz * cockpitz)
  144. select @cErrors = COUNT(*) from shiptypes where
  145. (shipclassid < 0) OR (shipclassid > 8)
  146. if (@cErrors > 0)
  147. select shiptypeid, name, shipclassid from shiptypes where
  148. (shipclassid < 0) OR (shipclassid > 8)
  149. /*
  150. AttachPoint test (this one's tricky).
  151. */
  152. select COUNT(*) as 'AttachPoints' into #bvtattachpt from attachpoints group by shiptypeid, parttypeid having COUNT(*) > 4
  153. select @cErrors = COUNT(*) from #bvtattachpt
  154. if (@cErrors > 0)
  155. select shiptypeid, parttypeid, COUNT(*) as 'AttachPoints' from attachpoints group by shiptypeid, parttypeid having COUNT(*) > 4
  156. drop table #bvtattachpt
  157. go
  158. /*
  159. Signature Test
  160. */
  161. declare @cErrors int
  162. select @cErrors = COUNT(*) from shiptypes where (basesignature < 50)
  163. if (@cErrors > 0)
  164. select shiptypeid, name, basesignature from shiptypes where (basesignature < 50)
  165. go
  166. /*
  167. Station Test
  168. */
  169. declare @cErrors int
  170. select @cErrors = COUNT(*) from stationtypes where (rateregenarmor < 0)
  171. if (@cErrors > 0)
  172. select stationtypeid, name, rateregenarmor from stationtypes where (rateregenarmor < 0)
  173. select @cErrors = COUNT(*) from stationtypes where (rateregenshield < 0)
  174. if (@cErrors > 0)
  175. select stationtypeid, name, rateregenshield from stationtypes where (rateregenshield < 0)
  176. select @cErrors = COUNT(*) from stationtypes where (UpgradeStationTypeID >= stationtypeid)
  177. if (@cErrors > 0)
  178. select stationtypeid, name, upgradestationtypeid from stationtypes where (UpgradeStationTypeID >= stationtypeid)
  179. select @cErrors = COUNT(*) from stationtypes where (upgradeprice = 0) AND (UpgradeName IS NOT NULL)
  180. if (@cErrors > 0)
  181. select stationtypeid, name, upgradeprice, upgradename from stationtypes where (upgradeprice = 0) AND (UpgradeName IS NOT NULL)
  182. select @cErrors = COUNT(*) from stationtypes where (capabilities % 2 = 1) and ((capabilities / 32) % 2 = 0)
  183. if (@cErrors > 0)
  184. select stationtypeid, name, capabilities from stationtypes where (capabilities % 2 = 1) and ((capabilities / 32) % 2 = 0)
  185. go
  186. /*
  187. Station Upgrade Test
  188. */
  189. declare @iIndex int
  190. declare @siStationType smallint
  191. declare @siUpgradeType smallint
  192. declare @szStationName varchar(20)
  193. declare @szUpgradeName varchar(20)
  194. declare @szStationEffect TechBits
  195. declare @szUpgradeEffect TechBits
  196. declare @iStationEffect int
  197. declare @iUpgradeEffect int
  198. declare @szStationLocal TechBits
  199. declare @szUpgradeLocal TechBits
  200. declare @iStationLocal int
  201. declare @iUpgradeLocal int
  202. declare curStations scroll cursor for
  203. select st1.stationtypeid, st2.stationtypeid,
  204. RTRIM(st1.name), RTRIM(st2.name),
  205. st1.techbitseffect, st2.techbitseffect,
  206. st1.techbitslocal, st2.techbitslocal
  207. from
  208. stationtypes st1, stationtypes st2 where
  209. (st1.upgradestationtypeid = st2.stationtypeid)
  210. order by st1.stationtypeid
  211. open curStations
  212. fetch next from curStations into @siStationType,
  213. @siUpgradeType,
  214. @szStationName,
  215. @szUpgradeName,
  216. @szStationEffect,
  217. @szUpgradeEffect,
  218. @szStationLocal,
  219. @szUpgradeLocal
  220. while (@@fetch_status <> -1)
  221. begin
  222. if (@@fetch_status <> -2)
  223. begin
  224. /*
  225. First check the effect bits.
  226. */
  227. select @iIndex = 1
  228. while (@iIndex <= datalength(@szStationEffect))
  229. begin
  230. /*
  231. Pull off one character at a time and compare the
  232. two bitmasks. Note that ASCII 0 == 48,
  233. ASCII A == 65, and ASCII a == 97.
  234. */
  235. select @iStationEffect =
  236. ASCII(SUBSTRING(@szStationEffect, @iIndex, 1)) - 48
  237. if (@iStationEffect > 9)
  238. select @iStationEffect = @iStationEffect - 7
  239. if (@iStationEffect > 15)
  240. select @iStationEffect = @iStationEffect - 32
  241. select @iUpgradeEffect =
  242. ASCII(SUBSTRING(@szUpgradeEffect, @iIndex, 1)) - 48
  243. if (@iUpgradeEffect > 9)
  244. select @iUpgradeEffect = @iUpgradeEffect - 7
  245. if (@iUpgradeEffect > 15)
  246. select @iUpgradeEffect = @iUpgradeEffect - 32
  247. if (@iStationEffect & @iUpgradeEffect <> @iStationEffect)
  248. begin
  249. select "Warning: Illegal upgrade from " +
  250. @szStationName + " to " + @szUpgradeName +
  251. " (effect)."
  252. select @iIndex = datalength(@szUpgradeEffect)
  253. end
  254. select @iIndex = @iIndex + 1
  255. end
  256. /*
  257. Now check the local bits.
  258. */
  259. select @iIndex = 1
  260. while (@iIndex <= datalength(@szStationLocal))
  261. begin
  262. /*
  263. Pull off one character at a time and compare the
  264. two bitmasks. Note that ASCII 0 == 48,
  265. ASCII A == 65, and ASCII a == 97.
  266. */
  267. select @iStationLocal =
  268. ASCII(SUBSTRING(@szStationLocal, @iIndex, 1)) - 48
  269. if (@iStationLocal > 9)
  270. select @iStationLocal = @iStationLocal - 7
  271. if (@iStationEffect > 15)
  272. select @iStationLocal = @iStationLocal - 32
  273. select @iUpgradeLocal =
  274. ASCII(SUBSTRING(@szUpgradeLocal, @iIndex, 1)) - 48
  275. if (@iUpgradeLocal > 9)
  276. select @iUpgradeLocal = @iUpgradeLocal - 7
  277. if (@iUpgradeLocal > 15)
  278. select @iUpgradeLocal = @iUpgradeLocal - 32
  279. if (@iStationLocal & @iUpgradeLocal <> @iStationLocal)
  280. begin
  281. select "Warning: Illegal upgrade from " +
  282. @szStationName + " to " + @szUpgradeName +
  283. " (local)."
  284. select @iIndex = datalength(@szUpgradeLocal)
  285. end
  286. select @iIndex = @iIndex + 1
  287. end
  288. end
  289. fetch next from curStations into @siStationType,
  290. @siUpgradeType,
  291. @szStationName,
  292. @szUpgradeName,
  293. @szStationEffect,
  294. @szUpgradeEffect,
  295. @szStationLocal,
  296. @szUpgradeLocal
  297. end
  298. close curStations
  299. deallocate curStations
  300. go
  301. /*
  302. Tech Tree Test
  303. */
  304. declare @cErrors int
  305. select @cErrors = COUNT(*) from civs where techbitsciv like '#%'
  306. if (@cErrors > 0)
  307. select Name, techbitsciv from civs where techbitsciv like '#%'
  308. select @cErrors = COUNT(*) from developments where techbitsrequired like '#%'
  309. if (@cErrors > 0)
  310. select Name, techbitsrequired from developments where techbitsrequired like '#%'
  311. select @cErrors = COUNT(*) from developments where techbitseffect like '#%'
  312. if (@cErrors > 0)
  313. select Name, techbitseffect from developments where techbitseffect like '#%'
  314. select @cErrors = COUNT(*) from drones where techbitsrequired like '#%'
  315. if (@cErrors > 0)
  316. select Name, techbitsrequired from drones where techbitsrequired like '#%'
  317. select @cErrors = COUNT(*) from drones where techbitseffect like '#%'
  318. if (@cErrors > 0)
  319. select Name, techbitseffect from drones where techbitseffect like '#%'
  320. select @cErrors = COUNT(*) from expendables where techbitsrequired like '#%'
  321. if (@cErrors > 0)
  322. select Name, techbitsrequired from expendables where techbitsrequired like '#%'
  323. select @cErrors = COUNT(*) from expendables where techbitseffect like '#%'
  324. if (@cErrors > 0)
  325. select Name, techbitseffect from expendables where techbitseffect like '#%'
  326. select @cErrors = COUNT(*) from parts where techbitsrequired like '#%'
  327. if (@cErrors > 0)
  328. select Name, techbitsrequired from parts where techbitsrequired like '#%'
  329. select @cErrors = COUNT(*) from parts where techbitseffect like '#%'
  330. if (@cErrors > 0)
  331. select Name, techbitseffect from parts where techbitseffect like '#%'
  332. select @cErrors = COUNT(*) from shiptypes where techbitsrequired like '#%'
  333. if (@cErrors > 0)
  334. select Name, techbitsrequired from shiptypes where techbitsrequired like '#%'
  335. select @cErrors = COUNT(*) from shiptypes where techbitseffect like '#%'
  336. if (@cErrors > 0)
  337. select Name, techbitseffect from shiptypes where techbitseffect like '#%'
  338. select @cErrors = COUNT(*) from stationtypes where techbitslocal like '#%'
  339. if (@cErrors > 0)
  340. select Name, techbitslocal from stationtypes where techbitslocal like '#%'
  341. select @cErrors = COUNT(*) from stationtypes where techbitsrequired like '#%'
  342. if (@cErrors > 0)
  343. select Name, techbitsrequired from stationtypes where techbitsrequired like '#%'
  344. select @cErrors = COUNT(*) from stationtypes where techbitseffect like '#%'
  345. if (@cErrors > 0)
  346. select Name, techbitseffect from stationtypes where techbitseffect like '#%'
  347. go
  348. /*
  349. Weapon Test
  350. */
  351. declare @cErrors int
  352. select @cErrors = COUNT(*) from weapons where (cBulletsPerShot <= 0) AND (energypershot <= 0)
  353. if (@cErrors > 0)
  354. select parts.partid, name, cBulletsPerShot from parts, weapons where (parts.partid = weapons.partid) AND (cBulletsPerShot <= 0) AND (energypershot <= 0)
  355. select @cErrors = COUNT(*) from weapons where (dispersion > 0.05)
  356. if (@cErrors > 0)
  357. select parts.partid, name, dispersion from parts, weapons where
  358. (parts.partid = weapons.partid) AND (dispersion > 0.05)
  359. select @cErrors = COUNT(*) from weapons, projectiles where (weapons.projectileid1 = projectiles.projectileid) AND (weapons.energypershot = 0) AND (projectiles.damagetype % 2 = 1)
  360. if (@cErrors > 0)
  361. select parts.name, projectileid, energypershot, cbulletspershot, damagetype from parts, weapons, projectiles where (parts.partid = weapons.partid) AND (weapons.projectileid1 = projectiles.projectileID) AND (weapons.energypershot = 0) and (projectiles.damagetype % 2 = 1)
  362. select @cErrors = COUNT(*) from weapons, projectiles where (weapons.projectileid1 = projectiles.projectileid) AND (weapons.cbulletspershot = 0) AND (projectiles.damagetype % 2 = 0)
  363. if (@cErrors > 0)
  364. select parts.name, projectileid, energypershot, cbulletspershot, damagetype from parts, weapons, projectiles where (parts.partid = weapons.partid) AND (weapons.projectileid1 = projectiles.projectileID) AND (weapons.cbulletspershot = 0) AND (projectiles.damagetype % 2 = 0)
  365. go
  366. declare @cWeapons int
  367. declare @cWeaponParts int
  368. declare @cShields int
  369. declare @cShieldParts int
  370. declare @cAfterburners int
  371. declare @cAfterburnerParts int
  372. declare @cAmmo int
  373. declare @cAmmoParts int
  374. select @cWeapons = COUNT(*) from weapons
  375. select @cWeaponParts = COUNT(*) from parts where parttypeid = 1
  376. select @cShields = COUNT(*) from shields
  377. select @cShieldParts = COUNT(*) from parts where parttypeid = 4
  378. select @cAfterburners = COUNT(*) from afterburners
  379. select @cAfterburnerParts = COUNT(*) from parts where parttypeid = 7
  380. select @cAmmo = COUNT(*) from ammo
  381. select @cAmmoParts = COUNT(*) from parts where parttypeid = 6
  382. if (@cWeapons <> @cWeaponParts)
  383. BEGIN
  384. select "ERROR: Wrong number of weapons (" +
  385. CONVERT(varchar, @cWeapons) + " vs " +
  386. CONVERT(varchar, @cWeaponParts) + ")"
  387. END
  388. if (@cShields <> @cShieldParts)
  389. BEGIN
  390. select "ERROR: Wrong number of shields (" +
  391. CONVERT(varchar, @cShields) + " vs " +
  392. CONVERT(varchar, @cShieldParts) + ")"
  393. END
  394. if (@cAfterburners <> @cAfterburnerParts)
  395. BEGIN
  396. select "ERROR: Wrong number of afterburners (" +
  397. CONVERT(varchar, @cAfterburners) + " vs " +
  398. CONVERT(varchar, @cAfterburnerParts) + ")"
  399. END
  400. if (@cAmmo <> @cAmmoParts)
  401. BEGIN
  402. select "ERROR: Wrong number of ammo (" +
  403. CONVERT(varchar, @cAmmo) + " vs " +
  404. CONVERT(varchar, @cAmmoParts) + ")"
  405. END