Fixed Room:onHumanoidLeave()'s callForStaff() condition

Staff will now always be called to use a room when a staff member
leaves before a patient has finished using the room. Before this
commit staff wouldn't be called if the room didn't have a queue.
Merge pull request #315 from J-Shep/fixedCallForStaffBug

Fixed Room:onHumanoidLeave()'s callForStaff() condition
If a handyman dies, deallocate him from his task

Fixes issue #62
Merge pull request #159 from alanwoolley/issue62

If a handyman dies, deallocate him from his task
Fix swapping surgeon mid-operation

See https://code.google.com/p/corsix-th/issues/detail?id=838

Thanks to this fix, one surgeon comes back to replace the picked up one (as he used to), but now washes his hands and restarts the operation. I also added a few changes for the sake of readability (e.g. a setter function to turn on/off the x-ray viewer), which helped me grasping the logic of the room behaviour.
Merge pull request #305 from benckx/issue838_fix
Added entity map for getting entities by absolute tile

Conflicts:
	CorsixTH/Lua/entities/object.lua
	CorsixTH/Lua/world.lua

Conflicts:
	CorsixTH/Lua/app.lua
	CorsixTH/Lua/world.lua
Epidemics - game logic including contagious patients and vaccinations.

Changes include:
  - Added contagious variable to all disease to determine which can be part
    of epidemics
  - Contagious patient can change the disease of a non-diagnosed patient
  - Game logic, faxes and win/lose conditions and resolution
  - Support for multiple epidemics in parallel - currently disabled for balance
  - Vaccinations - UI click behaviour and nurse dispatched humanoid actions.
  - Inspector humanoid class who visits to resolve epidemic cover up.
  - Conflict resolution between emergency and epidemic faxes
St. Peter's Level files with new epidemic variables
use_object: +destroy_user_after_use +after_walk_in

The "destroy_user_after_use" parameter is required by lava holes to prevent patients walking out after they've fallen in.

The "after_walk_in" parameter is required to make the grim reaper respond to the moment when the patient has walked on to the lava hole.

< "destroy_user_after_use" Changes @71 and @321
< "after_walk_in" Changes @282
+SDL SOUND_OVER Event & Support In Existing Audio Functions

Call stack for SOUND_OVER callbacks:
1. SDL_USEREEVNT_SOUND_OVER >
2. sdl_core.cpp: l_mainloop() >
3. app.lua:onSoundOver(callback_id) >
4. audio.lua:onSoundPlayed(callback_id) >
5. audio.lua.played_sound_callbacks[callback_id]()

Source code
-----------
1) lua_sdl.h:
+SDL_USEREEVNT_SOUND_OVER

2) sdl_core.cpp:
+SDL event switch statement case for SOUND_OVER events.

3) th_lua_sound.cpp:
a) +SOUND_OVER callback variables.
b) +SDL Timer callback function: played_sound_callback()
c) Made l_soundfx_play() support SOUND_OVER callbacks.

Lua
---
4) api_version.lua: 2037 > 2673

5) app.lua:
a) +onSoundOver()
b) +worldExited(): Required to call Audio:clearCallbacks()
c) +worldExited() calls

6) audio.lua:
a) +SOUND_OVER callback variables.
b) +clearCallbacks(): Required to clear the SOUND_OVER callbacks
c) +onSoundPlayed(): Executes SOUND_OVER callbacks.
d) Made playSound() support SOUND_OVER callbacks.

7) entity.lua:
Made playSound() support SOUND_OVER callbacks.

8) game_ui.lua:
Made playAnnouncement() support SOUND_OVER callbacks.

9) ui.lua:
a) Made playSound() support SOUND_OVER callbacks.
b) Made playAnnouncement() support SOUND_OVER callbacks.
New function: playSoundsAtEntityInRandomSequence()

This function is required to play the lava hole's sounds because its sounds are meant to be played in a random sequence and are therefore not associated with animation frames, so the animation code can't play these sounds.

Change list
-----------
1. app.lua:
a) SAVEGAME_VERSION = 87: Required in this commit because a new afterLoad() sound playing function has been added.
b) +afterLoad() call to world:playLoadedEntitySounds()

