Merge branch 'master' of github.com:OoliteProject/oolite into npc_reaction_times

This commit is contained in:
Kevin Anthoney 2014-08-11 23:01:05 +01:00
commit c71542c217
22 changed files with 488 additions and 165 deletions

View File

@ -1,4 +1,4 @@
Changes between Oolite 1.80 and Oolite 1.82:
Changes between Oolite 1.80.1 and Oolite 1.82:
General:
========
@ -7,6 +7,18 @@ General:
* Installation time now on equipment purchase screen
* OXZ installer now updates dependency check after each install
* Added zooming, scrolling galaxy chart
* Internal damage from missiles now more serious
* Damaged equipment now sorts to the top of the status screen
Graphics:
=========
* ECM bursts now have an effect on the scanner
* Spacedust fades out when entering atmosphere
Expansion pack manager:
=======================
* Installation status now updated without having to restart manager
* Missing requirements will be installed automatically if possible
Expansion pack development:
===========================
@ -25,13 +37,18 @@ Plists:
-------
* oolite-font.plist: new f6KernGovernment and f6KernTechLevel options
* equipment.plist: installation_time, repair_time
* descriptions.plist: long-range-chart-title-G-S now allows chart title
to vary from system to system
Bug fixes:
==========
* Restore something like the 1.76 behaviour in terms of alloy plates in debris
* Speech synthesis slightly more conservative in detecting 'credits'
abbreviation
-------------------------------------------------------------------------------
Changes between Oolite 1.80 and Oolite 1.80.1:
@ -43,6 +60,8 @@ Changes between Oolite 1.80 and Oolite 1.80.1:
filename entry.
* Fix Linux uninstall script error handling
* Fix errors with escape pod launch from subentities
* Fix consistency errors on ship library screen
* Ship registration forms now return to interfaces page
-------------------------------------------------------------------------------

View File

@ -374,6 +374,8 @@
<string>player-unknown</string>
<string>player-unknown</string>
</array>
<key>scenario_restriction</key>
<string>tag:oolite-tutorial-compatible</string>
<key>shipCommodityData</key>
<array>
<array>

View File

@ -57,6 +57,7 @@ this._registerShip = function()
titleKey: "oolite-registership-title-part1",
messageKey: "oolite-registership-instructions-part1",
screenID: "oolite-register",
exitScreen: "GUI_SCREEN_INTERFACES",
textEntry: true
},this._registerShip2.bind(this));
}
@ -72,6 +73,7 @@ this._registerShip2 = function(cdrname)
titleKey: "oolite-registership-title-part2",
messageKey: "oolite-registership-instructions-part2",
screenID: "oolite-register",
exitScreen: "GUI_SCREEN_INTERFACES",
textEntry: true
},this._registerShip3.bind(this));
}
@ -86,6 +88,7 @@ this._registerShip3 = function(shipname)
mission.runScreen({
titleKey: "oolite-registership-title-part3",
messageKey: "oolite-registership-instructions-part3",
exitScreen: "GUI_SCREEN_INTERFACES",
screenID: "oolite-register",
});
}

View File

@ -35,6 +35,7 @@ MA 02110-1301, USA.
#define NUM_KEYS 320
#define MOUSE_DOUBLE_CLICK_INTERVAL 0.40
#define OOMOUSEWHEEL_EVENTS_DELAY_INTERVAL 0.05
@class Entity, GameController;
@ -86,6 +87,13 @@ enum GameViewKeys
gvNumberPadKey9 //319
};
enum MouseWheelStatus
{
gvMouseWheelDown = -1,
gvMouseWheelNeutral,
gvMouseWheelUp
};
enum StringInput
{
gvStringInputNo = 0,
@ -174,6 +182,7 @@ extern int debug;
- (BOOL) isCommandDown;
- (BOOL) isShiftDown;
- (int) numKeys;
- (int) mouseWheelState;
// Command-key combinations need special handling.
- (BOOL) isCommandQDown;

View File

@ -971,6 +971,13 @@ FAIL:
}
- (int) mouseWheelState
{
// FIXME: Mousewheel in-game implementaiton for Macs needed
return gvMouseWheelNeutral;
}
- (BOOL) isCommandQDown
{
return commandQ;

View File

@ -97,6 +97,7 @@ typedef enum
OOLRC_MODE_TECHLEVEL = 3
} OOLongRangeChartMode;
// When fully zoomed in, chart shows area of galaxy that's 64x64 galaxy units.
#define CHART_WIDTH_AT_MAX_ZOOM 64.0
#define CHART_HEIGHT_AT_MAX_ZOOM 64.0
// Galaxy width / width of chart area at max zoom
@ -105,6 +106,8 @@ typedef enum
#define CHART_SCROLL_AT_X 25.0
#define CHART_SCROLL_AT_Y 31.0
#define CHART_CLIP_BORDER 10.0
#define CHART_SCREEN_VERTICAL_CENTRE (10*MAIN_GUI_ROW_HEIGHT)
#define CHART_ZOOM_SPEED_FACTOR 1.05
#define CHART_ZOOM_SHOW_LABELS 2.0
@ -286,6 +289,7 @@ typedef enum
#define SCANNER_ZOOM_RATE_UP 2.0
#define SCANNER_ZOOM_RATE_DOWN -8.0
#define SCANNER_ECM_FUZZINESS 1.5
#define PLAYER_INTERNAL_DAMAGE_FACTOR 31
@ -400,7 +404,8 @@ typedef enum
OOWeaponFacing chosen_weapon_facing; // for purchasing weapons
double ecm_start_time;
double last_ecm_time;
OOGUIScreenID gui_screen;
OOAlertFlags alertFlags;
OOAlertCondition alertCondition;
@ -416,6 +421,7 @@ typedef enum
NSPoint cursor_coordinates;
NSPoint chart_cursor_coordinates;
NSPoint chart_focus_coordinates;
NSPoint chart_centre_coordinates;
// where we want the chart centre to be - used for smooth transitions
NSPoint target_chart_centre;
@ -823,6 +829,8 @@ typedef enum
- (BOOL) activateCloakingDevice;
- (void) deactivateCloakingDevice;
- (double) scannerFuzziness;
- (BOOL) weaponsOnline;
- (void) setWeaponsOnline:(BOOL)newValue;

View File

