Oolite 1.91.0.7644-241112-7f5034b
Loading...
Searching...
No Matches
PlayerEntityLoadSave.h File Reference
import "PlayerEntity.h"
import "GuiDisplayGen.h"
import "MyOpenGLView.h"
import "Universe.h"
+ Include dependency graph for PlayerEntityLoadSave.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

category  PlayerEntity(LoadSave)
 

Macros

#define EXITROW   1
 
#define LABELROW   2
 
#define BACKROW   3
 
#define STARTROW   4
 
#define ENDROW   17
 
#define MOREROW   17
 
#define NUMROWS   13
 
#define COLUMNS   2
 
#define INPUTROW   21
 
#define CDRDESCROW   19
 
#define SAVE_OVERWRITE_WARN_ROW   5
 
#define SAVE_OVERWRITE_YES_ROW   8
 
#define SAVE_OVERWRITE_NO_ROW   9
 
#define USE_CUSTOM_LOAD_SAVE_ON_MAC_DEBUG   0
 
#define OOLITE_USE_APPKIT_LOAD_SAVE   (OOLITE_MAC_OS_X && !USE_CUSTOM_LOAD_SAVE_ON_MAC_DEBUG)
 
#define OO_USE_APPKIT_LOAD_SAVE_ALWAYS   (OOLITE_USE_APPKIT_LOAD_SAVE && OOLITE_64_BIT)
 
#define OO_USE_CUSTOM_LOAD_SAVE   (!OO_USE_APPKIT_LOAD_SAVE_ALWAYS)
 

Functions

OOCreditsQuantity OODeciCreditsFromDouble (double doubleDeciCredits)
 
OOCreditsQuantity OODeciCreditsFromObject (id object)
 

Macro Definition Documentation

◆ BACKROW

#define BACKROW   3

Definition at line 38 of file PlayerEntityLoadSave.h.

◆ CDRDESCROW

#define CDRDESCROW   19

Definition at line 45 of file PlayerEntityLoadSave.h.

◆ COLUMNS

#define COLUMNS   2

Definition at line 43 of file PlayerEntityLoadSave.h.

◆ ENDROW

#define ENDROW   17

Definition at line 40 of file PlayerEntityLoadSave.h.

◆ EXITROW

#define EXITROW   1

Definition at line 36 of file PlayerEntityLoadSave.h.

◆ INPUTROW

#define INPUTROW   21

Definition at line 44 of file PlayerEntityLoadSave.h.

◆ LABELROW

#define LABELROW   2

Definition at line 37 of file PlayerEntityLoadSave.h.

◆ MOREROW

#define MOREROW   17

Definition at line 41 of file PlayerEntityLoadSave.h.

◆ NUMROWS

#define NUMROWS   13

Definition at line 42 of file PlayerEntityLoadSave.h.

◆ OO_USE_APPKIT_LOAD_SAVE_ALWAYS

#define OO_USE_APPKIT_LOAD_SAVE_ALWAYS   (OOLITE_USE_APPKIT_LOAD_SAVE && OOLITE_64_BIT)

Definition at line 58 of file PlayerEntityLoadSave.h.

◆ OO_USE_CUSTOM_LOAD_SAVE

#define OO_USE_CUSTOM_LOAD_SAVE   (!OO_USE_APPKIT_LOAD_SAVE_ALWAYS)

Definition at line 61 of file PlayerEntityLoadSave.h.

◆ OOLITE_USE_APPKIT_LOAD_SAVE

#define OOLITE_USE_APPKIT_LOAD_SAVE   (OOLITE_MAC_OS_X && !USE_CUSTOM_LOAD_SAVE_ON_MAC_DEBUG)

Definition at line 55 of file PlayerEntityLoadSave.h.

◆ SAVE_OVERWRITE_NO_ROW

#define SAVE_OVERWRITE_NO_ROW   9

Definition at line 48 of file PlayerEntityLoadSave.h.

◆ SAVE_OVERWRITE_WARN_ROW

#define SAVE_OVERWRITE_WARN_ROW   5

Definition at line 46 of file PlayerEntityLoadSave.h.

◆ SAVE_OVERWRITE_YES_ROW

#define SAVE_OVERWRITE_YES_ROW   8

Definition at line 47 of file PlayerEntityLoadSave.h.

◆ STARTROW

#define STARTROW   4

Definition at line 39 of file PlayerEntityLoadSave.h.

◆ USE_CUSTOM_LOAD_SAVE_ON_MAC_DEBUG

#define USE_CUSTOM_LOAD_SAVE_ON_MAC_DEBUG   0

Definition at line 52 of file PlayerEntityLoadSave.h.

Function Documentation

◆ OODeciCreditsFromDouble()

OOCreditsQuantity OODeciCreditsFromDouble ( double doubleDeciCredits)

Definition at line 1378 of file PlayerEntityLoadSave.m.

1379{
1380 /* Clamp value to 0..kOOMaxCredits.
1381 The important bit here is that kOOMaxCredits can't be represented
1382 exactly as a double, and casting it rounds it up; casting this value
1383 back to an OOCreditsQuantity truncates it. Comparing value directly to
1384 kOOMaxCredits promotes kOOMaxCredits to a double, giving us this
1385 problem.
1386 nextafter(kOOMaxCredits, -1) gives us the highest non-truncated
1387 credits value that's representable as a double (namely,
1388 18 446 744 073 709 549 568 decicredits, or 2047 less than kOOMaxCredits).
1389 -- Ahruman 2011-02-27
1390 */
1391 if (doubleDeciCredits > 0)
1392 {
1393 doubleDeciCredits = round(doubleDeciCredits);
1394 double threshold = nextafter(kOOMaxCredits, -1);
1395
1396 if (doubleDeciCredits <= threshold)
1397 {
1398 return doubleDeciCredits;
1399 }
1400 else
1401 {
1402 return kOOMaxCredits;
1403 }
1404 }
1405 else
1406 {
1407 return 0;
1408 }
1409}
#define kOOMaxCredits
Definition OOTypes.h:183

References kOOMaxCredits.

Referenced by PlayerEntity(LoadSave)::addScenarioModel:.

+ Here is the caller graph for this function:

◆ OODeciCreditsFromObject()

OOCreditsQuantity OODeciCreditsFromObject ( id object)

Definition at line 1412 of file PlayerEntityLoadSave.m.

1413{
1414 if ([object isKindOfClass:[NSNumber class]] && [object oo_isFloatingPointNumber])
1415 {
1416 return OODeciCreditsFromDouble([object doubleValue]);
1417 }
1418 else
1419 {
1420 return OOUnsignedLongLongFromObject(object, 0);
1421 }
1422}
unsigned long long OOUnsignedLongLongFromObject(id object, unsigned long long defaultValue)
OOCreditsQuantity OODeciCreditsFromDouble(double doubleDeciCredits)