Oolite 1.93.0.7767-260207-f2a8cb5
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

◆ 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

◆ EXITROW

◆ 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

◆ NUMROWS

◆ 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

◆ 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

◆ STARTROW

◆ 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 1379 of file PlayerEntityLoadSave.m.

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

References kOOMaxCredits.

Referenced by OODeciCreditsFromObject(), and PlayerEntity(ScriptMethods)::setCreditBalance:.

Here is the caller graph for this function:

◆ OODeciCreditsFromObject()

OOCreditsQuantity OODeciCreditsFromObject ( id object)

Definition at line 1413 of file PlayerEntityLoadSave.m.

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

References OODeciCreditsFromDouble(), and OOUnsignedLongLongFromObject().

Referenced by PlayerEntity::setCommanderDataFromDictionary:, and PlayerEntity(OOLoadSavePrivate)::showCommanderShip:.

Here is the call graph for this function:
Here is the caller graph for this function: