-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Simantics, Server] Substantial Backend Improvements
- Fix a bug where the game could crash when switching properties. - Global Tuning: Tuning that is sent as soon as the player logs in, and is available in city view. - Tuning Presets: Tuning that can be applied as part of an ingame timed event. This can include tuning for motives, object payouts, skill speed and more - and allows all of these things to be automatically changed while the server is running. - Admin API for Events. (should make things easier on other M.O.M.I. ;) ) - Tuning changes while the server is running now immediately update any lots that are open. (fixes dynamic payouts not updating til a lot restart) - Interpolation for slot-slot movement. Very simple right now - could be improved for things like table slots. - Hidden objects (like the go here destination) no longer update shadows, causing a stutter. - New collision test function - should be helpful finding the desyncs that have been hitting popular lots. - Fix object shadows when shadows for surrounding lots are enabled - Terrain Force logic now uses global tuning. - "Community" category flag can now be set by Volcanic.
- Loading branch information
1 parent
ec31134
commit 6cefa61
Showing
63 changed files
with
827 additions
and
50 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
159 changes: 159 additions & 0 deletions
159
TSOClient/FSO.Server.Api.Core/Controllers/Admin/AdminEventsController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Threading.Tasks; | ||
using FSO.Server.Api.Core.Models; | ||
using FSO.Server.Api.Core.Utils; | ||
using FSO.Server.Database.DA.DbEvents; | ||
using FSO.Server.Database.DA.Tuning; | ||
using Microsoft.AspNetCore.Cors; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 | ||
|
||
namespace FSO.Server.Api.Core.Controllers.Admin | ||
{ | ||
[EnableCors("AdminAppPolicy")] | ||
[Route("admin/events")] | ||
[ApiController] | ||
public class AdminEventsController : ControllerBase | ||
{ | ||
//List events | ||
[HttpGet] | ||
public IActionResult Get(int limit, int offset, string order) | ||
{ | ||
if (limit == 0) limit = 20; | ||
if (order == null) order = "start_day"; | ||
var api = Api.INSTANCE; | ||
api.DemandModerator(Request); | ||
using (var da = api.DAFactory.Get()) | ||
{ | ||
|
||
if (limit > 100) | ||
{ | ||
limit = 100; | ||
} | ||
|
||
var result = da.Events.All((int)offset, (int)limit, order); | ||
return ApiResponse.PagedList<DbEvent>(Request, HttpStatusCode.OK, result); | ||
} | ||
} | ||
|
||
[HttpGet("presets")] | ||
public IActionResult GetPresets() | ||
{ | ||
var api = Api.INSTANCE; | ||
api.DemandModerator(Request); | ||
using (var da = api.DAFactory.Get()) | ||
{ | ||
return new JsonResult(da.Tuning.GetAllPresets().ToList()); | ||
} | ||
} | ||
|
||
[HttpPost("presets")] | ||
public IActionResult CreatePreset([FromBody]PresetCreateModel request) | ||
{ | ||
var api = Api.INSTANCE; | ||
api.DemandModerator(Request); | ||
using (var da = api.DAFactory.Get()) | ||
{ | ||
//make the preset first | ||
var preset_id = da.Tuning.CreatePreset( | ||
new DbTuningPreset() | ||
{ | ||
name = request.name, | ||
description = request.description, | ||
flags = request.flags | ||
}); | ||
|
||
foreach (var item in request.items) | ||
{ | ||
da.Tuning.CreatePresetItem(new DbTuningPresetItem() | ||
{ | ||
preset_id = preset_id, | ||
tuning_type = item.tuning_type, | ||
tuning_table = item.tuning_table, | ||
tuning_index = item.tuning_index, | ||
value = item.value | ||
}); | ||
} | ||
return new JsonResult(da.Tuning.GetAllPresets().ToList()); | ||
} | ||
} | ||
|
||
[HttpGet("presets/{preset_id}")] | ||
public IActionResult GetPresetEntries(int preset_id) | ||
{ | ||
var api = Api.INSTANCE; | ||
api.DemandModerator(Request); | ||
using (var da = api.DAFactory.Get()) | ||
{ | ||
return new JsonResult(da.Tuning.GetPresetItems(preset_id).ToList()); | ||
} | ||
} | ||
|
||
[HttpDelete("presets/{preset_id}")] | ||
public IActionResult DeletePreset(int preset_id) | ||
{ | ||
var api = Api.INSTANCE; | ||
api.DemandModerator(Request); | ||
using (var da = api.DAFactory.Get()) | ||
{ | ||
return da.Tuning.DeletePreset(preset_id) ? (IActionResult)Ok() : NotFound(); | ||
} | ||
} | ||
|
||
// POST admin/updates (start update generation) | ||
[HttpPost] | ||
public IActionResult Post([FromBody]EventCreateModel request) | ||
{ | ||
var api = Api.INSTANCE; | ||
api.DemandModerator(Request); | ||
|
||
using (var da = api.DAFactory.Get()) | ||
{ | ||
DbEventType type; | ||
try | ||
{ | ||
type = Enum.Parse<DbEventType>(request.type); | ||
} | ||
catch | ||
{ | ||
return BadRequest("Event type must be one of:" + string.Join(", ", Enum.GetNames(typeof(DbEventType)))); | ||
} | ||
var model = new DbEvent() | ||
{ | ||
title = request.title, | ||
description = request.description, | ||
start_day = request.start_day, | ||
end_day = request.end_day, | ||
type = type, | ||
value = request.value, | ||
value2 = request.value2, | ||
mail_subject = request.mail_subject, | ||
mail_message = request.mail_message, | ||
mail_sender = request.mail_sender, | ||
mail_sender_name = request.mail_sender_name | ||
}; | ||
return new JsonResult(new { id = da.Events.Add(model) }); | ||
} | ||
} | ||
|
||
[HttpDelete] | ||
[Route("{id}")] | ||
public IActionResult Delete(int id) | ||
{ | ||
var api = Api.INSTANCE; | ||
api.DemandModerator(Request); | ||
|
||
using (var da = api.DAFactory.Get()) | ||
{ | ||
if (!da.Events.Delete(id)) return NotFound(); | ||
} | ||
|
||
return Ok(); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace FSO.Server.Api.Core.Models | ||
{ | ||
public class EventCreateModel | ||
{ | ||
public string title; | ||
public string description; | ||
public DateTime start_day; | ||
public DateTime end_day; | ||
public string type; | ||
public int value; | ||
public int value2; | ||
public string mail_subject; | ||
public string mail_message; | ||
public int mail_sender; | ||
public string mail_sender_name; | ||
} | ||
|
||
public class PresetCreateModel | ||
{ | ||
public string name; | ||
public string description; | ||
public int flags; | ||
public List<PresetItemModel> items; | ||
} | ||
|
||
public class PresetItemModel | ||
{ | ||
public string tuning_type; | ||
public int tuning_table; | ||
public int tuning_index; | ||
public float value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.