@ -585,7 +585,7 @@ static GLfloat sBaseMass = 0.0;
// If the cursor is out of the centre non-scrolling part of the screen adjust the chart centre. If the cursor is just at scroll_pos
// we want to return the chart centre as it is, but if it's at the edge of the galaxy we want the centre positioned so the cursor is
// at the edge of the screen
if (chart_cursor_coordinates.x - acc.x <= -CHART_SCROLL_AT_X*chart_zoom)
if (chart_focus_coordinates.x - acc.x <= -CHART_SCROLL_AT_X*chart_zoom)
{
scroll_pos = acc.x - CHART_SCROLL_AT_X*chart_zoom;
ecc = CHART_WIDTH_AT_MAX_ZOOM*chart_zoom / 2.0;
@ -595,10 +595,10 @@ static GLfloat sBaseMass = 0.0;
}
else
{
acc.x = ((scroll_pos-chart_cursor_coordinates.x)*ecc + chart_cursor_coordinates.x*acc.x)/scroll_pos;
acc.x = ((scroll_pos-chart_focus_coordinates.x)*ecc + chart_focus_coordinates.x*acc.x)/scroll_pos;
}
}
else if (chart_cursor_coordinates.x - acc.x >= CHART_SCROLL_AT_X*chart_zoom)
else if (chart_focus_coordinates.x - acc.x >= CHART_SCROLL_AT_X*chart_zoom)
{
scroll_pos = acc.x + CHART_SCROLL_AT_X*chart_zoom;
ecc = 256.0 - CHART_WIDTH_AT_MAX_ZOOM*chart_zoom / 2.0;
@ -608,10 +608,10 @@ static GLfloat sBaseMass = 0.0;
}
else
{
acc.x = ((chart_cursor_coordinates.x-scroll_pos)*ecc + (256.0 - chart_cursor_coordinates.x)*acc.x)/(256.0 - scroll_pos);
acc.x = ((chart_focus_coordinates.x-scroll_pos)*ecc + (256.0 - chart_focus_coordinates.x)*acc.x)/(256.0 - scroll_pos);
}
}
if (chart_cursor_coordinates.y - acc.y <= -CHART_SCROLL_AT_Y*chart_zoom)
if (chart_focus_coordinates.y - acc.y <= -CHART_SCROLL_AT_Y*chart_zoom)
{
scroll_pos = acc.y - CHART_SCROLL_AT_Y*chart_zoom;
ecc = CHART_HEIGHT_AT_MAX_ZOOM*chart_zoom / 2.0;
@ -621,10 +621,10 @@ static GLfloat sBaseMass = 0.0;
}
else
{
acc.y = ((scroll_pos-chart_cursor_coordinates.y)*ecc + chart_cursor_coordinates.y*acc.y)/scroll_pos;
acc.y = ((scroll_pos-chart_focus_coordinates.y)*ecc + chart_focus_coordinates.y*acc.y)/scroll_pos;
}
}
else if (chart_cursor_coordinates.y - acc.y >= CHART_SCROLL_AT_Y*chart_zoom)
else if (chart_focus_coordinates.y - acc.y >= CHART_SCROLL_AT_Y*chart_zoom)
{
scroll_pos = acc.y + CHART_SCROLL_AT_Y*chart_zoom;
ecc = 256.0 - CHART_HEIGHT_AT_MAX_ZOOM*chart_zoom / 2.0;
@ -634,7 +634,7 @@ static GLfloat sBaseMass = 0.0;
}
else
{
acc.y = ((chart_cursor_coordinates.y-scroll_pos)*ecc + (256.0 - chart_cursor_coordinates.y)*acc.y)/(256.0 - scroll_pos);
acc.y = ((chart_focus_coordinates.y-scroll_pos)*ecc + (256.0 - chart_focus_coordinates.y)*acc.y)/(256.0 - scroll_pos);
}
}
return acc;
@ -914,11 +914,8 @@ static GLfloat sBaseMass = 0.0;
//local market for main station
if ([[UNIVERSE station] localMarket]) [result setObject:[[UNIVERSE station] localMarket] forKey:@"localMarket"];
// strict UNIVERSE?
if ([UNIVERSE strict])
{
[result setObject:[NSNumber numberWithBool:YES] forKey:@"strict"];
}
// Scenario restriction on OXZs
[result setObject:[UNIVERSE useAddOns] forKey:@"scenario_restriction"];
// persistant UNIVERSE information
if ([UNIVERSE localPlanetInfoOverrides])
@ -1000,8 +997,26 @@ static GLfloat sBaseMass = 0.0;
if ([dict oo_stringForKey:@"galaxy_seed"] == nil) return NO;
if ([dict oo_stringForKey:@"galaxy_coordinates"] == nil) return NO;
BOOL strict = [dict oo_boolForKey:@"strict" defaultValue:NO];
if (![UNIVERSE setStrict:strict fromSaveGame:YES]) return NO;
NSString *scenarioRestrict = [dict oo_stringForKey:@"scenario_restriction" defaultValue:nil];
if (scenarioRestrict == nil)
{
// older save game - use the 'strict' key instead
BOOL strict = [dict oo_boolForKey:@"strict" defaultValue:NO];
if (strict)
{
scenarioRestrict = SCENARIO_OXP_DEFINITION_NONE;
}
else
{
scenarioRestrict = SCENARIO_OXP_DEFINITION_ALL;
}
}
if (![UNIVERSE setUseAddOns:scenarioRestrict fromSaveGame:YES])
{
return NO;
}
//base ship description
[self setShipDataKey:[dict oo_stringForKey:@"ship_desc"]];
@ -1037,6 +1052,7 @@ static GLfloat sBaseMass = 0.0;
cursor_coordinates.y = [coord_vals oo_unsignedCharAtIndex:1];
}
chart_cursor_coordinates = cursor_coordinates;
chart_focus_coordinates = cursor_coordinates;
keyStringValue = [dict oo_stringForKey:@"found_system_seed"];
found_system_seed = (keyStringValue != nil) ? RandomSeedFromString(keyStringValue) : kNilRandomSeed;
@ -1807,6 +1823,7 @@ static GLfloat sBaseMass = 0.0;
target_chart_centre = chart_centre_coordinates;
cursor_coordinates = galaxy_coordinates;
chart_cursor_coordinates = cursor_coordinates;
chart_focus_coordinates = cursor_coordinates;
chart_zoom = 1.0;
target_chart_zoom = 1.0;
saved_chart_zoom = 1.0;
@ -3678,7 +3695,7 @@ static GLfloat sBaseMass = 0.0;
- (void) moveForward:(double) amount
{
distanceTravelled += (float)amount;
position = HPvector_add(position, vectorToHPVector(vector_multiply_scalar(v_forward, (float)amount)));
[self setPosition:HPvector_add(position, vectorToHPVector(vector_multiply_scalar(v_forward, (float)amount)))];
}
@ -5224,6 +5241,29 @@ static GLfloat sBaseMass = 0.0;
}
/* Scanner fuzziness is entirely cosmetic - it doesn't affect the
* player's actual target locks */
- (double) scannerFuzziness
{
double fuzz = 0.0;
/* Fuzziness from ECM bursts */
double since = [UNIVERSE getTime] - last_ecm_time;
if (since < SCANNER_ECM_FUZZINESS)
{
fuzz += (SCANNER_ECM_FUZZINESS - since) * (SCANNER_ECM_FUZZINESS - since) * 1000.0;
}
/* Other causes could go here */
return fuzz;
}
- (void) noticeECM
{
last_ecm_time = [UNIVERSE getTime];
}
- (BOOL) fireECM
{
if ([super fireECM])
@ -5576,7 +5616,6 @@ static GLfloat sBaseMass = 0.0;
if (amount > 0.0)
{
internal_damage = ((ranrot_rand() & PLAYER_INTERNAL_DAMAGE_FACTOR) < amount); // base chance of damage to systems
energy -= amount;
[self playDirectHit:relative];
if (ship_temperature < SHIP_MAX_CABIN_TEMP)
@ -5605,7 +5644,15 @@ static GLfloat sBaseMass = 0.0;
}
else
{
if (internal_damage) [self takeInternalDamage];
while (amount > 0.0)
{
internal_damage = ((ranrot_rand() & PLAYER_INTERNAL_DAMAGE_FACTOR) < amount); // base chance of damage to systems
if (internal_damage)
{
[self takeInternalDamage];
}
amount -= (PLAYER_INTERNAL_DAMAGE_FACTOR + 1);
}
}
}
@ -5662,16 +5709,16 @@ static GLfloat sBaseMass = 0.0;
}
}
if (amount)
[super takeScrapeDamage:amount from:ent];
while (amount > 0.0)
{
internal_damage = ((ranrot_rand() & PLAYER_INTERNAL_DAMAGE_FACTOR) < amount); // base chance of damage to systems
}
[super takeScrapeDamage:amount from:ent];
if (internal_damage)
{
[self takeInternalDamage];
if (internal_damage)
{
[self takeInternalDamage];
}
amount -= (PLAYER_INTERNAL_DAMAGE_FACTOR + 1);
}
}
@ -7669,8 +7716,6 @@ static GLfloat sBaseMass = 0.0;
}
/* ends */
[[UNIVERSE gameView] clearMouse];
[self setShowDemoShips:NO];
[UNIVERSE enterGUIViewModeWithMouseInteraction:YES];

