Changeset 41e492ffe2a142d78e5aa841c2c7bfb4f6f8415b
- Timestamp:
- 01/06/07 15:23:42
(2 years ago)
- Author:
- Christopher Jung <bktheg@web.de>
- git-committer:
- Christopher Jung <bktheg@web.de> 1168093422 +0100
- git-parent:
[63b8c37bb0b8fc90910a7274b674e7fda327e2d4]
- git-author:
- Christopher Jung <bktheg@web.de> 1168093422 +0100
- Message:
Die Schiffsbibliothek verwendet nun immer die Datenbankverbindung des Kontexts
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r906b63b |
r41e492f |
|
| 109 | 109 | public static final ThreadLocalMessage MESSAGE = new ThreadLocalMessage(); |
|---|
| 110 | 110 | |
|---|
| 111 | | private static Database db = new Database(); |
|---|
| 112 | | |
|---|
| 113 | 111 | private static Map<Integer,SQLResultRow> shiptypes = new HashMap<Integer,SQLResultRow>(); |
|---|
| 114 | 112 | private static Map<Location,Integer> nebel = Collections.synchronizedMap(new CacheMap<Location,Integer>(1000)); |
|---|
| … | … | |
| 308 | 306 | } |
|---|
| 309 | 307 | else { |
|---|
| | 308 | Database db = ContextMap.getContext().getDatabase(); |
|---|
| 310 | 309 | picture = User.getDefaultImagePath(db)+picture; |
|---|
| 311 | 310 | } |
|---|
| … | … | |
| 332 | 331 | return getShipType(shipdata, false); |
|---|
| 333 | 332 | } |
|---|
| 334 | | |
|---|
| 335 | | private static PreparedQuery pqGetModuleRow = db.prepare("SELECT nickname,picture,ru,rd,ra,rm,eps,cost,hull,panzerung,cargo,heat,crew,weapons,maxheat,torpedodef,shields,size,jdocks,adocks,sensorrange,hydro,deutfactor,recost,flags,werft,ow_werft FROM ships_modules WHERE id>0 AND id= ? "); |
|---|
| 336 | | |
|---|
| | 333 | |
|---|
| 337 | 334 | /** |
|---|
| 338 | 335 | * Gibt die Typen-Daten des angegebenen Schiffs zurueck |
|---|
| … | … | |
| 344 | 341 | public static SQLResultRow getShipType( SQLResultRow shipdata, boolean plaindata ) { |
|---|
| 345 | 342 | int shiptype = shipdata.getInt("type"); |
|---|
| | 343 | |
|---|
| 346 | 344 | if( shipdata.getString("status").indexOf("tblmodules") != -1 ) { |
|---|
| 347 | | shipdata = pqGetModuleRow.pfirst(shipdata.getInt("id")); |
|---|
| | 345 | Database db = ContextMap.getContext().getDatabase(); |
|---|
| | 346 | shipdata = db.prepare("SELECT nickname,picture,ru,rd,ra,rm,eps,cost,hull,panzerung,cargo,heat,crew,weapons,maxheat,torpedodef,shields,size,jdocks,adocks,sensorrange,hydro,deutfactor,recost,flags,werft,ow_werft " + |
|---|
| | 347 | "FROM ships_modules " + |
|---|
| | 348 | "WHERE id>0 AND id= ? ") |
|---|
| | 349 | .first(shipdata.getInt("id")); |
|---|
| 348 | 350 | } |
|---|
| 349 | 351 | else { |
|---|
| … | … | |
| 353 | 355 | return getShipType(shiptype, shipdata, plaindata); |
|---|
| 354 | 356 | } |
|---|
| 355 | | |
|---|
| 356 | | private static PreparedQuery pqGetShipInfos = db.prepare("SELECT type,status FROM ships WHERE id>0 AND id= ?"); |
|---|
| 357 | | |
|---|
| | 357 | |
|---|
| 358 | 358 | private static SQLResultRow getShipType( int shiptype, boolean isShip, boolean plaindata ) { |
|---|
| 359 | 359 | if( isShip ) { |
|---|
| 360 | 360 | // TODO: Schiffscache implementieren! |
|---|
| 361 | | SQLResultRow shipdata = pqGetShipInfos.pfirst(shiptype); |
|---|
| | 361 | |
|---|
| | 362 | Database db = ContextMap.getContext().getDatabase(); |
|---|
| | 363 | SQLResultRow shipdata = db.prepare("SELECT type,status FROM ships WHERE id>0 AND id= ?") |
|---|
| | 364 | .first(shiptype); |
|---|
| 362 | 365 | |
|---|
| 363 | 366 | if( shipdata.getString("status").indexOf("tblmodules") != -1 ) { |
|---|
| 364 | | shipdata = pqGetModuleRow.pfirst(shiptype); |
|---|
| | 367 | shipdata = db.prepare("SELECT nickname,picture,ru,rd,ra,rm,eps,cost,hull,panzerung,cargo,heat,crew,weapons,maxheat,torpedodef,shields,size,jdocks,adocks,sensorrange,hydro,deutfactor,recost,flags,werft,ow_werft " + |
|---|
| | 368 | "FROM ships_modules " + |
|---|
| | 369 | "WHERE id>0 AND id= ? ") |
|---|
| | 370 | .first(shiptype); |
|---|
| 365 | 371 | } |
|---|
| 366 | 372 | else { |
|---|
| … | … | |
| 374 | 380 | return getShipType(shiptype, null, plaindata); |
|---|
| 375 | 381 | } |
|---|
| 376 | | |
|---|
| 377 | | private static PreparedQuery pqGetShipType = db.prepare("SELECT *,LOCATE('=',weapons) as military FROM ship_types WHERE id= ? "); |
|---|
| 378 | 382 | |
|---|
| 379 | 383 | private static SQLResultRow getShipType( int shiptype, SQLResultRow shipdata, boolean plaindata ) { |
|---|
| 380 | 384 | synchronized (shiptypes) { |
|---|
| 381 | 385 | if( !shiptypes.containsKey(shiptype) ) { |
|---|
| 382 | | shiptypes.put(shiptype, pqGetShipType.pfirst(shiptype)); |
|---|
| | 386 | Database db = ContextMap.getContext().getDatabase(); |
|---|
| | 387 | SQLResultRow row = db.prepare("SELECT *,LOCATE('=',weapons) as military FROM ship_types WHERE id= ? ") |
|---|
| | 388 | .first(shiptype); |
|---|
| | 389 | |
|---|
| | 390 | shiptypes.put(shiptype, row); |
|---|
| 383 | 391 | } |
|---|
| 384 | 392 | } |
|---|
| … | … | |
| 2554 | 2562 | return getNebula(new Location(ship.getInt("system"), ship.getInt("x"), ship.getInt("y"))); |
|---|
| 2555 | 2563 | } |
|---|
| 2556 | | |
|---|
| 2557 | | private static PreparedQuery pqGetNebula = db.prepare("SELECT id,type FROM nebel WHERE system= ? AND x= ? AND y= ? "); |
|---|
| 2558 | | |
|---|
| | 2564 | |
|---|
| 2559 | 2565 | /** |
|---|
| 2560 | 2566 | * Gibt den Nebeltyp an der angegebenen Position zurueck. Sollte sich an der Position kein |
|---|
| … | … | |
| 2565 | 2571 | public static synchronized int getNebula(Location loc) { |
|---|
| 2566 | 2572 | if( !nebel.containsKey(loc) ) { |
|---|
| 2567 | | SQLResultRow neb = pqGetNebula.pfirst(loc.getSystem(), loc.getX(), loc.getY()); |
|---|
| | 2573 | Database db = ContextMap.getContext().getDatabase(); |
|---|
| | 2574 | |
|---|
| | 2575 | SQLResultRow neb = db.prepare("SELECT id,type FROM nebel WHERE system= ? AND x= ? AND y= ? "). |
|---|
| | 2576 | first(loc.getSystem(), loc.getX(), loc.getY()); |
|---|
| 2568 | 2577 | if( neb.isEmpty() ) { |
|---|
| 2569 | 2578 | nebel.put(loc, -1); |
|---|