Commit graph

1644 commits

Author SHA1 Message Date
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
Kamron Batman
410b18ceca
fix(linq): Removes linq and fixes fishing error (#674) 2021-08-04 22:24:38 -07:00
Kamron Batman
b112be4e1f
fix: Fixes vendor OPL (#672) 2021-08-03 00:34:44 -07:00
Kamron Batman
3dc406624e
fix: Fixes bank box withdraw using account gold (#671)
Fixes various locations where account gold is not used.
2021-08-02 19:23:25 -07:00
Kamron Batman
677e44d35f
fix: Fixes tests (#670) 2021-08-01 22:41:47 -07:00
Kamron Batman
f78a226321
fix(core): Fixes packet issues with hair/beard (#669) 2021-08-01 19:54:04 -07:00
Kamron Batman
ebac984543
fix(types): Fixes casting spell by type and [Add keyword search (#668)
* Fixes `[cast`
* Fixes `[add` search
2021-08-01 13:18:01 -07:00
Kamron Batman
4bad733366
fix: Fixes TeleportPets (#666) 2021-07-28 21:01:46 -07:00
SpeedyDevil
6c22b14a9b
fix(spells): SpellTargetPoint3D doesnt inherits ISpellTarget (#665) 2021-07-28 07:49:30 -07:00
Kamron Batman
06a577332d
fix(core): Fixes a timer bug where Stop wasn't called internally (#664) 2021-07-25 23:30:11 -07:00
Kamron Batman
26592f202e
feat(spawner): Adds where for EditSpawner command (#663)
Adds `where` option for EditSpawner command

Closes #547
2021-07-20 20:19:27 -07:00
Kamron Batman
c9ce597573
fix(core): Fixes bad check for verifying types (#662) 2021-07-19 21:50:29 -07:00
Kamron Batman
bd34e2fb0d
fix(build): Fixes building with VS 2019 16.10+ (#661)
**Note for Rider users** Code generation only works with Rider v2021.1+. For Rider 2021.1.x you must set a global msbuild attribute so that the IDE can recognize generated code after building. JetBrains claims this will be fixed in Rider 2021.2.

**Rider 2021.1 Required Setting for Code Generation**
<img width="945" alt="Screen Shot 2021-07-19 at 9 36 30 PM" src="https://user-images.githubusercontent.com/3953314/126262725-a4d58dd0-e9e0-400f-a172-0b29ef7a00d7.png">

**Note for VS 2019+ users**: Code generation requires completely cleaning your solution, doing a full build, closing VS 2019, and then opening the solution. This is a known issue and there are no plans to fix this multiple restart requirement for VS 2022 at this time.
2021-07-19 21:43:29 -07:00
Kamron Batman
679e8100f4
cleanup: Fixes bugs and cleans up code (#660) 2021-07-19 20:49:59 -07:00
Kamron Batman
1de0b656a9
fix(accounting): Fixes NPE when joining faction due to codegen (#658) 2021-07-12 00:03:46 -07:00
Kamron Batman
f8820e581a
fix(content): Localizes some messages and cleans up virtues (#657) 2021-07-11 23:10:54 -07:00
Kamron Batman
fb915992dd
fix(core): Adds Hashed & Hierarchical Timer Wheel (#655)
- Removes TimerPriority
- Removes TimerThread
- Adds a [Hashed & Hierarchical Timer Wheel](http://www.cs.columbia.edu/~nahum/w6998/papers/ton97-timing-wheels.pdf)
2021-07-11 22:42:06 -07:00
Kamron Batman
b99d520019
fix(core): Anchors delta min/max (#656) 2021-07-11 15:20:34 -07:00
Kamron Batman
c79a8a4002
Cleans up ore (#637) 2021-06-12 14:15:10 -07:00
Kamron Batman
61c49b8faa
fix(core): Fixes OPL with stale header (#651)
- [X] FIxes stale header/header args

Closes #650 
Closes #607
2021-06-11 23:44:05 -07:00
Kamron Batman
510d2e006b
fix(codegen): Fixes bulk order deed hue and codegens (#647)
- [X] Codegens some Bulk Order stuff
- [X] Fixes deserializing with a class that requires the parent as a constructor argument


Closes #641
Closes #623
2021-06-11 19:51:03 -07:00
Kamron Batman
eb4e3ac070
fix(core): Fixes various issues with codegen (#646)
- [X] Fixes bad `ReadEnum` by size
- [X] Fixes array, list, and set not handling null values properly.
  - It will be up to the user (for now) to null out empty lists using `[AfterDeserialization]`. Convenience may be added later.
- [X] Fixes errors with `dotnet clean` and non-empty generation folder
- [X] Fixes bad field indexes on `Account.cs` causing `tags` to not be serialized/deserialized.
  - This was caused by a duplicate entry. Don't have protection against this _yet_.
2021-06-06 17:03:05 -07:00
Kamron Batman
75db56edc4
fix(core): Fixes accounts and moves it to codegen (#644)
- [X] Fixes TimeSpan not working with codegen
- [X] Fixes bad check for generic classes with a serialize method and deserialize ctor
- [X] Moves Accounts to codegen so it is versioned
- [X] Fixes deserialization of old Accounts with no version variable.
- [X] Fixes deserialize seek not doing anything. 🙈 
- [X] Adds Email to serialization
2021-06-05 19:39:16 -07:00
Kamron Batman
ac4d349caa
fix(spells): Fixes an edge case with casters current map (#643) 2021-06-04 23:41:43 -07:00
Kamron Batman
7ddf2b1a8f
fix(core): Fixes regions (#642) 2021-06-04 23:34:22 -07:00
romanlysenko
20422e5f11
feat(content): Adds configuration for extended status override (UOML) (#634) 2021-06-03 09:31:18 -07:00
Kamron Batman
e51334cc0f
fix(codegen): Fixes writing enums (#636) 2021-06-02 23:28:49 -07:00
Kamron Batman
cc5a8dc4fa
fix(core): Fixes region base type (#635)
Fixes `Region` being loaded instead of `BaseRegion` as the default region type.
2021-06-02 23:12:52 -07:00
Kamron Batman
803b4a33cb
fix(codegen): Adds access modifiers to serializable fields (#633)
- [X] Adds options for SerializableField.

Example:
```cs
[SerializableField(0, getter: "protected", setter: "protected", isVritual: true)]
private int _someField;
```

Defaults: `getter: "public", setter: "public", isVirtual: false`
2021-06-01 22:53:51 -07:00
Kamron Batman
72d3966541
fix(codegen): Fixes list rules (#632) 2021-06-01 16:41:43 -07:00
Kamron Batman
8b0bdc7d62
fix(codegen): Codegens Holiday stuff (#631) 2021-06-01 16:34:24 -07:00
Kamron Batman
ac3958a0b8
fix(codegen): Fixes codegen on VS2019 (#629)
- [X] Fixes code gen on VS2019
- [X] Fixes schema generator not iterating through all nodes
- [X] Fixes errors with building the actual code gen
2021-05-31 16:30:17 -07:00