Commit graph

1675 commits

Author SHA1 Message Date
Kamron Batman
996fdeb011
fix: Removes testing fastwalk (#733) 2021-08-26 17:42:11 -07:00
Kamron Batman
451e53d006
fix: Fixes base armor deserializing old version (#731) 2021-08-26 13:45:31 -07:00
Kamron Batman
1a336752a6
fix: Fixes benchmarks (#729) 2021-08-25 00:35:07 -07:00
Kamron Batman
0dc4acc164
fix(core): Removes implicit cast between Serial and uint (#728)
* Fixes spellbooks using serial ctor
* Fixes misc items where someone thought they had an amount and it didn't
* Fixes all `Food` types.
2021-08-25 00:27:19 -07:00
Kamron Batman
17521c9cd7
fix: Adds defaults for codegenned clothing (#727) 2021-08-24 23:24:06 -07:00
Kamron Batman
ca3faec01d
fix(codegen): Codegens clothing (#714) 2021-08-24 23:11:59 -07:00
Kamron Batman
13931ddf1d
fix: Fixes area command not working (#725) 2021-08-24 11:24:28 -07:00
Kamron Batman
d18d436cfe
fix: Fixes BOD entries (#724) 2021-08-24 10:06:44 -07:00
Kamron Batman
671cc769a6
fix(codegen): Fixes codegenning timers when they are null. (#723)
When a timer is null, the code generator will use `TimeSpan.MinValue` as the delay.
2021-08-23 20:44:02 -07:00
Kamron Batman
dd62e17693
fix(vendors): Adds an option to turn OPL off for vendor buying. Defaults to on. (#721) 2021-08-23 11:36:26 -07:00
Kamron Batman
9729b5a7b0
fix(map): Fixes map diffs (Old Haven/Minax) (#720)
* Fixes reading map/static diffs.
2021-08-22 23:35:18 -07:00
Kamron Batman
0bcf7a8d01
fix: Fixes buying animals in UOR (#719) 2021-08-22 15:36:26 -07:00
Kamron Batman
b4566fe154
fix(wands): Fixes codegenning BaseWand. (#718) 2021-08-22 14:30:38 -07:00
Kamron Batman
3b44ee0c6b
fix(core): Fixes string wrapping for houses (#717) 2021-08-22 10:01:01 -07:00
Kamron Batman
d9a9e90c14
fix(codegen): Codegens bulletin boards. (#712) 2021-08-22 08:05:03 -07:00
Michael Dijkstra
8b0eb1aa79
fix(codegen): Codegens wands (#716) 2021-08-22 01:30:27 -07:00
Kamron Batman
957e5fd4e1
fix(codegen): Codegens champion artifacts (#713) 2021-08-21 13:03:05 -07:00
Kamron Batman
473e752606
fix(codegen): Fixes reference to parent while deserializing (#711) 2021-08-21 12:23:01 -07:00
Kamron Batman
c0a8672db3
fix(network): Don't crash the user when they click the UO Store button (#710) 2021-08-21 00:14:40 -07:00
Kamron Batman
c2f28f9a98
fix(codegen): Fixes bool in migration structs (#709)
* Fixes bool? not being a valid type for save flag property migrations.
* Fixes wrong SaveFlag type used in the if check for boolean save flags.
2021-08-20 22:46:13 -07:00
Kamron Batman
1d916fe2df
fix(timers): Fixes multiple issue with timer wheel (#705)
* Fixed an issue where a timer truncated the link list.
* Fixed an issue where a timer stopped and started itself within an OnTick causing it to remove itself from the link list, but still think it's running.
2021-08-20 18:04:34 -07:00
Kamron Batman
c2f853d8a8
fix(codegen): Fixes base armor using wrong int type (#708) 2021-08-19 23:02:16 -07:00
Kamron Batman
ca5e9342a0
fix(codegen): Adds default codegen option for save flags. Fixes world load issues. (#707) 2021-08-19 22:51:44 -07:00
Michael Dijkstra
3fc2b76468
fix(codegen): Codegens Weapons (#698) 2021-08-19 09:12:24 -07:00
Kamron Batman
3293ffcf06
fix: Cleanup IPoint3D calls (#704) 2021-08-19 09:11:48 -07:00
Kamron Batman
788b04b958
fix: Updates build/test workflow (#703) 2021-08-18 12:48:08 -07:00
Kamron Batman
e6de7a5898
fix(spells): Fixes interruption of spells (#702) 2021-08-18 12:17:42 -07:00
Michael Dijkstra
50dd7a1146
fix: README publish link (#699) 2021-08-18 08:35:28 -07:00
Kamron Batman
f7e7fa424b
fix(codegen): Codegens books (#697) 2021-08-17 22:38:48 -07:00
Michael Dijkstra
488f1044fa
fix(codegen): Code gens axes (#690) 2021-08-17 20:37:53 -07:00
Kamron Batman
c8a2605c0d
fix(codegen): Code gens base armor and fixes code genning of other armors. (#696)
* Fixes code gen of save flags
* Code gens rest of armor
* Fixes some existing code genned armors
* Code gens BaseArmor
2021-08-17 17:52:15 -07:00
Kamron Batman
803d594300
fix(codegen): Fixes leather gloves again, typo in the serialize version. (#695) 2021-08-17 13:45:08 -07:00
Kamron Batman
5f7dab0795
fix(codegen): Fixes leather gloves deserialization (#694) 2021-08-17 12:44:34 -07:00
Kamron Batman
9833b0439a
fix(codegen): Code gens more armor items (#693) 2021-08-17 11:04:03 -07:00
Kamron Batman
9b047d9d3f
fix(codegen): Removes unused json fields (#691) 2021-08-17 09:51:08 -07:00
Michael Dijkstra
28335ece88
fix(codegen): Codegens Weapon artifacts (#689) 2021-08-17 09:00:12 -07:00
Kamron Batman
2c8097f707
fix(codegen): Fixes various code gen issues. Adds better embedded serialization support (#688)
* Adds save flag support (see `ElvenGlasses` for an example)
* Updates AOSAttributes so they are code genned
* Fixes embedded object support by adding an `IRawSerializable`
* Fixes various inconsistencies in serializing with codegen
2021-08-17 02:43:52 -07:00
Kamron Batman
69af652a18
fix: Codegens some armors & Fixes code genning of some base addons (#687) 2021-08-16 16:11:20 -07:00
Kamron Batman
1323162628
fix(codegen): Adds codegen for embedded objects and timer fields (#686)
* Adds code genning for embedded objects. See `AquariumState` as an example.
* Adds code genning for fields that are `Timer`. See `Aquarium` as an example.
* Codegens aquariums
* Fixes missing option for most primitive field types.
2021-08-16 14:48:18 -07:00
Kamron Batman
4c265562bb
fix: Codgens more addons (#685)
* Fixes after deserialization not executing for older versions of an object
* Codegens more addons
2021-08-15 17:55:04 -07:00
Kamron Batman
25fa9b397b
fix: Code gens items. Fixes code genning of ore (#684)
### THIS IS A BREAKING CHANGE IF YOU ARE ALREADY USING CODEGEN. IF YOUR WORLD HAS ERRORS LOADING PLEASE CONTACT ME ON DISCORD. ORE MIGHT FAIL TO LOAD.
 
### Changes
* Fixes Components from addons not marking dirty
* Code gens BaseAddonContainer
* Code gens Ingots
* Fixes code gen deserialization for Ore
* Code gens dyetubs
* Code gens reagents
* Code gens tailor commodities
* Code gens fish
2021-08-14 22:16:42 -07:00
Kamron Batman
2de4717390
fix(content): Adds addons to code gen (#624)
* Codegens more addons.
* Fixes up some source generation issues.
2021-08-14 16:53:18 -07:00
Kamron Batman
360143478a
feat: Adds tidy option for serialization. Codegens ballotbox. Fixes pooled timer leaking (#681)
* Fixes pooled timer leaking
* Fixes `[dumptimers` command so it outputs properly, adds spacing, and stacktraces
* Adds `[Tidy]` for serializing Lists. This will remove deleted entities during world save before serializing the list.
* Adds helpers for managing Lists/Sets/Dictionaries


### New API

```cs
// Creates the list if it is null, then adds
Utility.Add(ref list, value);
Utility.Add(ref set, value);
Utility.Add(ref dict, key, value);

// Nulls the variable if the count is zero
Utility.Remove(ref list, value);
Utility.Remove(ref set, value);
Utility.Remove(ref dict, key);

// Marks entity as dirty in addition to doing the action
entity.Add(list, value);
// Marks entity as dirty, and will create list if it doesn't exist
entity.Add(ref list, value);

// Marks entity as dirty in addition to doing the action
entity.Remove(list, value);
// Marks entity as dirty, and will null the list count is zero
entity.Remove(ref list, value);
```


### Updates to [dumptimers
<img width="825" alt="Screen Shot 2021-08-14 at 2 55 10 AM" src="https://user-images.githubusercontent.com/3953314/129442449-ccf7fe14-29d6-4f3f-9366-c8eb7b9828a7.png">
2021-08-14 03:02:53 -07:00
Kamron Batman
84cbd52a2a
fix: Removes players from sectors (#682) 2021-08-13 21:25:24 -07:00
Kamron Batman
f795ab4698
fix: Updates first load configuration (#680)
<img width="814" alt="Screen Shot 2021-08-08 at 11 33 24 PM" src="https://user-images.githubusercontent.com/3953314/128667907-be43bf24-df7b-481b-ab0a-8b9094f01188.png">
2021-08-08 23:42:10 -07:00
Kamron Batman
b0f8fe0350
fix: Optimize OrderedHashSet and introduce more high perf collections (#679)
* Optimizes OrderedHashSet using the learnings here: https://github.com/dotnet/runtime/issues/10050
* Removes ValueCollection since it was a relic from the conversion of the OrderedDictionary
* Centralizes throw strings.
* Adds pooled ordered hash set (but doesn't use it)

Closes #448
2021-08-08 21:37:25 -07:00
Kamron Batman
d10e782371
feat(collections): Adds pooled ref queue (#678) 2021-08-07 21:15:48 -07:00
Kamron Batman
cb3895148d
fix(readme): Updates IDE requirements (#677) 2021-08-07 14:57:37 -07:00
Kamron Batman
9b554f69b0
feat(timers): Adds timer pooling, fixes timer related bugs, and changes timer api (#667)
### Changes/Fixes:
* Adds timer pooling.
* Allows pool to be configurable in ModernUO.json
* Pool replenishes itself asynchronously if depleted.
* Fixes an issue with barkeeps and town criers
* Fixes an issue with incognito buff icons not being removed
* Fixes an issue with polymorph name mod not being removed
* Fixes several places where timers go on forever even after an object is deleted, keeping a reference (memory leak)
* Eliminates the timer for MiningCart altogether.
* Deletes `AcidSlime` since it is a duplicate of `PoolOfAcid`
* Fixes HonorableExecution and standardizes the code for other Bushido moves.

## Changes to the Timer API:
```cs
public class Timer
{
  // Creates a timer that will be returned to the pool once execution stops.
  public static void StartTimer(Action callback);
  public static void StartTimer(TimeSpan delay, Action callback);
  public static void StartTimer(TimeSpan delay, TimeSpan interval, Action callback);
  public static void StartTimer(TimeSpan interval, int count, Action callback);
  public static void StartTimer(TimeSpan delay, TimeSpan interval, int count, Action callback);

  // Creates a timer and returns a token for more control. Requires manual cancellation in order for the timer to be returned to the pool.
  // If the token is dereferenced, the timer will be dereferenced too. While not returning a timer to the pool is not considered hazardous, it does defeat the purpose of pooled timers.
  public static void StartTimer(Action callback, out TimerExecutionToken token);
  public static void StartTimer(TimeSpan delay, Action callback, out TimerExecutionToken token);
  public static void StartTimer(TimeSpan delay, TimeSpan interval, Action callback, out TimerExecutionToken token);
  public static void StartTimer(TimeSpan interval, int count, Action callback, out TimerExecutionToken token);
  public static void StartTimer(TimeSpan delay, TimeSpan interval, int count, Action callback, out TimerExecutionToken token);

  // If you aren't sure how to use the API above, or you don't care about performance, then you can use the old RunUO Timer.DelayCall
  public static DelayCallTimer DelayCall(Action callback);
  public static DelayCallTimer DelayCall(TimeSpan delay, Action callback);
  public static DelayCallTimer DelayCall(TimeSpan delay, TimeSpan interval, Action callback);
  public static DelayCallTimer DelayCall(TimeSpan interval, int count, Action callback);
  public static DelayCallTimer DelayCall(TimeSpan delay, TimeSpan interval, int count, Action callback);
}

public struct TimerExecutionToken
{
  public bool Running { get; }
  public int Index { get; }
  public int RemainingCount { get; }
  public DateTime Next { get; }
}
```

## When to use `TimerExecutionToken`?
Use tokens when you want to gain the performance benefit of using a pooled timer, but you need one of the following:
* Access to the next time the timer will tick:`token.Next`
* Access to which interval, how many intervals there are, or how many are remaining: `token.Index`, `token.Count`, and `token.RemainingCount`
* Stop a timer manually.
* Determine if the timer is running: `timer.Running`
* See notes below about requirements for using tokens!

## Notes about using the TimerExecutionToken:
When you opt-in to receive a token, you must call `Cancel()` to return the timer. This can be done inside of the callback, or outside of the callback at any time.
If this is not called and your timer is an infinite interval, then you will create a potential memory leak, or null pointer exception in your callback.
If the timer ends and is stopped, but cancel is not called, then the timer will never return to the pool and stay referenced until the token is deleted or cancel is called. (Memory leak)

## Is this thread safe?
No. The ModernUO timer system is not thread safe at all. If you require a thread safe timer system, contact me and I'll help adapt this system. Keep in mind that there is a massive performance hit to make this thread safe when there are literally no use cases for it.

If you need to synchronize execution, meaning you want to execute code from another thread on the core thread. Let's say you have a discord bot that is pushing commands to the game server. Then use `EventLoopContext.Post(SendOrPostCallback callback, object state);`.
2021-08-07 14:33:35 -07:00
Kamron Batman
b4de631f96
fix(quests): Removes ML quest spawners (#675) 2021-08-05 19:31:52 -07:00