1#pragma once 2 3//******************************************************************************************** 4//* 5//* This file is part of Egoboo. 6//* 7//* Egoboo is free software: you can redistribute it and/or modify it 8//* under the terms of the GNU General Public License as published by 9//* the Free Software Foundation, either version 3 of the License, or 10//* (at your option) any later version. 11//* 12//* Egoboo is distributed in the hope that it will be useful, but 13//* WITHOUT ANY WARRANTY; without even the implied warranty of 14//* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15//* General Public License for more details. 16//* 17//* You should have received a copy of the GNU General Public License 18//* along with Egoboo. If not, see <http://www.gnu.org/licenses/>. 19//* 20//******************************************************************************************** 21 22/// @file enchant.inl 23 24#include "EncList.h" 25#include "ChrList.h" 26 27#include "char.inl" 28#include "profile.inl" 29 30//-------------------------------------------------------------------------------------------- 31// FORWARD DECLARARIONS 32//-------------------------------------------------------------------------------------------- 33static INLINE PRO_REF enc_get_ipro( const ENC_REF ienc ); 34static INLINE pro_t * enc_get_ppro( const ENC_REF ienc ); 35 36static INLINE CHR_REF enc_get_iowner( const ENC_REF ienc ); 37static INLINE chr_t * enc_get_powner( const ENC_REF ienc ); 38 39static INLINE EVE_REF enc_get_ieve( const ENC_REF ienc ); 40static INLINE eve_t * enc_get_peve( const ENC_REF ienc ); 41 42static INLINE IDSZ enc_get_idszremove( const ENC_REF ienc ); 43static INLINE bool_t enc_is_removed( const ENC_REF ienc, const PRO_REF test_profile ); 44 45//-------------------------------------------------------------------------------------------- 46// IMPLEMENTATION 47//-------------------------------------------------------------------------------------------- 48CHR_REF enc_get_iowner( const ENC_REF ienc ) 49{ 50 enc_t * penc; 51 52 if ( !DEFINED_ENC( ienc ) ) return ( CHR_REF )MAX_CHR; 53 penc = EncList.lst + ienc; 54 55 if ( !INGAME_CHR( penc->owner_ref ) ) return ( CHR_REF )MAX_CHR; 56 57 return penc->owner_ref; 58} 59 60//-------------------------------------------------------------------------------------------- 61chr_t * enc_get_powner( const ENC_REF ienc ) 62{ 63 enc_t * penc; 64 65 if ( !DEFINED_ENC( ienc ) ) return NULL; 66 penc = EncList.lst + ienc; 67 68 if ( !INGAME_CHR( penc->owner_ref ) ) return NULL; 69 70 return ChrList.lst + penc->owner_ref; 71} 72 73//-------------------------------------------------------------------------------------------- 74EVE_REF enc_get_ieve( const ENC_REF ienc ) 75{ 76 enc_t * penc; 77 78 if ( !DEFINED_ENC( ienc ) ) return ( EVE_REF )MAX_EVE; 79 penc = EncList.lst + ienc; 80 81 if ( !LOADED_EVE( penc->eve_ref ) ) return ( EVE_REF )MAX_EVE; 82 83 return penc->eve_ref; 84} 85 86//-------------------------------------------------------------------------------------------- 87eve_t * enc_get_peve( const ENC_REF ienc ) 88{ 89 enc_t * penc; 90 91 if ( !DEFINED_ENC( ienc ) ) return NULL; 92 penc = EncList.lst + ienc; 93 94 if ( !LOADED_EVE( penc->eve_ref ) ) return NULL; 95 96 return EveStack.lst + penc->eve_ref; 97} 98 99//-------------------------------------------------------------------------------------------- 100PRO_REF enc_get_ipro( const ENC_REF ienc ) 101{ 102 enc_t * penc; 103 104 if ( !DEFINED_ENC( ienc ) ) return ( PRO_REF )MAX_PROFILE; 105 penc = EncList.lst + ienc; 106 107 if ( !LOADED_PRO( penc->profile_ref ) ) return ( PRO_REF )MAX_PROFILE; 108 109 return penc->profile_ref; 110} 111 112//-------------------------------------------------------------------------------------------- 113pro_t * enc_get_ppro( const ENC_REF ienc ) 114{ 115 enc_t * penc; 116 117 if ( !DEFINED_ENC( ienc ) ) return NULL; 118 penc = EncList.lst + ienc; 119 120 if ( !LOADED_PRO( penc->profile_ref ) ) return NULL; 121 122 return ProList.lst + penc->profile_ref; 123} 124 125//-------------------------------------------------------------------------------------------- 126IDSZ enc_get_idszremove( const ENC_REF ienc ) 127{ 128 eve_t * peve = enc_get_peve( ienc ); 129 if ( NULL == peve ) return IDSZ_NONE; 130 131 return peve->removedbyidsz; 132} 133 134//-------------------------------------------------------------------------------------------- 135bool_t enc_is_removed( const ENC_REF ienc, const PRO_REF test_profile ) 136{ 137 IDSZ idsz_remove; 138 139 if ( !INGAME_ENC( ienc ) ) return bfalse; 140 idsz_remove = enc_get_idszremove( ienc ); 141 142 // if nothing can remove it, just go on with your business 143 if ( IDSZ_NONE == idsz_remove ) return bfalse; 144 145 // check vs. every IDSZ that could have something to do with cancelling the enchant 146 if ( idsz_remove == pro_get_idsz( test_profile, IDSZ_TYPE ) ) return btrue; 147 if ( idsz_remove == pro_get_idsz( test_profile, IDSZ_PARENT ) ) return btrue; 148 149 return bfalse; 150} 151 152//-------------------------------------------------------------------------------------------- 153 154#define _enchant_inl