• R/O
  • HTTP
  • SSH
  • HTTPS

hengband: Commit

変愚蛮怒のメインリポジトリです


Commit MetaInfo

Revision3aaee215674394986e9097f9a0e93b947b45b934 (tree)
Time2019-07-10 00:02:07
Authordeskull <deskull@user...>
Commiterdeskull

Log Message

[Refactor] #38997 calc_spells() に player_type * 引数を追加.

Change Summary

Incremental Difference

--- a/src/player-status.c
+++ b/src/player-status.c
@@ -4175,7 +4175,7 @@ static void calc_torch(void)
41754175 * Note that this function induces various "status" messages,
41764176 * which must be bypasses until the character is created.
41774177 */
4178-static void calc_spells(void)
4178+static void calc_spells(player_type *creature_ptr)
41794179 {
41804180 int i, j, k, levels;
41814181 int num_allowed;
@@ -4196,37 +4196,37 @@ static void calc_spells(void)
41964196 /* Hack -- handle "xtra" mode */
41974197 if (current_world_ptr->character_xtra) return;
41984198
4199- if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4199+ if ((creature_ptr->pclass == CLASS_SORCERER) || (creature_ptr->pclass == CLASS_RED_MAGE))
42004200 {
4201- p_ptr->new_spells = 0;
4201+ creature_ptr->new_spells = 0;
42024202 return;
42034203 }
42044204
42054205 p = spell_category_name(mp_ptr->spell_book);
42064206
42074207 /* Determine the number of spells allowed */
4208- levels = p_ptr->lev - mp_ptr->spell_first + 1;
4208+ levels = creature_ptr->lev - mp_ptr->spell_first + 1;
42094209
42104210 /* Hack -- no negative spells */
42114211 if (levels < 0) levels = 0;
42124212
42134213 /* Extract total allowed spells */
4214- num_allowed = (adj_mag_study[p_ptr->stat_ind[mp_ptr->spell_stat]] * levels / 2);
4214+ num_allowed = (adj_mag_study[creature_ptr->stat_ind[mp_ptr->spell_stat]] * levels / 2);
42154215
4216- if ((p_ptr->pclass != CLASS_SAMURAI) && (mp_ptr->spell_book != TV_LIFE_BOOK))
4216+ if ((creature_ptr->pclass != CLASS_SAMURAI) && (mp_ptr->spell_book != TV_LIFE_BOOK))
42174217 {
42184218 bonus = 4;
42194219 }
4220- if (p_ptr->pclass == CLASS_SAMURAI)
4220+ if (creature_ptr->pclass == CLASS_SAMURAI)
42214221 {
42224222 num_allowed = 32;
42234223 }
4224- else if (p_ptr->realm2 == REALM_NONE)
4224+ else if (creature_ptr->realm2 == REALM_NONE)
42254225 {
42264226 num_allowed = (num_allowed + 1) / 2;
42274227 if (num_allowed > (32 + bonus)) num_allowed = 32 + bonus;
42284228 }
4229- else if ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))
4229+ else if ((creature_ptr->pclass == CLASS_MAGE) || (creature_ptr->pclass == CLASS_PRIEST))
42304230 {
42314231 if (num_allowed > (96 + bonus)) num_allowed = 96 + bonus;
42324232 }
@@ -4240,72 +4240,72 @@ static void calc_spells(void)
42404240 {
42414241 /* Count known spells */
42424242 if ((j < 32) ?
4243- (p_ptr->spell_forgotten1 & (1L << j)) :
4244- (p_ptr->spell_forgotten2 & (1L << (j - 32))))
4243+ (creature_ptr->spell_forgotten1 & (1L << j)) :
4244+ (creature_ptr->spell_forgotten2 & (1L << (j - 32))))
42454245 {
42464246 num_boukyaku++;
42474247 }
42484248 }
42494249
42504250 /* See how many spells we must forget or may learn */
4251- p_ptr->new_spells = num_allowed + p_ptr->add_spells + num_boukyaku - p_ptr->learned_spells;
4251+ creature_ptr->new_spells = num_allowed + creature_ptr->add_spells + num_boukyaku - creature_ptr->learned_spells;
42524252
42534253 /* Forget spells which are too hard */
42544254 for (i = 63; i >= 0; i--)
42554255 {
42564256 /* Efficiency -- all done */
4257- if (!p_ptr->spell_learned1 && !p_ptr->spell_learned2) break;
4257+ if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2) break;
42584258
42594259 /* Access the spell */
4260- j = p_ptr->spell_order[i];
4260+ j = creature_ptr->spell_order[i];
42614261
42624262 /* Skip non-spells */
42634263 if (j >= 99) continue;
42644264
42654265
42664266 /* Get the spell */
4267- if (!is_magic((j < 32) ? p_ptr->realm1 : p_ptr->realm2))
4267+ if (!is_magic((j < 32) ? creature_ptr->realm1 : creature_ptr->realm2))
42684268 {
42694269 if (j < 32)
4270- s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC][j];
4270+ s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
42714271 else
4272- s_ptr = &technic_info[p_ptr->realm2 - MIN_TECHNIC][j % 32];
4272+ s_ptr = &technic_info[creature_ptr->realm2 - MIN_TECHNIC][j % 32];
42734273 }
42744274 else if (j < 32)
4275- s_ptr = &mp_ptr->info[p_ptr->realm1 - 1][j];
4275+ s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
42764276 else
4277- s_ptr = &mp_ptr->info[p_ptr->realm2 - 1][j % 32];
4277+ s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][j % 32];
42784278
42794279 /* Skip spells we are allowed to know */
4280- if (s_ptr->slevel <= p_ptr->lev) continue;
4280+ if (s_ptr->slevel <= creature_ptr->lev) continue;
42814281
42824282 /* Is it known? */
42834283 if ((j < 32) ?
4284- (p_ptr->spell_learned1 & (1L << j)) :
4285- (p_ptr->spell_learned2 & (1L << (j - 32))))
4284+ (creature_ptr->spell_learned1 & (1L << j)) :
4285+ (creature_ptr->spell_learned2 & (1L << (j - 32))))
42864286 {
42874287 /* Mark as forgotten */
42884288 if (j < 32)
42894289 {
4290- p_ptr->spell_forgotten1 |= (1L << j);
4291- which = p_ptr->realm1;
4290+ creature_ptr->spell_forgotten1 |= (1L << j);
4291+ which = creature_ptr->realm1;
42924292 }
42934293 else
42944294 {
4295- p_ptr->spell_forgotten2 |= (1L << (j - 32));
4296- which = p_ptr->realm2;
4295+ creature_ptr->spell_forgotten2 |= (1L << (j - 32));
4296+ which = creature_ptr->realm2;
42974297 }
42984298
42994299 /* No longer known */
43004300 if (j < 32)
43014301 {
4302- p_ptr->spell_learned1 &= ~(1L << j);
4303- which = p_ptr->realm1;
4302+ creature_ptr->spell_learned1 &= ~(1L << j);
4303+ which = creature_ptr->realm1;
43044304 }
43054305 else
43064306 {
4307- p_ptr->spell_learned2 &= ~(1L << (j - 32));
4308- which = p_ptr->realm2;
4307+ creature_ptr->spell_learned2 &= ~(1L << (j - 32));
4308+ which = creature_ptr->realm2;
43094309 }
43104310
43114311 #ifdef JP
@@ -4316,7 +4316,7 @@ static void calc_spells(void)
43164316
43174317
43184318 /* One more can be learned */
4319- p_ptr->new_spells++;
4319+ creature_ptr->new_spells++;
43204320 }
43214321 }
43224322
@@ -4325,44 +4325,44 @@ static void calc_spells(void)
43254325 for (i = 63; i >= 0; i--)
43264326 {
43274327 /* Stop when possible */
4328- if (p_ptr->new_spells >= 0) break;
4328+ if (creature_ptr->new_spells >= 0) break;
43294329
43304330 /* Efficiency -- all done */
4331- if (!p_ptr->spell_learned1 && !p_ptr->spell_learned2) break;
4331+ if (!creature_ptr->spell_learned1 && !creature_ptr->spell_learned2) break;
43324332
43334333 /* Get the (i+1)th spell learned */
4334- j = p_ptr->spell_order[i];
4334+ j = creature_ptr->spell_order[i];
43354335
43364336 /* Skip unknown spells */
43374337 if (j >= 99) continue;
43384338
43394339 /* Forget it (if learned) */
43404340 if ((j < 32) ?
4341- (p_ptr->spell_learned1 & (1L << j)) :
4342- (p_ptr->spell_learned2 & (1L << (j - 32))))
4341+ (creature_ptr->spell_learned1 & (1L << j)) :
4342+ (creature_ptr->spell_learned2 & (1L << (j - 32))))
43434343 {
43444344 /* Mark as forgotten */
43454345 if (j < 32)
43464346 {
4347- p_ptr->spell_forgotten1 |= (1L << j);
4348- which = p_ptr->realm1;
4347+ creature_ptr->spell_forgotten1 |= (1L << j);
4348+ which = creature_ptr->realm1;
43494349 }
43504350 else
43514351 {
4352- p_ptr->spell_forgotten2 |= (1L << (j - 32));
4353- which = p_ptr->realm2;
4352+ creature_ptr->spell_forgotten2 |= (1L << (j - 32));
4353+ which = creature_ptr->realm2;
43544354 }
43554355
43564356 /* No longer known */
43574357 if (j < 32)
43584358 {
4359- p_ptr->spell_learned1 &= ~(1L << j);
4360- which = p_ptr->realm1;
4359+ creature_ptr->spell_learned1 &= ~(1L << j);
4360+ which = creature_ptr->realm1;
43614361 }
43624362 else
43634363 {
4364- p_ptr->spell_learned2 &= ~(1L << (j - 32));
4365- which = p_ptr->realm2;
4364+ creature_ptr->spell_learned2 &= ~(1L << (j - 32));
4365+ which = creature_ptr->realm2;
43664366 }
43674367
43684368 #ifdef JP
@@ -4373,7 +4373,7 @@ static void calc_spells(void)
43734373
43744374
43754375 /* One more can be learned */
4376- p_ptr->new_spells++;
4376+ creature_ptr->new_spells++;
43774377 }
43784378 }
43794379
@@ -4382,60 +4382,60 @@ static void calc_spells(void)
43824382 for (i = 0; i < 64; i++)
43834383 {
43844384 /* None left to remember */
4385- if (p_ptr->new_spells <= 0) break;
4385+ if (creature_ptr->new_spells <= 0) break;
43864386
43874387 /* Efficiency -- all done */
4388- if (!p_ptr->spell_forgotten1 && !p_ptr->spell_forgotten2) break;
4388+ if (!creature_ptr->spell_forgotten1 && !creature_ptr->spell_forgotten2) break;
43894389
43904390 /* Get the next spell we learned */
4391- j = p_ptr->spell_order[i];
4391+ j = creature_ptr->spell_order[i];
43924392
43934393 /* Skip unknown spells */
43944394 if (j >= 99) break;
43954395
43964396 /* Access the spell */
4397- if (!is_magic((j < 32) ? p_ptr->realm1 : p_ptr->realm2))
4397+ if (!is_magic((j < 32) ? creature_ptr->realm1 : creature_ptr->realm2))
43984398 {
43994399 if (j < 32)
4400- s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC][j];
4400+ s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
44014401 else
4402- s_ptr = &technic_info[p_ptr->realm2 - MIN_TECHNIC][j % 32];
4402+ s_ptr = &technic_info[creature_ptr->realm2 - MIN_TECHNIC][j % 32];
44034403 }
44044404 else if (j < 32)
4405- s_ptr = &mp_ptr->info[p_ptr->realm1 - 1][j];
4405+ s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
44064406 else
4407- s_ptr = &mp_ptr->info[p_ptr->realm2 - 1][j % 32];
4407+ s_ptr = &mp_ptr->info[creature_ptr->realm2 - 1][j % 32];
44084408
44094409 /* Skip spells we cannot remember */
4410- if (s_ptr->slevel > p_ptr->lev) continue;
4410+ if (s_ptr->slevel > creature_ptr->lev) continue;
44114411
44124412 /* First set of spells */
44134413 if ((j < 32) ?
4414- (p_ptr->spell_forgotten1 & (1L << j)) :
4415- (p_ptr->spell_forgotten2 & (1L << (j - 32))))
4414+ (creature_ptr->spell_forgotten1 & (1L << j)) :
4415+ (creature_ptr->spell_forgotten2 & (1L << (j - 32))))
44164416 {
44174417 /* No longer forgotten */
44184418 if (j < 32)
44194419 {
4420- p_ptr->spell_forgotten1 &= ~(1L << j);
4421- which = p_ptr->realm1;
4420+ creature_ptr->spell_forgotten1 &= ~(1L << j);
4421+ which = creature_ptr->realm1;
44224422 }
44234423 else
44244424 {
4425- p_ptr->spell_forgotten2 &= ~(1L << (j - 32));
4426- which = p_ptr->realm2;
4425+ creature_ptr->spell_forgotten2 &= ~(1L << (j - 32));
4426+ which = creature_ptr->realm2;
44274427 }
44284428
44294429 /* Known once more */
44304430 if (j < 32)
44314431 {
4432- p_ptr->spell_learned1 |= (1L << j);
4433- which = p_ptr->realm1;
4432+ creature_ptr->spell_learned1 |= (1L << j);
4433+ which = creature_ptr->realm1;
44344434 }
44354435 else
44364436 {
4437- p_ptr->spell_learned2 |= (1L << (j - 32));
4438- which = p_ptr->realm2;
4437+ creature_ptr->spell_learned2 |= (1L << (j - 32));
4438+ which = creature_ptr->realm2;
44394439 }
44404440
44414441 #ifdef JP
@@ -4446,25 +4446,25 @@ static void calc_spells(void)
44464446
44474447
44484448 /* One less can be learned */
4449- p_ptr->new_spells--;
4449+ creature_ptr->new_spells--;
44504450 }
44514451 }
44524452
44534453 k = 0;
44544454
4455- if (p_ptr->realm2 == REALM_NONE)
4455+ if (creature_ptr->realm2 == REALM_NONE)
44564456 {
44574457 /* Count spells that can be learned */
44584458 for (j = 0; j < 32; j++)
44594459 {
4460- if (!is_magic(p_ptr->realm1)) s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC][j];
4461- else s_ptr = &mp_ptr->info[p_ptr->realm1 - 1][j];
4460+ if (!is_magic(creature_ptr->realm1)) s_ptr = &technic_info[creature_ptr->realm1 - MIN_TECHNIC][j];
4461+ else s_ptr = &mp_ptr->info[creature_ptr->realm1 - 1][j];
44624462
44634463 /* Skip spells we cannot remember */
4464- if (s_ptr->slevel > p_ptr->lev) continue;
4464+ if (s_ptr->slevel > creature_ptr->lev) continue;
44654465
44664466 /* Skip spells we already know */
4467- if (p_ptr->spell_learned1 & (1L << j))
4467+ if (creature_ptr->spell_learned1 & (1L << j))
44684468 {
44694469 continue;
44704470 }
@@ -4473,44 +4473,44 @@ static void calc_spells(void)
44734473 k++;
44744474 }
44754475 if (k > 32) k = 32;
4476- if ((p_ptr->new_spells > k) &&
4476+ if ((creature_ptr->new_spells > k) &&
44774477 ((mp_ptr->spell_book == TV_LIFE_BOOK) || (mp_ptr->spell_book == TV_HISSATSU_BOOK)))
44784478 {
4479- p_ptr->new_spells = (s16b)k;
4479+ creature_ptr->new_spells = (s16b)k;
44804480 }
44814481 }
44824482
4483- if (p_ptr->new_spells < 0) p_ptr->new_spells = 0;
4483+ if (creature_ptr->new_spells < 0) creature_ptr->new_spells = 0;
44844484
44854485 /* Spell count changed */
4486- if (p_ptr->old_spells != p_ptr->new_spells)
4486+ if (creature_ptr->old_spells != creature_ptr->new_spells)
44874487 {
44884488 /* Message if needed */
4489- if (p_ptr->new_spells)
4489+ if (creature_ptr->new_spells)
44904490 {
44914491 #ifdef JP
4492- if (p_ptr->new_spells < 10) {
4493- msg_format("あと %d つの%sを学べる。", p_ptr->new_spells, p);
4492+ if (creature_ptr->new_spells < 10) {
4493+ msg_format("あと %d つの%sを学べる。", creature_ptr->new_spells, p);
44944494 }
44954495 else {
4496- msg_format("あと %d 個の%sを学べる。", p_ptr->new_spells, p);
4496+ msg_format("あと %d 個の%sを学べる。", creature_ptr->new_spells, p);
44974497 }
44984498 #else
44994499 msg_format("You can learn %d more %s%s.",
4500- p_ptr->new_spells, p,
4501- (p_ptr->new_spells != 1) ? "s" : "");
4500+ creature_ptr->new_spells, p,
4501+ (creature_ptr->new_spells != 1) ? "s" : "");
45024502 #endif
45034503
45044504 }
45054505
45064506 /* Save the new_spells value */
4507- p_ptr->old_spells = p_ptr->new_spells;
4507+ creature_ptr->old_spells = creature_ptr->new_spells;
45084508
45094509 /* Redraw Study Status */
4510- p_ptr->redraw |= (PR_STUDY);
4510+ creature_ptr->redraw |= (PR_STUDY);
45114511
45124512 /* Redraw object recall */
4513- p_ptr->window |= (PW_OBJECT);
4513+ creature_ptr->window |= (PW_OBJECT);
45144514 }
45154515 }
45164516
@@ -5032,7 +5032,7 @@ void update_creature(player_type *creature_ptr)
50325032 if (creature_ptr->update & (PU_SPELLS))
50335033 {
50345034 creature_ptr->update &= ~(PU_SPELLS);
5035- calc_spells();
5035+ calc_spells(creature_ptr);
50365036 }
50375037
50385038 /* Character is not ready yet, no screen updates */
Show on old repository browser