mirror of
				https://github.com/TES3MP/openmw-tes3mp.git
				synced 2025-10-31 20:56:42 +00:00 
			
		
		
		
	[Server] Make spell script functions consistent with others
This commit is contained in:
		
							parent
							
								
									7173a48f4b
								
							
						
					
					
						commit
						cc91b32b2f
					
				
					 3 changed files with 22 additions and 34 deletions
				
			
		|  | @ -38,7 +38,7 @@ public: | |||
|     * \brief Add a new book to the book changes for a player. | ||||
|     * | ||||
|     * \param pid The player ID whose book changes should be used. | ||||
|     * \param topicId The bookId of the book. | ||||
|     * \param bookId The bookId of the book. | ||||
|     * \return void | ||||
|     */ | ||||
|     static void AddBook(unsigned short pid, const char* bookId) noexcept; | ||||
|  |  | |||
|  | @ -12,7 +12,6 @@ void SpellFunctions::InitializeSpellbookChanges(unsigned short pid) noexcept | |||
|     GET_PLAYER(pid, player, ); | ||||
| 
 | ||||
|     player->spellbookChanges.spells.clear(); | ||||
|     player->spellbookChanges.action = SpellbookChanges::SET; | ||||
| } | ||||
| 
 | ||||
| unsigned int SpellFunctions::GetSpellbookChangesSize(unsigned short pid) noexcept | ||||
|  | @ -23,7 +22,7 @@ unsigned int SpellFunctions::GetSpellbookChangesSize(unsigned short pid) noexcep | |||
|     return player->spellbookChanges.count; | ||||
| } | ||||
| 
 | ||||
| unsigned int SpellFunctions::GetSpellbookAction(unsigned short pid) noexcept | ||||
| unsigned int SpellFunctions::GetSpellbookChangesAction(unsigned short pid) noexcept | ||||
| { | ||||
|     Player *player; | ||||
|     GET_PLAYER(pid, player, 0); | ||||
|  | @ -31,6 +30,14 @@ unsigned int SpellFunctions::GetSpellbookAction(unsigned short pid) noexcept | |||
|     return player->spellbookChanges.action; | ||||
| } | ||||
| 
 | ||||
| void SpellFunctions::SetSpellbookChangesAction(unsigned short pid, unsigned char action) noexcept | ||||
| { | ||||
|     Player *player; | ||||
|     GET_PLAYER(pid, player, ); | ||||
| 
 | ||||
|     player->spellbookChanges.action = action; | ||||
| } | ||||
| 
 | ||||
| void SpellFunctions::AddSpell(unsigned short pid, const char* spellId) noexcept | ||||
| { | ||||
|     Player *player; | ||||
|  | @ -40,19 +47,6 @@ void SpellFunctions::AddSpell(unsigned short pid, const char* spellId) noexcept | |||
|     spell.mId = spellId; | ||||
| 
 | ||||
|     player->spellbookChanges.spells.push_back(spell); | ||||
|     player->spellbookChanges.action = SpellbookChanges::ADD; | ||||
| } | ||||
| 
 | ||||
| void SpellFunctions::RemoveSpell(unsigned short pid, const char* spellId) noexcept | ||||
| { | ||||
|     Player *player; | ||||
|     GET_PLAYER(pid, player, ); | ||||
| 
 | ||||
|     ESM::Spell spell; | ||||
|     spell.mId = spellId; | ||||
| 
 | ||||
|     player->spellbookChanges.spells.push_back(spell); | ||||
|     player->spellbookChanges.action = SpellbookChanges::REMOVE; | ||||
| } | ||||
| 
 | ||||
| const char *SpellFunctions::GetSpellId(unsigned short pid, unsigned int i) noexcept | ||||
|  |  | |||
|  | @ -5,10 +5,10 @@ | |||
|     {"InitializeSpellbookChanges", SpellFunctions::InitializeSpellbookChanges},\ | ||||
|     \ | ||||
|     {"GetSpellbookChangesSize",    SpellFunctions::GetSpellbookChangesSize},\ | ||||
|     {"GetSpellbookAction",         SpellFunctions::GetSpellbookAction},\ | ||||
|     {"GetSpellbookChangesAction",  SpellFunctions::GetSpellbookChangesAction},\ | ||||
|     \ | ||||
|     {"SetSpellbookChangesAction",  SpellFunctions::SetSpellbookChangesAction},\ | ||||
|     {"AddSpell",                   SpellFunctions::AddSpell},\ | ||||
|     {"RemoveSpell",                SpellFunctions::RemoveSpell},\ | ||||
|     \ | ||||
|     {"GetSpellId",                 SpellFunctions::GetSpellId},\ | ||||
|     \ | ||||
|  | @ -42,13 +42,19 @@ public: | |||
|     * \param pid The player ID whose faction changes should be used. | ||||
|     * \return The action type (0 for SET, 1 for ADD, 2 for REMOVE). | ||||
|     */ | ||||
|     static unsigned int GetSpellbookAction(unsigned short pid) noexcept; | ||||
|     static unsigned int GetSpellbookChangesAction(unsigned short pid) noexcept; | ||||
| 
 | ||||
|     /**
 | ||||
|     * \brief Prepare the addition of a spell to a player. | ||||
|     * \brief Set the action type in a player's spellbook changes. | ||||
|     * | ||||
|     * In practice, this changes the action type of the PlayerSpellbook packet to | ||||
|     * ADD and adds this spell to it. | ||||
|     * \param pid The player ID whose spellbook changes should be used. | ||||
|     * \param action The action (0 for SET, 1 for ADD, 2 for REMOVE). | ||||
|     * \return void | ||||
|     */ | ||||
|     static void SetSpellbookChangesAction(unsigned short pid, unsigned char action) noexcept; | ||||
| 
 | ||||
|     /**
 | ||||
|     * \brief Add a new spell to the spellbook changes for a player. | ||||
|     * | ||||
|     * \param pid The player ID whose spellbook changes should be used. | ||||
|     * \param topicId The spellId of the spell. | ||||
|  | @ -56,18 +62,6 @@ public: | |||
|     */ | ||||
|     static void AddSpell(unsigned short pid, const char* spellId) noexcept; | ||||
| 
 | ||||
|     /**
 | ||||
|     * \brief Prepare the removal of a spell from a player. | ||||
|     * | ||||
|     * In practice, this changes the action type of the PlayerSpellbook packet to | ||||
|     * REMOVE and adds this spell to it. | ||||
|     * | ||||
|     * \param pid The player ID whose spellbook changes should be used. | ||||
|     * \param topicId The spellId of the spell. | ||||
|     * \return void | ||||
|     */ | ||||
|     static void RemoveSpell(unsigned short pid, const char* spellId) noexcept; | ||||
| 
 | ||||
|     /**
 | ||||
|     * \brief Get the spellId at a certain index in a player's latest spellbook changes. | ||||
|     * | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue