Commit Graph

62 Commits

Author SHA1 Message Date
Noam
4e7a35b50f add NoAvailableMaps exception.
modify ChooseInitialMap to throw NoAvailalbeMaps exception if no maps were loaded.
implement Utilities.TryWithPrompt - safe execution of a provided action with ability to prompt user on error.
2018-09-19 12:52:51 +02:00
RoosterDragon
7bc5bd5791 Force buffered sheets to commit data to a texture on buffer release.
Previously ReleaseBuffer did not immediately null out the buffer, instead the releaseBufferOnCommit flag allows it to be nulled when the texture is next access and the pending changes from the buffer are committed to it. Now the texture is committed immediately, thus the buffer is null once ReleaseBuffer returns.

Once loaded, we force a GC to reclaim temporary memory used during loading. Previously the buffer would not be null as it was pending commit to the texture and thus could not be reclaimed. As soon as we rendered the first frame, the buffer is nulled but we are now in a low GC state - and the buffer will not be reclaimed until the next gen 2 GC which may be dozens of minutes away.

This change ensures the buffer is null in time for the post-load GC, and thus can be reclaimed before we start rendering.
2018-04-29 18:11:48 +02:00
Paul Chote
8ea1da1046 Apply map upgrade rules without instantiating the Map object.
This avoids a crash that stops the maps from being updated
when the base mod ruleset is not valid (e.g. a trait is missing a
FieldLoader.Required property).  This also significantly improves the
upgrade performance.
2018-03-21 12:15:23 +01:00
Peter Antal
3ce2417a06 Create SupportDirPrefix and IsPathRelativeToSupportDirectory() as members on Platform class. 2018-03-10 12:54:01 +00:00
Arular101
8a60918841 Update copyright notice year to 2018 2018-01-17 00:47:34 +01:00
abcdefg30
27345c1f6a Fix map linting crashing for not existing directories 2017-10-08 18:23:25 +01:00
Paul Chote
a1347a7f32 Populate MapLocations from LoadMaps.
This ensures that the map locations won't be created by the utility
but means that LoadMaps must be called before attempting to use MapLocations.
2017-09-30 17:37:52 +02:00
Paul Chote
d1ed0e09d0 Create user map directory if it doesn't exist. 2017-07-21 00:10:48 +02:00
Paul Chote
8321d1f3e3 Remove legacy FileSystem.OpenPackage(string, IReadOnlyPackage). 2017-05-29 12:27:24 +02:00
Paul Chote
b1ac1d06e3 Catch and ignore exceptions while loading map previews. 2017-05-26 23:41:30 +02:00
Paul Chote
1722f42f83 Move web urls from user config to mod config. 2017-04-17 12:00:41 +01:00
Taryn Hill
43317e0f5d Update copyright notice year to 2017 2016-12-31 23:46:13 -06:00
Chris Forbes
5b793e0455 server: Fix server getting wedged after map query with bad minimap
If the mapserver returned an unusable minimap blob, we'd end up dropping
the resulting exceptions on the floor, and committing a completely broken
MapPreview, which would then blow up the tail end of the map change
process, and all future ValidateClient calls after players join (which
itself was handled by kicking the player and logging some noise of dubious
value).

Adjusts exception handling in a number of places to log the exception
rather than dropping it on the floor, and makes the mapserver response
parsing tolerant of bogus minimap blobs -- in this case, we'd rather just
have no minimap.

