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#include "profile.h" 23 24#include "char.h" 25#include "particle.h" 26#include "enchant.h" 27#include "mad.h" 28 29//-------------------------------------------------------------------------------------------- 30// FORWARD DECLARATIONS 31//-------------------------------------------------------------------------------------------- 32 33static INLINE CAP_REF pro_get_icap( const PRO_REF iobj ); 34static INLINE MAD_REF pro_get_imad( const PRO_REF iobj ); 35static INLINE EVE_REF pro_get_ieve( const PRO_REF iobj ); 36static INLINE PIP_REF pro_get_ipip( const PRO_REF iobj, int ipip ); 37static INLINE IDSZ pro_get_idsz( const PRO_REF iobj, int type ); 38 39static INLINE cap_t * pro_get_pcap( const PRO_REF iobj ); 40static INLINE mad_t * pro_get_pmad( const PRO_REF iobj ); 41static INLINE eve_t * pro_get_peve( const PRO_REF iobj ); 42static INLINE pip_t * pro_get_ppip( const PRO_REF iobj, int pip_index ); 43static INLINE Mix_Chunk * pro_get_chunk( const PRO_REF iobj, int index ); 44 45//-------------------------------------------------------------------------------------------- 46//-------------------------------------------------------------------------------------------- 47static INLINE CAP_REF pro_get_icap( const PRO_REF iobj ) 48{ 49 pro_t * pobj; 50 51 if ( !LOADED_PRO( iobj ) ) return ( CAP_REF )MAX_CAP; 52 pobj = ProList.lst + iobj; 53 54 return LOADED_CAP( pobj->icap ) ? pobj->icap : ( CAP_REF )MAX_CAP; 55} 56 57//-------------------------------------------------------------------------------------------- 58static INLINE MAD_REF pro_get_imad( const PRO_REF iobj ) 59{ 60 pro_t * pobj; 61 62 if ( !LOADED_PRO( iobj ) ) return ( MAD_REF )MAX_MAD; 63 pobj = ProList.lst + iobj; 64 65 return LOADED_MAD( pobj->imad ) ? pobj->imad : ( MAD_REF )MAX_MAD; 66} 67 68//-------------------------------------------------------------------------------------------- 69static INLINE EVE_REF pro_get_ieve( const PRO_REF iobj ) 70{ 71 pro_t * pobj; 72 73 if ( !LOADED_PRO( iobj ) ) return ( EVE_REF )MAX_EVE; 74 pobj = ProList.lst + iobj; 75 76 return LOADED_EVE( pobj->ieve ) ? pobj->ieve : ( EVE_REF )MAX_EVE; 77} 78 79//-------------------------------------------------------------------------------------------- 80static INLINE PIP_REF pro_get_ipip( const PRO_REF iobj, int pip_index ) 81{ 82 pro_t * pobj; 83 PIP_REF found_pip, global_pip; 84 85 found_pip = ( PIP_REF )MAX_PIP; 86 87 if ( !LOADED_PRO( iobj ) ) 88 { 89 // check for a global pip 90 global_pip = pip_index; 91 if ( LOADED_PIP( global_pip ) ) 92 { 93 found_pip = global_pip; 94 } 95 } 96 else 97 { 98 // this pip is relative to a certain object 99 pobj = ProList.lst + iobj; 100 101 // find the local pip if it exists 102 if ( pip_index < MAX_PIP_PER_PROFILE ) 103 { 104 found_pip = pobj->prtpip[pip_index]; 105 } 106 } 107 108 return found_pip; 109} 110 111//-------------------------------------------------------------------------------------------- 112static INLINE IDSZ pro_get_idsz( const PRO_REF iobj, int type ) 113{ 114 cap_t * pcap; 115 116 if ( type >= IDSZ_COUNT ) return IDSZ_NONE; 117 118 pcap = pro_get_pcap( iobj ); 119 if ( NULL == pcap ) return IDSZ_NONE; 120 121 return pcap->idsz[type]; 122} 123 124//-------------------------------------------------------------------------------------------- 125static INLINE cap_t * pro_get_pcap( const PRO_REF iobj ) 126{ 127 pro_t * pobj; 128 129 if ( !LOADED_PRO( iobj ) ) return NULL; 130 pobj = ProList.lst + iobj; 131 132 if ( !LOADED_CAP( pobj->icap ) ) return NULL; 133 134 return CapStack.lst + pobj->icap; 135} 136 137//-------------------------------------------------------------------------------------------- 138static INLINE mad_t * pro_get_pmad( const PRO_REF iobj ) 139{ 140 pro_t * pobj; 141 142 if ( !LOADED_PRO( iobj ) ) return NULL; 143 pobj = ProList.lst + iobj; 144 145 if ( !LOADED_MAD( pobj->imad ) ) return NULL; 146 147 return MadStack.lst + pobj->imad; 148} 149 150//-------------------------------------------------------------------------------------------- 151static INLINE eve_t * pro_get_peve( const PRO_REF iobj ) 152{ 153 pro_t * pobj; 154 155 if ( !LOADED_PRO( iobj ) ) return NULL; 156 pobj = ProList.lst + iobj; 157 158 if ( !LOADED_EVE( pobj->ieve ) ) return NULL; 159 160 return EveStack.lst + pobj->ieve; 161} 162 163//-------------------------------------------------------------------------------------------- 164static INLINE pip_t * pro_get_ppip( const PRO_REF iobj, int pip_index ) 165{ 166 pro_t * pobj; 167 PIP_REF global_pip, local_pip; 168 169 if ( !LOADED_PRO( iobj ) ) 170 { 171 // check for a global pip 172 global_pip = pip_index; 173 if ( LOADED_PIP( global_pip ) ) 174 { 175 return PipStack.lst + global_pip; 176 } 177 else 178 { 179 return NULL; 180 } 181 } 182 183 // this pip is relative to a certain object 184 pobj = ProList.lst + iobj; 185 186 // find the local pip if it exists 187 local_pip = ( PIP_REF )MAX_PIP; 188 if ( pip_index < MAX_PIP_PER_PROFILE ) 189 { 190 local_pip = pobj->prtpip[pip_index]; 191 } 192 193 return LOADED_PIP( local_pip ) ? PipStack.lst + local_pip : NULL; 194} 195 196//-------------------------------------------------------------------------------------------- 197static INLINE Mix_Chunk * pro_get_chunk( const PRO_REF iobj, int index ) 198{ 199 pro_t * pobj; 200 201 if ( !VALID_SND( index ) ) return NULL; 202 203 if ( !LOADED_PRO( iobj ) ) return NULL; 204 pobj = ProList.lst + iobj; 205 206 return pobj->wavelist[index]; 207} 208