Skip to content

Commit

Permalink
GUID typing fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Norbyte committed Oct 16, 2019
1 parent a5c21bf commit c6030b1
Show file tree
Hide file tree
Showing 7 changed files with 187 additions and 177 deletions.
80 changes: 41 additions & 39 deletions APIDocs.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Possible return values: `Character`, `Potion`, `Armor`, `Object`, `Shield`, `Wea
# Status functions

### IterateCharacterStatuses
`call NRD_IterateCharacterStatuses((GUIDSTRING)_CharacterGuid, (STRING)_Event)`
`call NRD_IterateCharacterStatuses((CHARACTERGUID)_CharacterGuid, (STRING)_Event)`
`event NRD_StatusIteratorEvent((STRING)_Event, (CHARACTERGUID)_Character, (STRING)_StatusId, (INTEGER64)_StatusHandle)`

Throws status iterator event `_Event` for each status present on the character. Unlike regular events, `NRD_StatusIteratorEvent` events are not queued and are thrown immediately (i.e. during the `NRD_IterateCharacterStatuses` call), so there is no need for an additional cleanup/finalizer event.
Expand All @@ -67,7 +67,7 @@ DebugBreak(_StatusId);
- The `_StatusHandle` is a persistent, unique value (like UUIDs) identifying the status instance. Unlike status names, it can be used to differentiate between two instances of the same status.
### StatusGetHandle
`query NRD_StatusGetHandle([in](GUIDSTRING)_Character, [in](STRING)_StatusId, [out](INTEGER64)_StatusHandle)`
`query NRD_StatusGetHandle([in](CHARACTERGUID)_Character, [in](STRING)_StatusId, [out](INTEGER64)_StatusHandle)`
Returns the handle of the first status with the specified `_StatusId`. If no such status exists, the query fails.
Expand All @@ -83,10 +83,10 @@ NRD_DebugLog((STRING)_Handle);
```

### StatusGet
`query NRD_StatusGetInt([in](GUIDSTRING)_Character, [in](INTEGER64)_StatusHandle, [in](STRING)_Attribute, [out](INTEGER)_Value)`
`query NRD_StatusGetReal([in](GUIDSTRING)_Character, [in](INTEGER64)_StatusHandle, [in](STRING)_Attribute, [out](REAL)_Value)`
`query NRD_StatusGetString([in](GUIDSTRING)_Character, [in](INTEGER64)_StatusHandle, [in](STRING)_Attribute, [out](STRING)_Value)`
`query NRD_StatusGetGuidString([in](GUIDSTRING)_Character, [in](INTEGER64)_StatusHandle, [in](STRING)_Attribute, [out](GUIDSTRING)_Value)`
`query NRD_StatusGetInt([in](CHARACTERGUID)_Character, [in](INTEGER64)_StatusHandle, [in](STRING)_Attribute, [out](INTEGER)_Value)`
`query NRD_StatusGetReal([in](CHARACTERGUID)_Character, [in](INTEGER64)_StatusHandle, [in](STRING)_Attribute, [out](REAL)_Value)`
`query NRD_StatusGetString([in](CHARACTERGUID)_Character, [in](INTEGER64)_StatusHandle, [in](STRING)_Attribute, [out](STRING)_Value)`
`query NRD_StatusGetGuidString([in](CHARACTERGUID)_Character, [in](INTEGER64)_StatusHandle, [in](STRING)_Attribute, [out](GUIDSTRING)_Value)`

Returns the specified status attribute. If the character or status does not exist, or if the attribute is not of the appropriate type, the query fails.