Candidate for stable, as it fixes a bug present in the current release and
the current playtest series.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
2016-09-20 19:28:31 +12:00
RoosterDragon
3b5798b5e8 Fix cancellation of downloads.
The Download class cancels asynchronously, which means callers must handle cancellation inside the completion event, and not after requesting cancellation.
2016-07-30 16:27:45 +01:00
Paul Chote
55cd2ca8f5 Move initial map suitability calculation to MapCache.
This was previously trying to use values that had
not yet been initialised, which meant that *all*
maps were treated as unsuitable.  This would cause
the mod to always fall back to the first installed
map.
2016-06-18 11:04:37 +01:00
Matthias Mailänder
d57e53dc53 Merge pull request #10992 from pchote/server-maps
Allow Dedicated Servers to query map info from the Resource Center.
2016-04-03 12:19:41 +02:00
Paul Chote
4ec1369553 Let servers query map details from the resource centre. 2016-03-31 21:08:36 +01:00
Paul Chote
65f7d46025 Parse map rules and players from remote maps. 2016-03-31 21:08:36 +01:00
Paul Chote
b5c2703eba Pass random to ChooseInitialMap. 2016-03-29 23:46:12 +01:00
Paul Chote
fee899f63d Fix unnecessary uses of Game.ModData. 2016-03-29 23:46:12 +01:00
Paul Chote
2150a5e865 Move ChooseInitialMap to MapCache. 2016-03-29 23:46:11 +01:00
Paul Chote
be5eee0227 Allow rules to be constructed from a MapPreview. 2016-03-12 20:01:39 +00:00
Paul Chote
9c4dd54fa3 Generate map previews on save. 2016-03-08 21:13:38 +00:00
Paul Chote
be52c1cb72 Properly use the virtual filesystem for map loading and saving. 2016-02-28 19:27:33 +00:00
Paul Chote
b0f4646b88 Dispose package on exception. 2016-02-28 10:18:50 +00:00
Paul Chote
bee3eb2c0a Dispose MapPreviews and map packages. 2016-02-28 10:18:49 +00:00
Oliver Brakmann
4f1fa3acec Merge pull request #10786 from pchote/mappreview-packages
Remove internal use of map paths.
2016-02-23 22:52:54 +01:00
Paul Chote
e71225496b Clarify GPL version. 2016-02-21 16:30:48 +00:00
Paul Chote
b396965fd9 Update licence header year. 2016-02-21 16:27:31 +00:00
Paul Chote
d492c23a6d Store map packages in MapPreview. 2016-02-21 16:11:36 +00:00
Paul Chote
02ab54c9bc Load MapPreview data without initialising a full Map. 2016-02-18 20:19:44 +00:00
Paul Chote
102880c80f Use the virtual filesystem to resolve MapFolder paths. 2016-02-15 00:44:36 +00:00
Paul Chote
7b00da04ca Remove MapPreview.Map. 2016-02-06 22:30:50 +00:00
Pavel Penev
b16ebd480b Rename MapGridType.Diamond to MapGridType.RectangularIsometric 2015-10-26 00:42:30 +02:00
Pavel Penev
bb3aea338a Rename enum TileShape to MapGridType 2015-10-26 00:41:21 +02:00
Paul Chote
be37717e6d Account for cross-mod tile shapes in map previews. 2015-10-24 22:02:46 +01:00
RoosterDragon
3b5a672848 Always access the SheetBuilder from the main thread in MapCache.
Not doing this can occasionally this can result in a cross thread call to the backing texture which leads to bad things. This stops trying to be clever regarding the thread safety invariants exposed by SheetBuilder and does things simply and safely: All updates happen on the main thread.
2015-05-07 20:58:59 +01:00
Oliver Brakmann
b363c2c51e Don't unnecessarily discard 24bpp map previews
Those images now get converted on-the-fly by the game.
2015-04-18 11:27:23 +02:00
RoosterDragon
c1787a8368 Don't process images with the wrong pixel format in MapCache. 2015-04-11 15:20:16 +01:00
RoosterDragon
47e2c48068 Ensure MapCache disposes cleanly.
This prevents the map loading thread writing to disposed objects which can have unintended side effects.
2015-04-01 20:58:09 +01:00
RoosterDragon
82bea961ba Checked LINQ queries and collections for inefficiencies.
- Made Array.IndexOf available via extension method.
- Made ToHashSet extension method.
- Change collections queried often via Contains into sets.
- Avoid Count() extension if Count or Length property exist.
- Made Count() > 0 checks and variations calls to Any() instead.
- Don't call ToList/ToArray if there is no benefit to materializing the sequence.
- If the sequence does benefit from materialization, follow this general pattern:
  - Collection queried often via Contains use ToHashSet to speed up lookups.
  - Short lived variables use ToList. This is because ToArray requires an extra copy to output the final size.
  - Collections persisted into fields or for a long time use ToArray to minimize memory overhead.
2015-01-29 19:20:11 +00:00
Oliver Brakmann
16cf805a23 Fix wrong log channel name: Debug -> debug 2015-01-25 18:34:16 +01:00
Oliver Brakmann
7267a3afdb Merge pull request #6984 from DeadlySurprise/yamlFix
Fixed yaml bug with leading spaces
2015-01-20 21:42:22 +01:00
abcdefg30
8ca61aa917 Updated all year numbers 2015-01-09 21:18:05 +01:00
DeadlySurprise
fbe6ab7f4e Fixed yaml bug with leading spaces 2015-01-07 22:16:15 +01:00
Hellhake
5a97a4b63b Fix StyleCop warnings in OpenRA.Game 2015-01-02 12:11:01 +01:00
Paul Chote
14deb1efdf Drop support for map format 5. 2014-12-23 09:08:00 +13:00
RoosterDragon
f0f02dff5c Dispose of graphics resources deterministically.
Textures, FrameBuffers and VertexBuffers allocated by the Sdl2 Renderer were only being released via finalizers. This could lead to OpenGL out of memory errors since resources may not be cleaned up in a timely manner. To avoid this, IDisposable has been implemented and transitively applied to classes that use these resources.

As a side-effect some static state is no longer static, particularly in Renderer, in order to facilitate this change and just for nicer design in general.

Also dispose some bitmaps.
2014-12-22 17:34:01 +00:00
RoosterDragon
c2b7d9ca5b Release sheet buffers in SequenceProvider and MapCache.
The buffers in SequenceProvider can be freed if Preload is called, since we know everything is loaded. A SequenceProvider is created for each TileSet is use so this saves memory for however many tilesets had been used in the game. This will be at least one for the shellmap, and often more.

The MapCache loading thread is kept alive for 5 seconds after it last generated a map (in anticipation of more requests). Once this time expires the thread is allowed to die, as it is unlikely there will be more requests in the short term. At this time it is ideal to force the changes to be committed to the texture so we can release the buffer. As well as marking the buffer for release, we must access the texture to force the changes stored in the buffer to be written to the texture, after which the buffer can be reclaimed.

Additionally, when starting the MapCache loading thread we must ensure the buffer is created from the main thread since it may query the texture object which has thread affinity. After that the buffer may be modified freely on the loading thread until released.
2014-11-29 12:04:51 +00:00
Paul Chote
4f44cc1969 Load assets using absolute paths. Fixes #6717. 2014-10-11 11:02:30 +13:00