View File

@ -125,6 +125,10 @@ static BOOL weaponsOnlineToggle_pressed;
static BOOL escapePodKey_pressed;
static BOOL cycleMFD_pressed;
static BOOL switchMFD_pressed;
static BOOL mouse_left_down;
static NSPoint mouse_click_position;
static NSPoint centre_at_mouse_click;
static NSUInteger searchStringLength;
static double timeLastKeyPress;
@ -1584,6 +1588,7 @@ static NSTimeInterval time_last_frame;
{
MyOpenGLView *gameView = [UNIVERSE gameView];
BOOL moving = NO;
BOOL dragging = NO;
double cursor_speed = ([gameView isCtrlDown] ? 20.0 : 10.0)* chart_zoom;
GameController *controller = [UNIVERSE gameController];
GuiDisplayGen *gui = [UNIVERSE gui];
@ -1731,38 +1736,68 @@ static NSTimeInterval time_last_frame;
if ([gameView isDown:gvMouseLeftButton])
{
NSPoint maus = [gameView virtualJoystickPosition];
double vadjust = 80;
double hscale = MAIN_GUI_PIXEL_WIDTH / (64.0 * chart_zoom);
double vscale = MAIN_GUI_PIXEL_HEIGHT / (128.0 * chart_zoom);
NSPoint centre = [self adjusted_chart_centre];
cursor_coordinates.x = OOClamp_0_max_f(centre.x + (maus.x * MAIN_GUI_PIXEL_WIDTH) / hscale, 256.0);
cursor_coordinates.y = OOClamp_0_max_f(centre.y + (maus.y * MAIN_GUI_PIXEL_HEIGHT + vadjust) / vscale, 256.0);
double vadjust = MAIN_GUI_PIXEL_HEIGHT/2.0 - CHART_SCREEN_VERTICAL_CENTRE;
double hscale = MAIN_GUI_PIXEL_WIDTH / (64.0 * chart_zoom);
double vscale = MAIN_GUI_PIXEL_HEIGHT / (128.0 * chart_zoom);
if (mouse_left_down == NO)
{
NSPoint centre = [self adjusted_chart_centre];
centre_at_mouse_click = chart_centre_coordinates;
mouse_click_position = maus;
chart_focus_coordinates.x = OOClamp_0_max_f(centre.x + (maus.x * MAIN_GUI_PIXEL_WIDTH) / hscale, 256.0);
chart_focus_coordinates.y = OOClamp_0_max_f(centre.y + (maus.y * MAIN_GUI_PIXEL_HEIGHT + vadjust) / vscale, 256.0);
}
if (fabs(maus.x - mouse_click_position.x)*MAIN_GUI_PIXEL_WIDTH > 2 ||
fabs(maus.y - mouse_click_position.y)*MAIN_GUI_PIXEL_HEIGHT > 2)
{
target_chart_centre.x = OOClamp_0_max_f(centre_at_mouse_click.x - (maus.x - mouse_click_position.x)*MAIN_GUI_PIXEL_WIDTH/hscale, 256.0);
target_chart_centre.y = OOClamp_0_max_f(centre_at_mouse_click.y - (maus.y - mouse_click_position.y)*MAIN_GUI_PIXEL_HEIGHT/vscale, 256.0);
dragging = YES;
}
if (gui_screen == GUI_SCREEN_LONG_RANGE_CHART)
[gameView resetTypedString];
moving = YES;
mouse_left_down = YES;
}
else if (mouse_left_down == YES)
{
NSPoint maus = [gameView virtualJoystickPosition];
if (fabs(maus.x - mouse_click_position.x)*MAIN_GUI_PIXEL_WIDTH <= 2 &&
fabs(maus.y - mouse_click_position.y)*MAIN_GUI_PIXEL_HEIGHT <= 2)
{
cursor_coordinates = chart_focus_coordinates;
moving = YES;
}
else
{
dragging = YES;
}
mouse_left_down = NO;
}
if ([gameView isDown:gvMouseDoubleClick])
{
[gameView clearMouse];
mouse_left_down = NO;
[self noteGUIWillChangeTo:GUI_SCREEN_SYSTEM_DATA];
[self setGuiToSystemDataScreen];
break;
}
if ([gameView isDown:key_map_home])
{
[gameView resetTypedString];
cursor_coordinates = galaxy_coordinates;
chart_focus_coordinates = cursor_coordinates;
target_chart_centre = galaxy_coordinates;
found_system_seed = kNilRandomSeed;
[UNIVERSE findSystemCoordinatesWithPrefix:@""];
moving = YES;
}
if ([gameView isDown:gvPageDownKey])
if ([gameView isDown:gvPageDownKey] || [gameView mouseWheelState] == gvMouseWheelDown)
{
target_chart_zoom *=1.02;
target_chart_zoom *= CHART_ZOOM_SPEED_FACTOR;
if (target_chart_zoom > CHART_MAX_ZOOM) target_chart_zoom = CHART_MAX_ZOOM;
moving = YES;
}
if ([gameView isDown:gvPageUpKey])
if ([gameView isDown:gvPageUpKey] || [gameView mouseWheelState] == gvMouseWheelUp)
{
if (gui_screen == GUI_SCREEN_LONG_RANGE_CHART)
{
@ -1770,10 +1805,11 @@ static NSTimeInterval time_last_frame;
target_chart_zoom = CHART_MAX_ZOOM;
[gui clearAndKeepBackground: YES];
}
target_chart_zoom /= 1.02;
target_chart_zoom /= CHART_ZOOM_SPEED_FACTOR;
if (target_chart_zoom < 1.0) target_chart_zoom = 1.0;
moving = YES;
target_chart_centre = cursor_coordinates;
chart_focus_coordinates = target_chart_centre;
}
BOOL nextSystem = [gameView isShiftDown];
@ -1792,6 +1828,7 @@ static NSTimeInterval time_last_frame;
if (cursor_coordinates.x < 0.0) cursor_coordinates.x = 0.0;
moving = YES;
}
chart_focus_coordinates = cursor_coordinates;
}
else
pressedArrow = pressedArrow == key_gui_arrow_left ? 0 : pressedArrow;
@ -1810,6 +1847,7 @@ static NSTimeInterval time_last_frame;
if (cursor_coordinates.x > 256.0) cursor_coordinates.x = 256.0;
moving = YES;
}
chart_focus_coordinates = cursor_coordinates;
}
else
pressedArrow = pressedArrow == key_gui_arrow_right ? 0 : pressedArrow;
@ -1828,6 +1866,7 @@ static NSTimeInterval time_last_frame;
if (cursor_coordinates.y > 256.0) cursor_coordinates.y = 256.0;
moving = YES;
}
chart_focus_coordinates = cursor_coordinates;
}
else
pressedArrow = pressedArrow == key_gui_arrow_down ? 0 : pressedArrow;
@ -1846,6 +1885,7 @@ static NSTimeInterval time_last_frame;
if (cursor_coordinates.y < 0.0) cursor_coordinates.y = 0.0;
moving = YES;
}
chart_focus_coordinates = cursor_coordinates;
}
else
pressedArrow = pressedArrow == key_gui_arrow_up ? 0 : pressedArrow;
@ -1856,29 +1896,30 @@ static NSTimeInterval time_last_frame;
target_system_seed = [UNIVERSE findSystemAtCoords:cursor_coordinates withGalaxySeed:galaxy_seed];
cursor_coordinates.x = target_system_seed.d;
cursor_coordinates.y = target_system_seed.b;
chart_focus_coordinates = cursor_coordinates;
}
if (cursor_coordinates.x - target_chart_centre.x <= -CHART_SCROLL_AT_X*chart_zoom)
if (chart_focus_coordinates.x - target_chart_centre.x <= -CHART_SCROLL_AT_X*chart_zoom)
{
target_chart_centre.x = cursor_coordinates.x + CHART_SCROLL_AT_X*chart_zoom;
target_chart_centre.x = chart_focus_coordinates.x + CHART_SCROLL_AT_X*chart_zoom;
}
else if (cursor_coordinates.x - target_chart_centre.x >= CHART_SCROLL_AT_X*chart_zoom)
else if (chart_focus_coordinates.x - target_chart_centre.x >= CHART_SCROLL_AT_X*chart_zoom)
{
target_chart_centre.x = cursor_coordinates.x - CHART_SCROLL_AT_X*chart_zoom;
target_chart_centre.x = chart_focus_coordinates.x - CHART_SCROLL_AT_X*chart_zoom;
}
if (cursor_coordinates.y - target_chart_centre.y <= -CHART_SCROLL_AT_Y*chart_zoom)
if (chart_focus_coordinates.y - target_chart_centre.y <= -CHART_SCROLL_AT_Y*chart_zoom)
{
target_chart_centre.y = cursor_coordinates.y + CHART_SCROLL_AT_Y*chart_zoom;
target_chart_centre.y = chart_focus_coordinates.y + CHART_SCROLL_AT_Y*chart_zoom;
}
else if (cursor_coordinates.y - target_chart_centre.y >= CHART_SCROLL_AT_Y*chart_zoom)
else if (chart_focus_coordinates.y - target_chart_centre.y >= CHART_SCROLL_AT_Y*chart_zoom)
{
target_chart_centre.y = cursor_coordinates.y - CHART_SCROLL_AT_Y*chart_zoom;
target_chart_centre.y = chart_focus_coordinates.y - CHART_SCROLL_AT_Y*chart_zoom;
}
chart_centre_coordinates.x = (3.0*chart_centre_coordinates.x + target_chart_centre.x)/4.0;
chart_centre_coordinates.y = (3.0*chart_centre_coordinates.y + target_chart_centre.y)/4.0;
chart_zoom = (3.0*chart_zoom + target_chart_zoom)/4.0;
chart_cursor_coordinates.x = (3.0*chart_cursor_coordinates.x + cursor_coordinates.x)/4.0;
chart_cursor_coordinates.y = (3.0*chart_cursor_coordinates.y + cursor_coordinates.y)/4.0;
if (cursor_moving) [self setGuiToChartScreenFrom: gui_screen]; // update graphics
if (cursor_moving || dragging) [self setGuiToChartScreenFrom: gui_screen]; // update graphics
cursor_moving = moving;
}
@ -3295,6 +3336,8 @@ static NSTimeInterval time_last_frame;
if (([gameView isDown:gvFunctionKey6])||(fKeyAlias && [gameView isDown:key_gui_chart_screens]))
{
mouse_left_down = NO;
[gameView clearMouse];
if (!switching_chart_screens)
{
switching_chart_screens = YES;

View File

@ -625,29 +625,28 @@ static uint16_t PersonalityForCommanderDict(NSDictionary *dict);
if (loadedOK)
{
BOOL strict = [fileDic oo_boolForKey:@"strict" defaultValue:NO];
if (![UNIVERSE setStrict:strict fromSaveGame:YES])
NSString *scenarioRestrict = [fileDic oo_stringForKey:@"scenario_restriction" defaultValue:nil];
if (scenarioRestrict == nil)
{
// older save game - use the 'strict' key instead
BOOL strict = [fileDic oo_boolForKey:@"strict" defaultValue:NO];
if (strict)
{
scenarioRestrict = SCENARIO_OXP_DEFINITION_NONE;
}
else
{
scenarioRestrict = SCENARIO_OXP_DEFINITION_ALL;
}
}
if (![UNIVERSE setUseAddOns:scenarioRestrict fromSaveGame:YES])
{
fail_reason = DESC(@"loadfailed-saved-game-failed-to-load");
loadedOK = NO;
}
}
}
if (loadedOK)
{
NSString *shipKey = nil;
NSDictionary *shipDict = nil;
shipKey = [fileDic oo_stringForKey:@"ship_desc"];
shipDict = [[OOShipRegistry sharedRegistry] shipInfoForKey:shipKey];
if (shipDict == nil && [UNIVERSE strict] && shipKey != nil)
{
fail_reason = [NSString stringWithFormat:DESC(@"loadfailed-could-not-use-ship-type-@-please-switch-to-unrestricted"), shipKey];
loadedOK = NO;
}
}
if (loadedOK)
{
@ -1233,9 +1232,9 @@ NSComparisonResult sortCommanders(id cdr1, id cdr2, void *context)
{
[self showShipyardModel:@"oolite-unknown-ship" shipData:nil personality:personality];
shipName = [cdr oo_stringForKey:@"ship_name" defaultValue:@"unknown"];
if ([UNIVERSE strict])
if (![[UNIVERSE useAddOns] isEqualToString:SCENARIO_OXP_DEFINITION_ALL])
{
shipName = [shipName stringByAppendingString:@" - OXPs disabled"];
shipName = [shipName stringByAppendingString:@" - OXPs disabled or not installed"];
}
else
{

View File

@ -60,8 +60,9 @@
#define SHIP_COOLING_FACTOR 0.1f
// heat taken from energy damage depends on mass
// but limit heating at maximum to the rate of a Cobra III
#define SHIP_ENERGY_DAMAGE_TO_HEAT_FACTOR (mass > 215000 ? 215000 / mass : 1.0)
// but limit maximum rate since masses vary so much
// Cobra III ~=215000
#define SHIP_ENERGY_DAMAGE_TO_HEAT_FACTOR (mass > 400000 ? 200000 / mass : 0.5)
#define SHIP_INSULATION_FACTOR 0.00175f
#define SHIP_MAX_CABIN_TEMP 256.0f
#define SHIP_MIN_CABIN_TEMP 60.0f

View File

@ -1575,7 +1575,7 @@ static OOTextureSprite *NewTextureSpriteWithDescriptor(NSDictionary *descriptor)
double hcenter = size_in_pixels.width/2.0;
double hscale = size_in_pixels.width / (CHART_WIDTH_AT_MAX_ZOOM*zoom);
double vscale = -size_in_pixels.height / (2*CHART_HEIGHT_AT_MAX_ZOOM*zoom);
double vcenter = 10*MAIN_GUI_ROW_HEIGHT;
double vcenter = CHART_SCREEN_VERTICAL_CENTRE;
double hoffset = hcenter - chart_centre_coordinates.x*hscale;
double voffset = size_in_pixels.height - vcenter - chart_centre_coordinates.y*vscale;
int i;

View File

@ -1190,6 +1190,12 @@ static void prefetchData(NSDictionary *info, struct CachedInfo *data)
ms_blip -= floor(ms_blip);
relativePosition = [PLAYER vectorTo:scannedEntity];
double fuzz = [PLAYER scannerFuzziness];
if (fuzz > 0)
{
relativePosition = vector_add(relativePosition,OOVectorRandomRadial(fuzz));
}
Vector rp = relativePosition;
if (act_dist > max_zoomed_range)

View File

@ -39,14 +39,15 @@ static NSString * const kOOManifestFileSize = @"file_size";
static NSString * const kOOManifestInformationURL = @"information_url";
static NSString * const kOOManifestAuthor = @"author";
static NSString * const kOOManifestLicense = @"license";
static NSString * const kOOManifestTags = @"tags";
/* these properties are not contained in the manifest.plist (and would be
overwritten if they were...) but are calculated by Oolite */
static NSString * const kOOManifestFilePath = @"file_path";
static NSString * const kOOManifestRequiredBy = @"required_by";
static NSString * const kOOManifestAvailableVersion = @"available_version";
// following manifest.plist properties not (yet?) used by Oolite
// but may be used by other manifest reading applications
#if 0
static NSString * const kOOManifestTags = @"tags";
static NSString * const kOOManifestOptionalOXPs = @"optional_oxps";
#endif

View File

@ -865,7 +865,7 @@ static OOOXZManager *sSingleton = nil;
{
// Rebuilds OXP search
[ResourceManager reset];
[UNIVERSE reinitAndShowDemo:YES strictChanged:YES];
[UNIVERSE reinitAndShowDemo:YES];
_changesMade = NO;
_interfaceState = OXZ_STATE_MAIN;
_downloadStatus = OXZ_DOWNLOAD_NONE; // clear error state

View File

@ -281,7 +281,11 @@ static void OpenLogFile(NSString *name);
*/
[[OOCacheManager sharedCache] flush];
[[OOCacheManager sharedCache] setAllowCacheWrites:NO];
[ResourceManager setUseAddOns:NO];
/* FIXME: the OXP verifier should load files from OXPs which have
* been explicitly listed as required_oxps in the
* manifest. Reading the manifest from the OXP being verified and
* setting 'id:<its identifier>' below will do this. */
[ResourceManager setUseAddOns:SCENARIO_OXP_DEFINITION_NONE];
SwitchLogFile(_displayName);
OOLog(@"verifyOXP.start", @"Running OXP verifier for %@", _basePath);//_displayName);

View File

@ -38,6 +38,10 @@ typedef enum
MERGE_SMART // Merge files by merging the top-level elements of each file (second-order merge, but not recursive)
} OOResourceMergeMode;
#define SCENARIO_OXP_DEFINITION_ALL @""
#define SCENARIO_OXP_DEFINITION_NONE @"strict"
#define SCENARIO_OXP_DEFINITION_BYID @"id:"
#define SCENARIO_OXP_DEFINITION_BYTAG @"tag:"
@interface ResourceManager : NSObject
@ -50,9 +54,9 @@ typedef enum
+ (NSString *)builtInPath; // Path for built-in data only.
+ (NSArray *)pathsWithAddOns; // Root paths + add-on paths.
+ (NSArray *)paths; // builtInPath or pathsWithAddOns, depending on useAddOns state.
+ (BOOL)useAddOns;
+ (NSString *)useAddOns;
+ (NSArray *)OXPsWithMessagesFound;
+ (void)setUseAddOns:(BOOL)useAddOns;
+ (void)setUseAddOns:(NSString *)useAddOns;
+ (void)addExternalPath:(NSString *)fileName;
+ (NSEnumerator *)pathEnumerator;
+ (NSEnumerator *)reversePathEnumerator;

View File

@ -66,6 +66,11 @@ extern NSDictionary* ParseOOSScripts(NSString* script);
+ (BOOL) areRequirementsFulfilled:(NSDictionary*)requirements forOXP:(NSString *)path andFile:(NSString *)file;
+ (void) filterSearchPathsForConflicts:(NSMutableArray *)searchPaths;
+ (BOOL) filterSearchPathsForRequirements:(NSMutableArray *)searchPaths;
+ (void) filterSearchPathsByScenario:(NSMutableArray *)searchPaths;
+ (BOOL) manifestAllowedByScenario:(NSDictionary *)manifest;
+ (BOOL) manifestAllowedByScenario:(NSDictionary *)manifest withIdentifier:(NSString *)identifier;
+ (BOOL) manifestAllowedByScenario:(NSDictionary *)manifest withTag:(NSString *)tag;
+ (void) addErrorWithKey:(NSString *)descriptionKey param1:(id)param1 param2:(id)param2;
+ (BOOL) checkCacheUpToDateForPaths:(NSArray *)searchPaths;
+ (void) logPaths;
@ -80,13 +85,16 @@ extern NSDictionary* ParseOOSScripts(NSString* script);
static NSMutableArray *sSearchPaths;
static BOOL sUseAddOns = YES;
static NSString *sUseAddOns;
static BOOL sFirstRun = YES;
static BOOL sAllMet = NO;
static NSMutableArray *sOXPsWithMessagesFound;
static NSMutableArray *sExternalPaths;
static NSMutableArray *sErrors;
static NSMutableDictionary *sOXPManifests;
// caches allow us to load any given file once only
//
static NSMutableDictionary *sSoundCache;
@ -99,7 +107,7 @@ static NSMutableDictionary *sStringCache;
+ (void) reset
{
sFirstRun = YES;
sUseAddOns = YES;
DESTROY(sUseAddOns);
DESTROY(sSearchPaths);
DESTROY(sOXPsWithMessagesFound);
DESTROY(sExternalPaths);
@ -110,6 +118,7 @@ static NSMutableDictionary *sStringCache;
+ (void) resetManifestKnowledgeForOXZManager
{
DESTROY(sUseAddOns);
DESTROY(sSearchPaths);
DESTROY(sOXPManifests);
[ResourceManager pathsWithAddOns];
@ -213,7 +222,18 @@ static NSMutableDictionary *sStringCache;
+ (NSArray *)pathsWithAddOns
{
if ([sSearchPaths count] > 0) return sSearchPaths;
if (sUseAddOns == nil)
{
sUseAddOns = [[NSString alloc] initWithString:SCENARIO_OXP_DEFINITION_ALL];
}
/* Handle special case of 'strict mode' efficiently */
if ([sUseAddOns isEqualToString:SCENARIO_OXP_DEFINITION_NONE])
{
return (NSArray *)[NSArray arrayWithObject:[self builtInPath]];
}
[sErrors release];
sErrors = nil;
@ -298,6 +318,7 @@ static NSMutableDictionary *sStringCache;
* loading OXPs which we shouldn't; if doing so takes out other
* OXPs which would have been safe, that's not important. */
[self filterSearchPathsForConflicts:sSearchPaths];
/* This one needs to be run repeatedly to be sure. Take the chain
* A depends on B depends on C. A and B are installed. A is
* checked first, and depends on B, which is thought to be
@ -310,6 +331,13 @@ static NSMutableDictionary *sStringCache;
*/
while (![self filterSearchPathsForRequirements:sSearchPaths]) {}
/* If a scenario restriction is in place, restrict OXPs to the
* ones valid for the scenario only. */
if (![sUseAddOns isEqualToString:SCENARIO_OXP_DEFINITION_ALL])
{
[self filterSearchPathsByScenario:sSearchPaths];
}
[self checkCacheUpToDateForPaths:sSearchPaths];
return sSearchPaths;
@ -427,32 +455,33 @@ static NSMutableDictionary *sStringCache;
{
if (EXPECT_NOT(sSearchPaths == nil))
{
if (!sUseAddOns)
{
sSearchPaths = [[NSMutableArray alloc] init];
}
sSearchPaths = [[NSMutableArray alloc] init];
}
return sUseAddOns ? [self pathsWithAddOns] : (NSArray *)[NSArray arrayWithObject:[self builtInPath]];
return [self pathsWithAddOns];
}
+ (BOOL)useAddOns
+ (NSString *)useAddOns
{
return sUseAddOns;
}
+ (void)setUseAddOns:(BOOL)useAddOns
+ (void)setUseAddOns:(NSString *)useAddOns
{
if (sFirstRun || sUseAddOns != useAddOns)
if (sFirstRun || ![useAddOns isEqualToString:sUseAddOns])
{
[self reset];
sFirstRun = NO;
sUseAddOns = useAddOns;
sUseAddOns = [useAddOns retain];
[ResourceManager clearCaches];
OOHUDResetTextEngine();
OOCacheManager *cmgr = [OOCacheManager sharedCache];
if (sUseAddOns)
/* only allow cache writes for the "all OXPs" default
*
* cache should be less necessary for restricted sets anyway */
if ([sUseAddOns isEqualToString:SCENARIO_OXP_DEFINITION_ALL])
{
[cmgr reloadAllCaches];
[cmgr setAllowCacheWrites:YES];
@ -561,11 +590,15 @@ static NSMutableDictionary *sStringCache;
[self addErrorWithKey:@"oxz-lacks-manifest" param1:[path lastPathComponent] param2:nil];
return;
}
else
{
// make up a basic manifest
manifest = [NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"__oolite.tmp.%@",path],kOOManifestIdentifier,@"1",kOOManifestVersion,@"OXP without manifest",kOOManifestTitle,@"1",kOOManifestRequiredOoliteVersion,nil];
}
}
else
{
requirementsMet = [self validateManifest:manifest forOXP:path];
}
requirementsMet = [self validateManifest:manifest forOXP:path];
if (requirementsMet)
{
@ -811,7 +844,7 @@ static NSMutableDictionary *sStringCache;
+ (BOOL) manifest:(NSDictionary *)manifest HasUnmetDependency:(NSDictionary *)required logErrors:(BOOL)logErrors
{
NSString *requiredID = [required oo_stringForKey:kOOManifestRelationIdentifier];
NSDictionary *requiredManifest = [sOXPManifests objectForKey:requiredID];
NSMutableDictionary *requiredManifest = [sOXPManifests objectForKey:requiredID];
// if the other OXP is in the list
BOOL requirementsMet = NO;
if (requiredManifest != nil)
@ -820,6 +853,26 @@ static NSMutableDictionary *sStringCache;
if ([self matchVersions:required withVersion:[requiredManifest oo_stringForKey:kOOManifestVersion]])
{
requirementsMet = YES;
/* Mark the requiredManifest as a dependency of the
* requiring manifest */
NSSet *reqby = [requiredManifest oo_setForKey:kOOManifestRequiredBy defaultValue:[NSSet set]];
NSUInteger reqbycount = [reqby count];
/* then add this manifest to its required set. This is
* done without checking if it's already there, because
* the list of nested requirements may have changed. */
reqby = [reqby setByAddingObject:[manifest oo_stringForKey:kOOManifestIdentifier]];
// *and* anything that requires this OXP to be installed
reqby = [reqby setByAddingObjectsFromSet:[manifest oo_setForKey:kOOManifestRequiredBy]];
if (reqbycount < [reqby count])
{
/* Then the set has increased in size. To handle
* potential cases with nested dependencies, need to
* re-run the requirement filter until all the sets
* stabilise. */
sAllMet = NO;
}
// and push back into the requiring manifest
[requiredManifest setObject:reqby forKey:kOOManifestRequiredBy];
}
}
if (!requirementsMet)
@ -841,7 +894,7 @@ static NSMutableDictionary *sStringCache;
NSString *identifier = nil;
NSArray *identifiers = [sOXPManifests allKeys];
BOOL allMet = YES;
sAllMet = YES;
// take a copy because we'll mutate the original
// foreach identified add-on
@ -855,12 +908,12 @@ static NSMutableDictionary *sStringCache;
// then we have a missing requirement, so remove this path
[searchPaths removeObject:[manifest oo_stringForKey:kOOManifestFilePath]];
[sOXPManifests removeObjectForKey:identifier];
allMet = NO;
sAllMet = NO;
}
}
}
return allMet;
return sAllMet;
}
@ -893,6 +946,108 @@ static NSMutableDictionary *sStringCache;
}
+ (void) filterSearchPathsByScenario:(NSMutableArray *)searchPaths
{
NSDictionary *manifest = nil;
NSString *identifier = nil;
NSArray *identifiers = [sOXPManifests allKeys];
// take a copy because we'll mutate the original
// foreach identified add-on
foreach (identifier, identifiers)
{
manifest = [sOXPManifests objectForKey:identifier];
if (manifest != nil)
{
if (![ResourceManager manifestAllowedByScenario:manifest])
{
// then we don't need this one
[searchPaths removeObject:[manifest oo_stringForKey:kOOManifestFilePath]];
[sOXPManifests removeObjectForKey:identifier];
}
}
}
}
+ (BOOL) manifestAllowedByScenario:(NSDictionary *)manifest
{
/* Checks for a couple of "never happens" cases */
#ifndef NDEBUG
if ([sUseAddOns isEqualToString:SCENARIO_OXP_DEFINITION_ALL])
{
OOLog(@"scenario.check",@"Checked scenario allowances in all state - this is an internal error; please report this");
return YES;
}
if ([sUseAddOns isEqualToString:SCENARIO_OXP_DEFINITION_NONE])
{
OOLog(@"scenario.check",@"Checked scenario allowances in none state - this is an internal error; please report this");
return NO;
}
#endif
if ([[manifest oo_stringForKey:kOOManifestIdentifier] isEqualToString:@"org.oolite.oolite"])
{
// the core data is always allowed!
return YES;
}
if ([sUseAddOns hasPrefix:SCENARIO_OXP_DEFINITION_BYID])
{
return [ResourceManager manifestAllowedByScenario:manifest withIdentifier:[sUseAddOns substringFromIndex:[SCENARIO_OXP_DEFINITION_BYID length]]];
}
else
{
return [ResourceManager manifestAllowedByScenario:manifest withTag:[sUseAddOns substringFromIndex:[SCENARIO_OXP_DEFINITION_BYTAG length]]];
}
}
+ (BOOL) manifestAllowedByScenario:(NSDictionary *)manifest withIdentifier:(NSString *)identifier
{
if ([[manifest oo_stringForKey:kOOManifestIdentifier] isEqualToString:identifier])
{
// manifest has the identifier - easy
return YES;
}
// manifest is also allowed if a manifest with that identifier
// requires it to be installed
if ([[manifest oo_setForKey:kOOManifestRequiredBy] containsObject:identifier])
{
return YES;
}
// otherwise, no
return NO;
}
+ (BOOL) manifestAllowedByScenario:(NSDictionary *)manifest withTag:(NSString *)tag
{
if ([[manifest oo_arrayForKey:kOOManifestTags] containsObject:tag])
{
// manifest has the tag - easy
return YES;
}
// manifest is also allowed if a manifest with that tag
// requires it to be installed
NSSet *reqby = [manifest oo_setForKey:kOOManifestRequiredBy];
if (reqby != nil)
{
NSString *identifier = nil;
foreach (identifier, reqby)
{
NSDictionary *reqManifest = [sOXPManifests oo_dictionaryForKey:identifier defaultValue:nil];
// need to check for nil as this one may already have been ruled out
if (reqManifest != nil && [[reqManifest oo_arrayForKey:kOOManifestTags] containsObject:tag])
{
return YES;
}
}
}
// otherwise, no
return NO;
}
+ (void) addErrorWithKey:(NSString *)descriptionKey param1:(id)param1 param2:(id)param2
{
@ -1723,22 +1878,15 @@ static NSString *LogClassKeyRoot(NSString *key)
NSEnumerator *pathEnum = nil;
NSString *path = nil;
if (sUseAddOns)
// Prettify paths for logging.
displayPaths = [NSMutableArray arrayWithCapacity:[sSearchPaths count]];
for (pathEnum = [sSearchPaths objectEnumerator]; (path = [pathEnum nextObject]); )
{
// Prettify paths for logging.
displayPaths = [NSMutableArray arrayWithCapacity:[sSearchPaths count]];
for (pathEnum = [sSearchPaths objectEnumerator]; (path = [pathEnum nextObject]); )
{
[displayPaths addObject:[[path stringByStandardizingPath] stringByAbbreviatingWithTildeInPath]];
}
OOLog(@"searchPaths.dumpAll", @"Unrestricted mode - resource paths:\n %@", [displayPaths componentsJoinedByString:@"\n "]);
}
else
{
OOLog(@"searchPaths.dumpAll", @"Strict mode - resource path:\n %@",
[[[self builtInPath] stringByStandardizingPath] stringByAbbreviatingWithTildeInPath]);
[displayPaths addObject:[[path stringByStandardizingPath] stringByAbbreviatingWithTildeInPath]];
}
OOLog(@"searchPaths.dumpAll", @"Resource paths: %@\n %@", sUseAddOns, [displayPaths componentsJoinedByString:@"\n "]);
}

View File

@ -610,7 +610,9 @@ static JSFunctionSpec sScriptMethods[] =
NSString *manifestPath = [[[path stringByDeletingLastPathComponent] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"manifest.plist"];
NSDictionary *manifest = OODictionaryFromFile(manifestPath);
NSMutableDictionary *properties = [NSMutableDictionary dictionaryWithCapacity:3];
if (manifest != nil)
/* __oolite.tmp.* is allocated for OXPs without manifests. Its
* values are meaningless and shouldn't be used here */
if (manifest != nil && ![[manifest oo_stringForKey:kOOManifestIdentifier] hasPrefix:@"__oolite.tmp."])
{
if ([manifest objectForKey:kOOManifestVersion] != nil)
{

View File

@ -283,7 +283,7 @@ enum
NSArray *closeSystems;
BOOL strict;
NSString *useAddOns;
BOOL no_update;
@ -340,13 +340,10 @@ enum
- (BOOL) doProcedurallyTexturedPlanets;
- (void) setDoProcedurallyTexturedPlanets:(BOOL) value;
- (BOOL) strict;
- (BOOL) setStrict:(BOOL) value;
- (BOOL) setStrict:(BOOL)value fromSaveGame: (BOOL)saveGame;
- (NSString *) useAddOns;
- (BOOL) setUseAddOns:(NSString *)newUse fromSaveGame: (BOOL)saveGame;
- (void) reinitAndShowDemo:(BOOL)showDemo;
// called from OXZ manager
- (BOOL) reinitAndShowDemo:(BOOL) showDemo strictChanged:(BOOL) strictChanged;
- (BOOL) reinitAndShowDemo:(BOOL)showDemo;
- (BOOL) doingStartUp; // True during initial game startup (not reset).

View File

@ -266,7 +266,7 @@ static GLfloat docked_light_specular[4] = { DOCKED_ILLUM_LEVEL, DOCKED_ILLUM_LEV
// prefs value no longer used - per save game but startup needs to
// be non-strict
strict = NO;
useAddOns = [[NSString alloc] initWithString:SCENARIO_OXP_DEFINITION_ALL];
[self setGameView:inGameView];
gSharedUniverse = self;
@ -292,8 +292,7 @@ static GLfloat docked_light_specular[4] = { DOCKED_ILLUM_LEVEL, DOCKED_ILLUM_LEV
#endif
// init the Resource Manager
[ResourceManager setUseAddOns:!strict]; // also logs the paths if changed
//[ResourceManager paths]; // called inside setUseAddOns...
[ResourceManager setUseAddOns:useAddOns]; // also logs the paths if changed
// Set up the internal game strings
[self loadDescriptions];
@ -498,43 +497,26 @@ static GLfloat docked_light_specular[4] = { DOCKED_ILLUM_LEVEL, DOCKED_ILLUM_LEV
}
/* From 1.79, "strict mode" is "no OXPs mode" as a useful debug tool,
* nothing else */
- (BOOL) strict
- (NSString *) useAddOns
{
return strict;
return useAddOns;
}
- (BOOL) setStrict:(BOOL)value
- (BOOL) setUseAddOns:(NSString *) newUse fromSaveGame:(BOOL) saveGame
{
return [self setStrict:value fromSaveGame:NO];
}
- (BOOL) setStrict:(BOOL) value fromSaveGame:(BOOL) saveGame
{
if (strict == value) return YES;
strict = !!value;
return [self reinitAndShowDemo:!saveGame strictChanged:YES];
}
- (void) reinitAndShowDemo:(BOOL) showDemo
{
if (strict && showDemo)
if ([newUse isEqualToString:useAddOns])
{
[self setStrict:NO];
[self reinitAndShowDemo:showDemo strictChanged:YES];
}
else
{
[self reinitAndShowDemo:showDemo strictChanged:NO];
return YES;
}
DESTROY(useAddOns);
useAddOns = [newUse retain];
return [self reinitAndShowDemo:!saveGame];
}
- (NSUInteger) entityCount
{
return [entities count];
@ -10204,7 +10186,7 @@ static OOComparisonResult comparePrice(id dict1, id dict2, void *context)
// FIXME: needs less redundancy?
- (BOOL) reinitAndShowDemo:(BOOL) showDemo strictChanged:(BOOL) strictChanged
- (BOOL) reinitAndShowDemo:(BOOL) showDemo
{
no_update = YES;
PlayerEntity* player = PLAYER;
@ -10213,11 +10195,10 @@ static OOComparisonResult comparePrice(id dict1, id dict2, void *context)
if (JSResetFlags != 0) // JS reset failed, remember previous settings
{
showDemo = (JSResetFlags & 2) > 0; // binary 10, a.k.a. 1 << 1
strictChanged = (JSResetFlags & 1) > 0; // binary 01
}
else
{
JSResetFlags = (showDemo << 1) | strictChanged;
JSResetFlags = (showDemo << 1);
}
[self removeAllEntitiesExceptPlayer];
@ -10226,7 +10207,7 @@ static OOComparisonResult comparePrice(id dict1, id dict2, void *context)
_sessionID++; // Must be after removing old entities and before adding new ones.
[ResourceManager setUseAddOns:!strict]; // also logs the paths
[ResourceManager setUseAddOns:useAddOns]; // also logs the paths
//[ResourceManager loadScripts]; // initialised inside [player setUp]!
// NOTE: Anything in the sharedCache is now trashed and must be
@ -10238,14 +10219,12 @@ static OOComparisonResult comparePrice(id dict1, id dict2, void *context)
[[self gameController] setMouseInteractionModeForUIWithMouseInteraction:NO];
[PLAYER setSpeed:0.0];
if (strictChanged)
{
[self loadDescriptions];
[self loadScenarios];
[missiontext autorelease];
missiontext = [[ResourceManager dictionaryFromFilesNamed:@"missiontext.plist" inFolder:@"Config" andMerge:YES] retain];
}
[self loadDescriptions];
[self loadScenarios];
[missiontext autorelease];
missiontext = [[ResourceManager dictionaryFromFilesNamed:@"missiontext.plist" inFolder:@"Config" andMerge:YES] retain];
if(showDemo)
{

View File

@ -41,6 +41,7 @@ MA 02110-1301, USA.
#define NUM_KEYS 320
#define MOUSE_DOUBLE_CLICK_INTERVAL 0.40
#define OOMOUSEWHEEL_EVENTS_DELAY_INTERVAL 0.05
#define SNAPSHOTS_PNG_FORMAT 1
@ -93,6 +94,13 @@ enum GameViewKeys
gvNumberPadKey9 //319
};
enum MouseWheelStatus
{
gvMouseWheelDown = -1,
gvMouseWheelNeutral,
gvMouseWheelUp
};
enum StringInput
{
gvStringInputNo = 0,
@ -128,6 +136,7 @@ extern int debug;
BOOL mouseWarped;
NSTimeInterval timeIntervalAtLastClick;
NSTimeInterval timeSinceLastMouseWheel;
BOOL doubleClick;
NSMutableString *typedString;
@ -167,7 +176,9 @@ extern int debug;
NSSize firstScreen;
// Mouse mode indicator (for mouse movement model)
BOOL mouseInDeltaMode;
BOOL mouseInDeltaMode;
int _mouseWheelState;
}
- (void) initSplashScreen;
@ -241,6 +252,7 @@ extern int debug;
- (BOOL) isCommandDown;
- (BOOL) isShiftDown;
- (int) numKeys;
- (int) mouseWheelState;
// Command-key combinations need special handling. SDL stubs for these mac functions.
- (BOOL) isCommandQDown;

View File

@ -311,7 +311,9 @@ MA 02110-1301, USA.
allowingStringInput = gvStringInputNo;
isAlphabetKeyDown = NO;
timeIntervalAtLastClick = [NSDate timeIntervalSinceReferenceDate];
timeIntervalAtLastClick = timeSinceLastMouseWheel = [NSDate timeIntervalSinceReferenceDate];
_mouseWheelState = gvMouseWheelNeutral;
m_glContextInitialized = NO;
@ -1238,6 +1240,12 @@ MA 02110-1301, USA.
}
- (int) mouseWheelState
{
return _mouseWheelState;
}
- (BOOL) isCommandQDown
{
return NO;
@ -1281,6 +1289,7 @@ MA 02110-1301, USA.
int mxdelta, mydelta;
float mouseVirtualStickSensitivityX = viewSize.width * MOUSEVIRTUALSTICKSENSITIVITYFACTOR;
float mouseVirtualStickSensitivityY = viewSize.height * MOUSEVIRTUALSTICKSENSITIVITYFACTOR;
NSTimeInterval timeNow = [NSDate timeIntervalSinceReferenceDate];
while (SDL_PollEvent(&event))
@ -1309,12 +1318,20 @@ MA 02110-1301, USA.
so we use mouseWarped to simply ignore handling of motion events in this case. - Nikos 20110721
*/
[self resetMouse]; // Will set mouseWarped to YES
break;
// mousewheel stuff
case SDL_BUTTON_WHEELUP:
_mouseWheelState = gvMouseWheelUp;
break;
case SDL_BUTTON_WHEELDOWN:
_mouseWheelState = gvMouseWheelDown;
break;
}
break;
case SDL_MOUSEBUTTONUP:
mbtn_event = (SDL_MouseButtonEvent*)&event;
NSTimeInterval timeBetweenClicks = [NSDate timeIntervalSinceReferenceDate] - timeIntervalAtLastClick;
NSTimeInterval timeBetweenClicks = timeNow - timeIntervalAtLastClick;
timeIntervalAtLastClick += timeBetweenClicks;
if (mbtn_event->button == SDL_BUTTON_LEFT)
{
@ -1325,6 +1342,17 @@ MA 02110-1301, USA.
}
keys[gvMouseLeftButton] = NO;
}
/*
Mousewheel handling - just note time since last use here and mark as inactive,
if needed, at the end of this method. Note that the mousewheel button up event is
kind of special, as in, it is sent at the same time as its corresponding mousewheel
button down one - Nikos 20140809
*/
if (mbtn_event->button == SDL_BUTTON_WHEELUP || mbtn_event->button == SDL_BUTTON_WHEELDOWN)
{
NSTimeInterval timeBetweenMouseWheels = timeNow - timeSinceLastMouseWheel;
timeSinceLastMouseWheel += timeBetweenMouseWheels;
}
break;
case SDL_MOUSEMOTION:
@ -1810,6 +1838,12 @@ keys[a] = NO; keys[b] = NO; \
}
}
}
// check if enough time has passed since last use of the mousewheel and act
// if needed
if (timeNow >= timeSinceLastMouseWheel + OOMOUSEWHEEL_EVENTS_DELAY_INTERVAL)
{
_mouseWheelState = gvMouseWheelNeutral;
}
}