Expand All @@ -102,11 +102,11 @@ DebugBreak(_SourceStr);
```
### StatusSet
`call NRD_StatusSetInt((GUIDSTRING)_Character, (INTEGER64)_StatusHandle, (STRING)_Attribute, (INTEGER)_Value)`
`call NRD_StatusSetReal((GUIDSTRING)_Character, (INTEGER64)_StatusHandle, (STRING)_Attribute, (REAL)_Value)`
`call NRD_StatusSetString((GUIDSTRING)_Character, (INTEGER64)_StatusHandle, (STRING)_Attribute, (STRING)_Value)`
`call NRD_StatusSetGuidString((GUIDSTRING)_Character, (INTEGER64)_StatusHandle, (STRING)_Attribute, (GUIDSTRING)_Value)`
`call NRD_StatusSetVector3((GUIDSTRING)_Character, (INTEGER64)_StatusHandle, (STRING)_Attribute, (REAL)_X, (REAL)_Y, (REAL)_Z)`
`call NRD_StatusSetInt((CHARACTERGUID)_Character, (INTEGER64)_StatusHandle, (STRING)_Attribute, (INTEGER)_Value)`
`call NRD_StatusSetReal((CHARACTERGUID)_Character, (INTEGER64)_StatusHandle, (STRING)_Attribute, (REAL)_Value)`
`call NRD_StatusSetString((CHARACTERGUID)_Character, (INTEGER64)_StatusHandle, (STRING)_Attribute, (STRING)_Value)`
`call NRD_StatusSetGuidString((CHARACTERGUID)_Character, (INTEGER64)_StatusHandle, (STRING)_Attribute, (GUIDSTRING)_Value)`
`call NRD_StatusSetVector3((CHARACTERGUID)_Character, (INTEGER64)_StatusHandle, (STRING)_Attribute, (REAL)_X, (REAL)_Y, (REAL)_Z)`
Updates the specified status attribute.
See the "Status attributes" section below for a list of attributes that can be modified.
Expand All @@ -128,15 +128,15 @@ NRD_StatusSetReal(_Character, _Handle, "CurrentLifeTime", _NewLifeTime);
```

### ApplyActiveDefense
`query NRD_ApplyActiveDefense([in](GUIDSTRING)_Character, [in](STRING)_StatusId, [in](REAL)_LifeTime, [out](INTEGER64)_StatusHandle)`
`query NRD_ApplyActiveDefense([in](CHARACTERGUID)_Character, [in](STRING)_StatusId, [in](REAL)_LifeTime, [out](INTEGER64)_StatusHandle)`

Apply the specified `ACTIVE_DEFENSE` status on the character.
- `_StatusId` - Status to apply
- `_LifeTime` - Lifetime of status in seconds (one turn = 6 seconds)
- `_StatusHandle` - Handle of created status

### ApplyDamageOnMove
`query NRD_ApplyDamageOnMove([in](GUIDSTRING)_Character, [in](STRING)_StatusId, [in](GUIDSTRING)_SourceCharacter, [in](REAL)_LifeTime, [in](REAL)_DistancePerDamage, [out](INTEGER64)_StatusHandle)`
`query NRD_ApplyDamageOnMove([in](CHARACTERGUID)_Character, [in](STRING)_StatusId, [in](CHARACTERGUID)_SourceCharacter, [in](REAL)_LifeTime, [in](REAL)_DistancePerDamage, [out](INTEGER64)_StatusHandle)`

