#include <hook.h>
gehe zum Quellcode dieser Datei
Makrodefinitionen | |
| #define | NEED_PROTOTYPES |
Funktionen | |
| protected status | h_dbg () |
| void | HookTestOffer (int id, status stat) |
| void | HookTestTrigger (int id, mixed data) |
| nomask mapping | HCopyHookMapping () |
| nomask protected void | CleanHookMapping (int *hookids) |
| nomask protected void | offerHook (int hookid, status offerstate) |
| status | HConsumerTypeIsAllowed (int type, object consumer) |
| status | HPriorityIsAllowed (int prio, object consumer) |
| nomask protected int | findObjectInTypeArr (mixed ar, object ob) |
| nomask status | HIsHookConsumer (int hookid, object consumer) |
| nomask protected int * | hookConsumerInfo (int hookid, object consumer) |
| nomask mapping | HListHookConsumer (int hookid) |
| nomask int * | HListHooks () |
| status | HUnregisterFromHook (int hookid, object consumer) |
| nomask protected status | askSurveyorsForRegistrationAllowance (mixed *surveyors, object consumer, int hookid, int hookprio, int consumertype) |
| status | HRegisterToHook (int hookid, object consumer, int hookprio, int consumertype, int timeInSeconds) |
| nomask int | internalEntrySort (mixed a, mixed b) |
| nomask protected status | askSurveyorsForCancelAllowance (mixed surveyors, object modifiyingOb, mixed data, int hookid, int prio, object hookOb) |
| nomask protected status | askSurveyorsForModificationAllowance (mixed surveyors, object modifiyingOb, mixed data, int hookid, int prio, object hookOb) |
| nomask protected mixed | HookFlow (int hookid, mixed hookdata) |
Variablen | |
| private nosave mapping | hookMapping = ([]) |
| #define NEED_PROTOTYPES |
Definiert in Zeile 13 der Datei hook_provider.c.
| nomask protected status askSurveyorsForCancelAllowance | ( | mixed | surveyors, | |
| object | modifiyingOb, | |||
| mixed | data, | |||
| int | hookid, | |||
| int | prio, | |||
| object | hookOb | |||
| ) |
Definiert in Zeile 311 der Datei hook_provider.c.
00312 { 00313 00314 foreach(mixed surveyor: surveyors) { 00315 if (objectp(surveyor[H_OBJECT]) 00316 && (surveyor[H_TIME] == -1 || surveyor[H_TIME] >= time()) 00317 && surveyor[H_OBJECT]->HookCancelAllowanceCallback(modifiyingOb, 00318 hookid,hookOb,prio,data)==0) { 00319 return 0; 00320 } 00321 } 00322 return 1; 00323 }
| nomask protected status askSurveyorsForModificationAllowance | ( | mixed | surveyors, | |
| object | modifiyingOb, | |||
| mixed | data, | |||
| int | hookid, | |||
| int | prio, | |||
| object | hookOb | |||
| ) |
Definiert in Zeile 325 der Datei hook_provider.c.
00326 { 00327 00328 foreach(mixed surveyor: surveyors) { 00329 if (objectp(surveyor[H_OBJECT]) 00330 && (surveyor[H_TIME] == -1 || surveyor[H_TIME] >= time()) 00331 && surveyor[H_OBJECT]->HookModificationAllowanceCallback(modifiyingOb, 00332 hookid,hookOb,prio,data)==0){ 00333 return 0; 00334 } 00335 } 00336 return 1; 00337 }
| nomask protected status askSurveyorsForRegistrationAllowance | ( | mixed * | surveyors, | |
| object | consumer, | |||
| int | hookid, | |||
| int | hookprio, | |||
| int | consumertype | |||
| ) |
Definiert in Zeile 203 der Datei hook_provider.c.
Benutzt H_DMSG, H_OBJECT, H_TIME und i.
Wird benutzt von HRegisterToHook().
00204 { 00205 int i; 00206 status tmp; 00207 00208 H_DMSG(sprintf("askSurveyorsForRegistrationAllowance surveyors %O, " 00209 "consumer %O, hookid %d, hookprio %d, consumertype %d\n", 00210 surveyors,consumer,hookid,hookprio,consumertype)); 00211 00212 foreach(mixed surveyor: surveyors) { 00213 if (objectp(surveyor[H_OBJECT]) 00214 && (surveyor[H_TIME] == -1 || surveyor[H_TIME] >= time()) ) { 00215 H_DMSG(sprintf("Calling surveyor %O\n",surveyor[H_OBJECT])); 00216 tmp=surveyor[H_OBJECT]->HookRegistrationCallback(consumer, 00217 hookid, this_object(), hookprio, consumertype); 00218 H_DMSG(sprintf("Result is %d\n",tmp)); 00219 if(tmp==0){ 00220 return 0; 00221 } 00222 } 00223 } 00224 return 1; 00225 }