2. audio.lua:
a) +self.entities_waiting_for_sound_to_be_enabled{}: Required to support the resumption of sounds being played by this commit's new audio playing function.
b) +playSoundsAtEntityInRandomSequence()
c) +playSoundAtEntityInRandomSequenceRecursionHandler()
d) +getRandomSilenceLengths(): Required to provide different durations for the sound seperating pauses in this commit's new audio playing function.
e) Modified playSound(): Moved its sound caching statements into a new function to prevent them from having to be duplicated in this commit's new audio playing function.
f) +canSoundsBePlayed(): Required to support the resumption of sounds being played by this commit's new audio playing function.
g) +onEndPause(paused): Required to support the resumption of sounds being played by this commit's new audio playing function.
h) +tellInterestedEntitiesTheyCanNowPlaySounds(): Required to support the resumption of sounds being played by this commit's new audio playing function.
i) +calls to tellInterestedEntitiesTheyCanNowPlaySounds()
j) +entityNoLongerWaitingForSoundsToBeTurnedOn(entity): Required to prevent the resumption of sounds being played for an entity which no longer exists or no longer wants its sounds to be resumed.

3. entity.lua:
a) +Variables for this commit's new audio playing function.
b) +playSoundsAtEntityInRandomSequence()
c) +playAfterLoadSound(): Required to support the resumption of sounds being played by this commit's new audio playing function.
d) +setWaitingForSoundEffectsToBeTurnedOn(state): Required to call audio:entityNoLongerWaitingForSoundsToBeTurnedOn()

4. game_ui.lua:
Modified togglePlaySounds() so that the keyboard shortcut will have the same response as clicking the menu option allowing it to disable and enable sounds being played by this commit's new audio playing function.

5. world.lua:
a) +Call to audio:onEndPause(): Required to support the resumption of sounds being played by this commit's new audio playing function.
b) +isPaused(): Required to support the resumption of sounds being played by this commit's new audio playing function.
c) Modified afterLoad() to make it support the resumption of sounds being played by this commit's new audio playing function.
d) +playLoadedEntitySounds(): Required to support the resumption of sounds being played by this commit's new audio playing function.
Created world.lua "can object spawn at" check functions

Because lava holes are objects which spawn instead of being
placed this commit must implement the object spawn checking
function: world:wouldNonSideObjectBreakPathfindingIfSpawnedAt()

This new function performs the required spawn checks by calling
four new functions for each test, allowing these tests to also
be called in setBluePrintCell() when objects are being placed:
+ world:areFootprintTilesCoardinatesInvalid()
+ world:willObjectsFootprintTileBeWithinItsAllowedRoomIfLocatedAt()
+ world:checkFootprintCellsTileIsBuildableOrPassable()
+ world:wouldNonSideObjectBreakPathfindingIfSpawnedAt()

So this commit must also modify UIPlaceObjects:setBluePrintCell() by moving the
code for these tests into the new test functions.
Implemented Hell Deaths

1. New files:
a) /objects/gates_to_hell.lua
b) /entities/grimreaper.lua

2. app.lua:
Modified afterLoad() so that the gates_to_hell object will be added to a world's objects list when its loaded from an old saved game.

3. die.lua:
a) Modified action_die_start() so that males can either go to heaven or hell.
b) +action_die_tick_reaper: Makes hell deaths happen.

4. humanoid.lua:
a) Modefiend the die_anims() setting function to make it support the rise_hell_east animation.
b) Modified Humanoid_startAction(): So that grim reapers with no actions will have the idle action be their default action.

5. patient.lua:
a) +rise_hell_east death animation.
b) Modified afterLoad() to give patients the rise_hell_east animation when they don't have it.

6. world.lua:
a) +newObjectType(): I've created this function so that app.lua can use it to add the new gates_to_hell object to old worlds.
b) Modified objectPlaced() by adding statements to make it respond to the spawning of lava holes.
Merge pull request #229 from J-Shep/hell-deaths2
Merge pull request #88 from sadger/epidemics

Conflicts:
	CorsixTH/Lua/app.lua
	CorsixTH/Lua/world.lua
Added changelog items for 0.40
Merge pull request #326 from Lego3/changelog_for_0.40