Apply the specified `DAMAGE_ON_MOVE` status on the character.
- `_StatusId` - Status to apply
Expand Down Expand Up @@ -381,13 +381,13 @@ NRD_ProjectileLaunch();
# Skill functions
### SkillSetCooldown
`call NRD_SkillSetCooldown((GUIDSTRING)_Character, (STRING)_SkillId, (REAL)_Cooldown)`
`call NRD_SkillSetCooldown((CHARACTERGUID)_Character, (STRING)_SkillId, (REAL)_Cooldown)`
Set the current cooldown timer of the skill (in seconds).
Doesn't work on skills that can only be used once per combat.
### SkillGetCooldown
`query NRD_SkillGetCooldown([in](GUIDSTRING)_Character, [in](STRING)_SkillId, [out](REAL)_Cooldown)`
`query NRD_SkillGetCooldown([in](CHARACTERGUID)_Character, [in](STRING)_SkillId, [out](REAL)_Cooldown)`
Returns the current cooldown timer of the skill (in seconds).
For skills that can only be used once per combat -1.0 is returned.
Expand All @@ -399,40 +399,40 @@ For skills that can only be used once per combat -1.0 is returned.
- The skill bar slot (`_Slot`) must be an integer between 0 and 144.
### SkillBarGetItem
`query NRD_SkillBarGetItem([in](GUIDSTRING)_Character, [in](INTEGER)_Slot, [out](GUIDSTRING)_Item)`
`query NRD_SkillBarGetItem([in](CHARACTERGUID)_Character, [in](INTEGER)_Slot, [out](ITEMGUID)_Item)`
Retrieves the item in skill bar slot `_Slot`. If the character is not a player, the skill bar slot is empty, or if the skill bar slot is occupied by a skill, the query fails.
### SkillBarGetSkill
`query NRD_SkillBarGetSkill([in](GUIDSTRING)_Character, [in](INTEGER)_Slot, [out](STRING)_Skill)`
`query NRD_SkillBarGetSkill([in](CHARACTERGUID)_Character, [in](INTEGER)_Slot, [out](STRING)_Skill)`
Retrieves the skill in skill bar slot `_Slot`. If the character is not a player, the skill bar slot is empty, or if the skill bar slot is occupied by an item, the query fails.
### SkillBarFindSkill
`query NRD_SkillBarFindSkill([in](GUIDSTRING)_Character, [in](STRING)_Skill, [out](INTEGER)_Slot)`
`query NRD_SkillBarFindSkill([in](CHARACTERGUID)_Character, [in](STRING)_Skill, [out](INTEGER)_Slot)`
Checks whether the player has the skill `_Skill` on the skill bar, and returns the slot number of its first occurrence in `_Slot`. If the character is not a player or the skill is not on the skill bar, the query fails.
### SkillBarFindItem
`query NRD_SkillBarFindItem([in](GUIDSTRING)_Character, [in](GUIDSTRING)_Item, [out](INTEGER)_Slot)`
`query NRD_SkillBarFindItem([in](CHARACTERGUID)_Character, [in](ITEMGUID)_Item, [out](INTEGER)_Slot)`
Checks whether the player has the item `_Item` on the skill bar, and returns the slot number of its first occurrence in `_Slot`. If the character is not a player or the item is not on the skill bar, the query fails.
### SkillBarSetSkill
`call NRD_SkillBarSetSkill((GUIDSTRING)_Character, (INTEGER)_Slot, (STRING)_SkillId)`
`call NRD_SkillBarSetSkill((CHARACTERGUID)_Character, (INTEGER)_Slot, (STRING)_SkillId)`
Removes any item or skill that's currently in the skill bar slot and replaces it with the specified skill.
**Notes:**
- It is possible to pin any skill to the skill bar, not just ones that the character currently has.
### SkillBarSetItem
`call NRD_SkillBarSetItem((GUIDSTRING)_Character, (INTEGER)_Slot, (GUIDSTRING)_Item)`
`call NRD_SkillBarSetItem((CHARACTERGUID)_Character, (INTEGER)_Slot, (ITEMGUID)_Item)`
Removes any item or skill that's currently in the skill bar slot and replaces it with the specified item.
### SkillBarClear
`call NRD_SkillBarClear((GUIDSTRING)_Character, (INTEGER)_Slot)`
`call NRD_SkillBarClear((CHARACTERGUID)_Character, (INTEGER)_Slot)`
Removes any item or skill that's currently in the specified skill bar slot.
Expand All @@ -452,22 +452,22 @@ Each function needs a skill stats id of the same type (Rain skill id for `NRD_Cr
- Dome: `LifeTime`, `Finished`
### CreateRain
`query NRD_CreateRain([in](GUIDSTRING)_OwnerCharacter, [in](STRING)_SkillId, [in](REAL)_X, [in](REAL)_Y, [in](REAL)_Z, [out](INTEGER64)_GameObjectHandle)`
`query NRD_CreateRain([in](CHARACTERGUID)_OwnerCharacter, [in](STRING)_SkillId, [in](REAL)_X, [in](REAL)_Y, [in](REAL)_Z, [out](INTEGER64)_GameObjectHandle)`
### CreateStorm
`query NRD_CreateStorm([in](GUIDSTRING)_OwnerCharacter, [in](STRING)_SkillId, [in](REAL)_X, [in](REAL)_Y, [in](REAL)_Z, [out](INTEGER64)_GameObjectHandle)`
`query NRD_CreateStorm([in](CHARACTERGUID)_OwnerCharacter, [in](STRING)_SkillId, [in](REAL)_X, [in](REAL)_Y, [in](REAL)_Z, [out](INTEGER64)_GameObjectHandle)`
### CreateWall
`query NRD_CreateWall([in](GUIDSTRING)_OwnerCharacter, [in](STRING)_SkillId, [in](REAL)_SourceX, [in](REAL)_SourceY, [in](REAL)_SourceZ, [in](REAL)_TargetX, [in](REAL)_TargetY, [in](REAL)_TargetZ, [out](INTEGER64)_GameObjectHandle)`
`query NRD_CreateWall([in](CHARACTERGUID)_OwnerCharacter, [in](STRING)_SkillId, [in](REAL)_SourceX, [in](REAL)_SourceY, [in](REAL)_SourceZ, [in](REAL)_TargetX, [in](REAL)_TargetY, [in](REAL)_TargetZ, [out](INTEGER64)_GameObjectHandle)`
### CreateTornado
`query NRD_CreateTornado([in](GUIDSTRING)_OwnerCharacter, [in](STRING)_SkillId, [in](REAL)_PositionX, [in](REAL)_PositionY, [in](REAL)_PositionZ, [in](REAL)_TargetX, [in](REAL)_TargetY, [in](REAL)_TargetZ, [out](INTEGER64)_GameObjectHandle)`
`query NRD_CreateTornado([in](CHARACTERGUID)_OwnerCharacter, [in](STRING)_SkillId, [in](REAL)_PositionX, [in](REAL)_PositionY, [in](REAL)_PositionZ, [in](REAL)_TargetX, [in](REAL)_TargetY, [in](REAL)_TargetZ, [out](INTEGER64)_GameObjectHandle)`
### CreateDome
`query NRD_CreateDome([in](GUIDSTRING)_OwnerCharacter, [in](STRING)_SkillId, [in](REAL)_X, [in](REAL)_Y, [in](REAL)_Z, [out](INTEGER64)_GameObjectHandle)`
`query NRD_CreateDome([in](CHARACTERGUID)_OwnerCharacter, [in](STRING)_SkillId, [in](REAL)_X, [in](REAL)_Y, [in](REAL)_Z, [out](INTEGER64)_GameObjectHandle)`
### GameObjectMove
`query NRD_CreateGameObjectMove([in](GUIDSTRING)_TargetCharacter, [in](REAL)_X, [in](REAL)_Y, [in](REAL)_Z, [in](STRING)_BeamEffectName, [in](GUIDSTRING)_CasterCharacter, [out](INTEGER64)_GameObjectHandle)`
`query NRD_CreateGameObjectMove([in](CHARACTERGUID)_TargetCharacter, [in](REAL)_X, [in](REAL)_Y, [in](REAL)_Z, [in](STRING)_BeamEffectName, [in](CHARACTERGUID)_CasterCharacter, [out](INTEGER64)_GameObjectHandle)`
### GameActionDestroy
`call NRD_GameActionDestroy((INTEGER64)_GameActionHandle)`
Expand Down Expand Up @@ -496,30 +496,32 @@ Updates the total lifetime of the specified game action.
### Summon
`query NRD_Summon([in](GUIDSTRING)_OwnerCharacter, [in](GUIDSTRING)_Template, [in](REAL)_X, [in](REAL)_Y, [in](REAL)_Z, [in](REAL)_Lifetime, [in](INTEGER)_Level, [in](INTEGER)_IsTotem, [in](INTEGER)_MapToAiGrid, [out](GUIDSTRING)_Summon)`
`query NRD_Summon([in](CHARACTERGUID)_OwnerCharacter, [in](GUIDSTRING)_Template, [in](REAL)_X, [in](REAL)_Y, [in](REAL)_Z, [in](REAL)_Lifetime, [in](INTEGER)_Level, [in](INTEGER)_IsTotem, [in](INTEGER)_MapToAiGrid, [out](CHARACTERGUID)_Summon)`
** TODO Documentation **
# Item functions
### ItemSetIdentified
`call NRD_ItemSetIdentified((GUIDSTRING)_Item, (INTEGER)_IsIdentified)`
`call NRD_ItemSetIdentified((ITEMGUID)_Item, (INTEGER)_IsIdentified)`
Sets whether the item is identified or not.
Marking common items (that cannot be identified) as unidentified has no effect.
### ItemGetStatsId
`query NRD_ItemGetStatsId([in](GUIDSTRING)_Item, [out](STRING)_StatsId)`
`query NRD_ItemGetStatsId([in](ITEMGUID)_Item, [out](STRING)_StatsId)`
Return the stats entry ID of the specified item.
### ItemGetGenerationParams
`query NRD_ItemGetGenerationParams([in](GUIDSTRING)_Item, [out](STRING)_Base, [out](STRING)_ItemType, [out](INTEGER)_Level)`
`query NRD_ItemGetGenerationParams([in](ITEMGUID)_Item, [out](STRING)_Base, [out](STRING)_ItemType, [out](INTEGER)_Level)`
Return the stats generation parameters of the specified item.
### ItemHasDeltaModifier
`query NRD_ItemHasDeltaModifier([in](GUIDSTRING)_Item, [in](STRING)_DeltaMod, [out](INTEGER)_Count)`
`query NRD_ItemHasDeltaModifier([in](ITEMGUID)_Item, [in](STRING)_DeltaMod, [out](INTEGER)_Count)`
Return the number of DeltaMods on the item with the specified boost name. Unlike vanilla `ItemHasDeltaModifier`, this also takes into account the boosts added by item generation.
Expand Down Expand Up @@ -595,25 +597,25 @@ Permanent boosts don't show up immediately because of how client-server communic
### ItemGetPermanentBoost
`query NRD_ItemGetPermanentBoostInt([in](GUIDSTRING)_Item, [in](STRING)_Stat, [out](INTEGER)_Value)`
`query NRD_ItemGetPermanentBoostReal([in](GUIDSTRING)_Item, [in](STRING)_Stat, [out](REAL)_Value)`
`query NRD_ItemGetPermanentBoostInt([in](ITEMGUID)_Item, [in](STRING)_Stat, [out](INTEGER)_Value)`
`query NRD_ItemGetPermanentBoostReal([in](ITEMGUID)_Item, [in](STRING)_Stat, [out](REAL)_Value)`
Returns the permanent boost value applied to the specified item. `_Stat` must be one of the values listed above.
### ItemSetPermanentBoost
`query NRD_ItemGetPermanentBoostInt([in](GUIDSTRING)_Item, [in](STRING)_Stat, [out](INTEGER)_Value)`
`query NRD_ItemGetPermanentBoostReal([in](GUIDSTRING)_Item, [in](STRING)_Stat, [out](REAL)_Value)`
`query NRD_ItemGetPermanentBoostInt([in](ITEMGUID)_Item, [in](STRING)_Stat, [out](INTEGER)_Value)`
`query NRD_ItemGetPermanentBoostReal([in](ITEMGUID)_Item, [in](STRING)_Stat, [out](REAL)_Value)`
Updates the permanent boost value of `_Stat` to the specified value . `_Stat` must be one of the values listed above. Both positive and negative boost values are supported.
## Cloning items
`call NRD_ItemCloneBegin((GUIDSTRING)_Item)`
`call NRD_ItemCloneBegin((ITEMGUID)_Item)`
`call NRD_ItemCloneSetInt((STRING)_Property, (INTEGER)_Value)`
`call NRD_ItemCloneSetString((STRING)_Property, (STRING)_Value)`
`query NRD_ItemClone([out](GUIDSTRING)_NewItem)`
`query NRD_ItemClone([out](ITEMGUID)_NewItem)`
**Usage:**
The clone API creates a copy of a specific item.
Expand Down
32 changes: 20 additions & 12 deletions OsiInterface/CustomFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace osidbg {
bool CustomFunction::ValidateArgs(OsiArgumentDesc const & params) const
{
if (params.Count() != params_.size()) {
Debug("Function %s/%d: Argument count mismatch", name_.c_str(), params_.size());
OsiError("Function " << name_ << "/" << params_.size() << ": Argument count mismatch");
return false;
}

Expand Down Expand Up @@ -42,10 +42,18 @@ bool CustomFunction::ValidateParam(CustomFunctionParam const & param, OsiArgumen
typeId = ValueType::GuidString;
}

if (typeId != param.Type) {
Debug("Function %s/%d: Argument '%s' type mismatch; expected %d, got %d",
name_.c_str(), params_.size(), param.Name.c_str(),
param.Type, typeId);
auto paramTypeId = param.Type;
if (paramTypeId == ValueType::CharacterGuid
|| paramTypeId == ValueType::ItemGuid
|| paramTypeId == ValueType::TriggerGuid
|| paramTypeId == ValueType::SplineGuid
|| paramTypeId == ValueType::LevelTemplateGuid) {
paramTypeId = ValueType::GuidString;
}

if (typeId != paramTypeId) {
OsiError("Function " << name_ << "/" << params_.size() << ": Argument '" << param.Name
<< "' type mismatch; expected " << (unsigned)paramTypeId << ", got " << (unsigned)typeId);
return false;
}

Expand Down Expand Up @@ -157,12 +165,12 @@ CustomFunction * CustomFunctionManager::Find(FunctionNameAndArity const & signat
bool CustomFunctionManager::Call(FunctionHandle handle, OsiArgumentDesc const & params)
{
if (handle.classIndex() != CallClassId) {
Debug("CustomFunctionManager::Call(): Cannot call %08x - not a custom function!", (uint32_t)handle);
OsiError("CustomFunctionManager::Call(): Cannot call " << (uint32_t)handle << " - not a custom function!");
return false;
}

if (handle.functionIndex() >= calls_.size()) {
Debug("CustomFunctionManager::Call(): Call index %d out of bounds!", handle.functionIndex());
OsiError("CustomFunctionManager::Call(): Call index " << handle.functionIndex() << " out of bounds!");
return false;
}

Expand All @@ -172,12 +180,12 @@ bool CustomFunctionManager::Call(FunctionHandle handle, OsiArgumentDesc const &
bool CustomFunctionManager::Query(FunctionHandle handle, OsiArgumentDesc & params)
{
if (handle.classIndex() != QueryClassId) {
Debug("CustomFunctionManager::Query(): Cannot query %08x - not a custom function!", (uint32_t)handle);
OsiError("CustomFunctionManager::Query(): Cannot query " << (uint32_t)handle << " - not a custom function!");
return false;
}

if (handle.functionIndex() >= queries_.size()) {
Debug("CustomFunctionManager::Query(): Query index %d out of bounds!", handle.functionIndex());
OsiError("CustomFunctionManager::Query(): Query index " << handle.functionIndex() << " out of bounds!");
return false;
}

Expand Down Expand Up @@ -237,13 +245,13 @@ void CustomFunctionInjector::ThrowEvent(FunctionHandle handle, OsiArgumentDesc *
auto osiris = gOsirisProxy->GetDynamicGlobals().OsirisObject;
gOsirisProxy->GetWrappers().Event.CallOriginal(osiris, it->second, args);
} else {
Debug(L"CustomFunctionInjector::ThrowEvent(): Event handle not mapped: %08x", (unsigned)handle);
OsiError("CustomFunctionInjector::ThrowEvent(): Event handle not mapped: " << (unsigned)handle);
}
}

void CustomFunctionInjector::OnAfterGetFunctionMappings(void * Osiris, MappingInfo ** Mappings, uint32_t * MappingCount)
{
Debug(L"CustomFunctionInjector::OnAfterGetFunctionMappings(): No. funcs: %d", *MappingCount);
Debug("CustomFunctionInjector::OnAfterGetFunctionMappings(): No. funcs: %d", *MappingCount);

// Remove local functions
auto outputIndex = 0;
Expand All @@ -263,7 +271,7 @@ void CustomFunctionInjector::OnAfterGetFunctionMappings(void * Osiris, MappingIn
}

*MappingCount = outputIndex;
Debug(L"CustomFunctionInjector::OnAfterGetFunctionMappings(): No. funcs after filtering: %d", *MappingCount);
Debug("CustomFunctionInjector::OnAfterGetFunctionMappings(): No. funcs after filtering: %d", *MappingCount);
}

bool CustomFunctionInjector::CallWrapper(std::function<bool (uint32_t, OsiArgumentDesc *)> const & next, uint32_t handle, OsiArgumentDesc * params)
Expand Down
Loading

0 comments on commit c6030b1

Please sign in to comment.