| nomask protected void CleanHookMapping | ( | int * | hookids | ) |
Definiert in Zeile 55 der Datei hook_provider.c.
Benutzt H_OBJECT, H_TIME und hookMapping.
Wird benutzt von HListHookConsumer(), HookFlow() und HRegisterToHook().
00055 { 00056 // hooks enthaelt die aufzuraeumenden Hooks. Wenn kein Array -> alle Hooks 00057 if (pointerp(hookids)) 00058 hookids=m_indices(hookMapping); 00059 00060 foreach(int hookid : hookids) { // alle Hooks 00061 foreach(int consumertype, mixed consumers : hookMapping[hookid]) { // Consumertypen 00062 foreach(int *hookentry : &consumers) { // Hookeintraege / Consumer 00063 if (!hookentry[H_OBJECT] 00064 || (hookentry[H_TIME] > -1 && hookentry[H_TIME] < time())) 00065 hookentry = 0; 00066 } 00067 // 0 noch rauswerfen. 00068 hookMapping[hookid][consumertype] -= ({0}); 00069 } 00070 } 00071 00072 }

| nomask protected int findObjectInTypeArr | ( | mixed | ar, | |
| object | ob | |||
| ) |
Definiert in Zeile 106 der Datei hook_provider.c.
Benutzt H_OBJECT, H_TIME und i.
Wird benutzt von hookConsumerInfo().
00107 { 00108 int i=sizeof(ar)-1; 00109 00110 for ( ; i>=0 ; i--) { 00111 if(ar[i][H_OBJECT]==ob && 00112 (ar[i][H_TIME]<0 || ar[i][H_TIME] >= time() )) { 00113 return i; 00114 } 00115 } 00116 00117 return -1; 00118 }

| protected status h_dbg | ( | ) |
Definiert in Zeile 37 der Datei hook_provider.c.
Wird benutzt von HookTestOffer() und HookTestTrigger().

| status HConsumerTypeIsAllowed | ( | int | type, | |
| object | consumer | |||
| ) |
Definiert in Zeile 98 der Datei hook_provider.c.
Wird benutzt von HRegisterToHook().

| nomask mapping HCopyHookMapping | ( | ) |
Definiert in Zeile 51 der Datei hook_provider.c.
Benutzt hookMapping.
00051 { 00052 return deep_copy(hookMapping); 00053 }
| nomask status HIsHookConsumer | ( | int | hookid, | |
| object | consumer | |||
| ) |
Definiert in Zeile 121 der Datei hook_provider.c.
Benutzt hookConsumerInfo().
Wird benutzt von HRegisterToHook().
00121 { 00122 if(hookConsumerInfo(hookid,consumer)!=0){ 00123 return 1; 00124 } 00125 00126 return 0; 00127 }


| nomask mapping HListHookConsumer | ( | int | hookid | ) |
Definiert in Zeile 171 der Datei hook_provider.c.
Benutzt CleanHookMapping() und hookMapping.
00171 { 00172 00173 if(member(hookMapping,hookid)) { 00174 CleanHookMapping(({hookid})); 00175 return deep_copy(hookMapping[hookid]); 00176 } 00177 00178 return 0; 00179 }

| nomask int* HListHooks | ( | ) |
Definiert in Zeile 181 der Datei hook_provider.c.
Benutzt hookMapping.
00181 { 00182 if(sizeof(hookMapping)) { 00183 return m_indices(hookMapping); 00184 } 00185 return ({}); 00186 }
| nomask protected int* hookConsumerInfo | ( | int | hookid, | |
| object | consumer | |||
| ) |
Definiert in Zeile 129 der Datei hook_provider.c.
Benutzt findObjectInTypeArr(), H_DATA_MODIFICATOR, H_DMSG, H_HOOK_MODIFICATOR, H_HOOK_SURVEYOR, H_LISTENER und hookMapping.
Wird benutzt von HIsHookConsumer() und HUnregisterFromHook().
00130 { 00131 int* ret; 00132 int index; 00133 ret=0; 00134 00135 H_DMSG(sprintf("hookConsumerInfo hookid %d consumer %O\n",hookid,consumer)); 00136 00137 // Consumertypen in der Reihenfolge pruefen, in der die Max-Anzahlen 00138 // abnehmen. 00139 if(consumer && member(hookMapping,hookid)){ 00140 index=findObjectInTypeArr(hookMapping[hookid][H_LISTENER], 00141 consumer); 00142 if (index!=-1) { 00143 ret=({H_LISTENER,index}); 00144 } 00145 else{ 00146 index=findObjectInTypeArr(hookMapping[hookid][H_DATA_MODIFICATOR], 00147 consumer); 00148 if(index!=-1){ 00149 ret=({H_DATA_MODIFICATOR,index}); 00150 } 00151 else{ 00152 index=findObjectInTypeArr(hookMapping[hookid][H_HOOK_MODIFICATOR], 00153 consumer); 00154 if(index!=-1){ 00155 ret=({H_HOOK_MODIFICATOR,index}); 00156 } 00157 else{ 00158 index=findObjectInTypeArr(hookMapping[hookid][H_HOOK_SURVEYOR], 00159 consumer); 00160 if(index!=-1){ 00161 ret=({H_HOOK_SURVEYOR,index}); 00162 } 00163 } 00164 } 00165 } 00166 } 00167 H_DMSG(sprintf(" result %O\n",ret)); 00168 return ret; 00169 }


| nomask protected mixed HookFlow | ( | int | hookid, | |
| mixed | hookdata | |||
| ) |
Definiert in Zeile 339 der Datei hook_provider.c.
Benutzt call_out() und CleanHookMapping().
Wird benutzt von _set_alcohol(), _set_drink(), _set_food(), _set_poison(), Attack(), consume(), HookTestTrigger() und move().
00339 { 00340 mixed tmp; 00341 mixed ret; 00342 00343 ret=({H_NO_MOD,hookdata}); 00344 00345 H_DMSG(sprintf("HookFlow hookid %d hookdata %O\n",hookid,hookdata)); 00346 if(member(hookMapping,hookid)) { 00347 00348 // notify surveyors 00349 foreach(mixed surv: hookMapping[hookid][H_HOOK_SURVEYOR]) { 00350 if (objectp(surv[H_OBJECT]) 00351 && (surv[H_TIME] == -1 || surv[H_TIME] >= time()) ) 00352 { 00353 tmp=surv[H_OBJECT]->HookCallback(this_object(), hookid,ret[H_RETDATA]); 00354 if(tmp[H_RETCODE]==H_CANCELLED) { 00355 ret[H_RETCODE]=H_CANCELLED; 00356 return ret; // und weg... 00357 } 00358 else if(tmp[H_RETCODE]==H_ALTERED){ 00359 ret[H_RETCODE]=H_ALTERED; 00360 ret[H_RETDATA]=tmp[H_RETDATA]; 00361 } 00362 } 00363 // ungueltige/abgelaufene Eintraege -> Aufraeumen, aber nicht jetzt. 00364 else if (find_call_out(#'CleanHookMapping) == -1) { 00365 call_out(#'CleanHookMapping,0,({hookid})); 00366 } 00367 } 00368 00369 // notify hmods 00370 foreach(mixed hmod: hookMapping[hookid][H_HOOK_MODIFICATOR]) { 00371 if (objectp(hmod[H_OBJECT]) 00372 && (hmod[H_TIME] == -1 || hmod[H_TIME] >= time()) ) 00373 { 00374 tmp=hmod[H_OBJECT]->HookCallback(this_object(),hookid, ret[H_RETDATA]); 00375 if(tmp[H_RETCODE]==H_CANCELLED) { 00376 // ask allowance in surveyors 00377 if(askSurveyorsForCancelAllowance(hookMapping[hookid][H_HOOK_SURVEYOR], 00378 hmod[H_OBJECT],hookdata,hookid, 00379 hmod[H_PRIO],this_object())) 00380 { 00381 ret[H_RETCODE]=H_CANCELLED; 00382 return ret; // und raus... 00383 } 00384 } 00385 else if(tmp[H_RETCODE]==H_ALTERED) { 00386 // ask allowance in surveyors 00387 if(askSurveyorsForModificationAllowance(hookMapping[hookid][H_HOOK_SURVEYOR], 00388 hmod[H_OBJECT],hookdata,hookid, 00389 hmod[H_PRIO],this_object())) 00390 { 00391 ret[H_RETCODE]=H_ALTERED; 00392 ret[H_RETDATA]=tmp[H_RETDATA]; 00393 } 00394 } 00395 } 00396 // ungueltige/abgelaufene Eintraege -> Aufraeumen, aber nicht jetzt. 00397 else if (find_call_out(#'CleanHookMapping) == -1) { 00398 call_out(#'CleanHookMapping,0,({hookid})); 00399 } 00400 } 00401 00402 // notify dmods 00403 foreach(mixed dmod: hookMapping[hookid][H_DATA_MODIFICATOR]) { 00404 if (objectp(dmod[H_OBJECT]) 00405 && (dmod[H_TIME] == -1 || dmod[H_TIME] >= time()) ) { 00406 tmp=dmod[H_OBJECT]->HookCallback(this_object(),hookid,ret[H_RETDATA]); 00407 if(tmp[H_RETCODE]==H_ALTERED) { 00408 // ask allowance in surveyors 00409 if(askSurveyorsForModificationAllowance(hookMapping[hookid][H_HOOK_SURVEYOR], 00410 dmod[H_OBJECT],hookdata,hookid, 00411 dmod[H_PRIO],this_object())) 00412 { 00413 ret[H_RETCODE]=H_ALTERED; 00414 ret[H_RETDATA]=tmp[H_RETDATA]; 00415 } 00416 } 00417 } 00418 // ungueltige/abgelaufene Eintraege -> Aufraeumen, aber nicht jetzt. 00419 else if (find_call_out(#'CleanHookMapping) == -1) { 00420 call_out(#'CleanHookMapping,0,({hookid})); 00421 } 00422 } 00423 00424 // notify listener 00425 foreach(mixed listener: hookMapping[hookid][H_LISTENER]) { 00426 if (objectp(listener[H_OBJECT]) 00427 && (listener[H_TIME] == -1 || listener[H_TIME] >= time()) ) { 00428 listener[H_OBJECT]->HookCallback(this_object(),hookid,ret[H_RETDATA]); 00429 } 00430 // ungueltige/abgelaufene Eintraege -> Aufraeumen, aber nicht jetzt. 00431 else if (find_call_out(#'CleanHookMapping) == -1) { 00432 call_out(#'CleanHookMapping,0,({hookid})); 00433 } 00434 } 00435 00436 } 00437 00438 return ret; 00439 }


| void HookTestOffer | ( | int | id, | |
| status | stat | |||
| ) |
Definiert in Zeile 39 der Datei hook_provider.c.
Benutzt h_dbg() und offerHook().

| void HookTestTrigger | ( | int | id, | |
| mixed | data | |||
| ) |
Definiert in Zeile 45 der Datei hook_provider.c.
Benutzt h_dbg() und HookFlow().

| status HPriorityIsAllowed | ( | int | prio, | |
| object | consumer | |||
| ) |
Definiert in Zeile 102 der Datei hook_provider.c.
Wird benutzt von HRegisterToHook().

| status HRegisterToHook | ( | int | hookid, | |
| object | consumer, | |||
| int | hookprio, | |||
| int | consumertype, | |||
| int | timeInSeconds | |||
| ) |
Definiert in Zeile 227 der Datei hook_provider.c.
Benutzt askSurveyorsForRegistrationAllowance(), CleanHookMapping(), H_CONSUMERCHECK, H_DMSG, H_HOOK_SURVEYOR, H_HOOK_VALIDPRIO, H_OBJECT, H_PRIO, HConsumerTypeIsAllowed(), HIsHookConsumer(), hookMapping, HPriorityIsAllowed() und MAX_HOOK_COUNTS.
Wird benutzt von init().
00228 { 00229 status ret; 00230 mixed ar; 00231 int regtime; 00232 00233 if(timeInSeconds>0) { 00234 regtime=time() + timeInSeconds; 00235 } 00236 else{ 00237 regtime=-1; 00238 } 00239 ret=0; 00240 00241 H_DMSG(sprintf("HRegisterToHook hookid %d consumer %O\n hookprio %d " 00242 "consumertype %d\n",hookid,consumer,hookprio,consumertype)); 00243 00244 CleanHookMapping(({hookid})); // entfernt abgelaufene Eintraege 00245 00246 if(member(hookMapping,hookid) && consumer!=0 && 00247 !HIsHookConsumer(hookid,consumer)) { 00248 H_DMSG("First barrier\n"); 00249 if(H_CONSUMERCHECK(consumertype)!=-1 && 00250 HConsumerTypeIsAllowed(consumertype,consumer)){ 00251 H_DMSG("Second barrier\n"); 00252 if(H_HOOK_VALIDPRIO(hookprio)!=-1 && 00253 HPriorityIsAllowed(hookprio,consumer)){ 00254 H_DMSG("Third barrier\n"); 00255 if(askSurveyorsForRegistrationAllowance(hookMapping[hookid][H_HOOK_SURVEYOR], 00256 consumer,hookid,hookprio,consumertype)) { 00257 H_DMSG("Fourth barrier\n"); 00258 00259 // ar enthaelt die Hookeintraege 00260 ar=hookMapping[hookid][consumertype]; 00261 if (sizeof(ar) < MAX_HOOK_COUNTS[consumertype]) { 00262 // max. Anzahl an Eintraegen fuer diesen Typ noch nicht 00263 // erreicht, direkt anhaengen. 00264 ar += ({ ({consumer,hookprio,regtime}) }); 00265 hookMapping[hookid][consumertype]=ar; 00266 ret=1; 00267 } 00268 else { 00269 // gibt es einen Eintrag mit hoeherem Priowert (niedrigere 00270 // Prioritaet), den man ersetzen koennte? 00271 // Das Array ist sortiert, mit hoechsten Priowerten am 00272 // Ende. Ersetzt werden soll der Eintrag mit dem hoechsten 00273 // Zahlenwert, falls der neue Eintrag einen niedrigeren Wert 00274 // hat. 00275 // Pruefung auf Objektexistenz, falls der Surveyor Objekte 00276 // zerstoert... 00277 if (!objectp(ar[<1][H_OBJECT]) || 00278 (ar[<1][H_PRIO] > hookprio 00279 && ar[<1][H_OBJECT]->superseededHook(hookid,this_object())) 00280 ) { 00281 H_DMSG("Found superseedable entry\n"); 00282 ar[<1] = ({consumer,hookprio,regtime}); 00283 // nicht noetig, wegen Array -> Referenz 00284 //hookMapping[hookid][consumertype]=ar; 00285 ret = 1; 00286 } 00287 } 00288 } 00289 00290 } 00291 } 00292 } 00293 // wenn ein Eintrag hinzugefuegt wurde, muss neu sortiert werden 00294 if (ret) { 00295 hookMapping[hookid][consumertype] = 00296 sort_array(hookMapping[hookid][consumertype],#'internalEntrySort); 00297 } 00298 00299 H_DMSG(sprintf(" result %O\n",hookMapping)); 00300 00301 return ret; 00302 }


| status HUnregisterFromHook | ( | int | hookid, | |
| object | consumer | |||
| ) |
Definiert in Zeile 188 der Datei hook_provider.c.
Benutzt H_DMSG, H_INDEX, H_TYPE, hookConsumerInfo(), hookMapping und info.
00188 { 00189 int* info; 00190 status ret=0; 00191 00192 H_DMSG(sprintf("HUnregisterFromHook hookid %d consumer %O\n",hookid,consumer)); 00193 info=hookConsumerInfo(hookid,consumer); 00194 if (info) { 00195 hookMapping[hookid][info[H_TYPE]][info[H_INDEX]]=0; 00196 hookMapping[hookid][info[H_TYPE]] -= ({0}); 00197 ret=1; 00198 } 00199 H_DMSG(sprintf(" result %O\n",hookMapping)); 00200 return ret; 00201 }

| nomask int internalEntrySort | ( | mixed | a, | |
| mixed | b | |||
| ) |
Definiert in Zeile 304 der Datei hook_provider.c.
| nomask protected void offerHook | ( | int | hookid, | |
| status | offerstate | |||
| ) |
Definiert in Zeile 74 der Datei hook_provider.c.
Benutzt H_DATA_MODIFICATOR, H_DMSG, H_HOOK_MODIFICATOR, H_HOOK_SURVEYOR, H_LISTENER und hookMapping.
Wird benutzt von create() und HookTestOffer().
00075 { 00076 H_DMSG(sprintf("offerHook hookid %d offerstate %d\n",hookid,offerstate)); 00077 if(hookid>0) 00078 { 00079 if(offerstate){ 00080 if(!member(hookMapping,hookid)){ 00081 hookMapping+=([hookid:([ 00082 H_HOOK_SURVEYOR: ({}), 00083 H_HOOK_MODIFICATOR: ({}), 00084 H_DATA_MODIFICATOR: ({}), 00085 H_LISTENER: ({}), 00086 ])]); 00087 } 00088 } 00089 else{ 00090 if(member(hookMapping,hookid)){ 00091 hookMapping-=([hookid]); 00092 } 00093 } 00094 } 00095 H_DMSG(sprintf(" result %O\n",hookMapping)); 00096 }

| private nosave mapping hookMapping = ([]) |
Definiert in Zeile 29 der Datei hook_provider.c.
Wird benutzt von CleanHookMapping(), HCopyHookMapping(), HListHookConsumer(), HListHooks(), hookConsumerInfo(), HRegisterToHook(), HUnregisterFromHook() und offerHook().
1.6.3