comparison pytouhou/game/game.pyx @ 617:a6af3ff86612

Change all “void except *” function into “bint except True”, to prevent PyErr_Occurred() from being called at each call.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 29 Mar 2015 00:08:20 +0100
parents 3c2f96f1d715
children cd8a2baf468c
comparison
equal deleted inserted replaced
616:4ce3ef053a25 617:a6af3ff86612
117 self.spellcard_effect = None 117 self.spellcard_effect = None
118 if 'enemy_spellcard' in self.texts: 118 if 'enemy_spellcard' in self.texts:
119 del self.texts['enemy_spellcard'] 119 del self.texts['enemy_spellcard']
120 120
121 121
122 cdef void set_player_bomb(self) except *: 122 cdef bint set_player_bomb(self) except True:
123 face = Effect((-32, -16), 1, self.msg_anm[0][0][0]) 123 face = Effect((-32, -16), 1, self.msg_anm[0][0][0])
124 face.sprite.allow_dest_offset = True 124 face.sprite.allow_dest_offset = True
125 self.effects.append(face) 125 self.effects.append(face)
126 self.texts['player_spellcard'] = self.new_native_text((24, 24), u'Player Spellcard') 126 self.texts['player_spellcard'] = self.new_native_text((24, 24), u'Player Spellcard')
127 127
128 128
129 cdef void unset_player_bomb(self) except *: 129 cdef bint unset_player_bomb(self) except True:
130 del self.texts['player_spellcard'] 130 del self.texts['player_spellcard']
131 131
132 132
133 cpdef drop_bonus(self, double x, double y, long _type, end_pos=None, player=None): 133 cpdef drop_bonus(self, double x, double y, long _type, end_pos=None, player=None):
134 if _type > 6: 134 if _type > 6:
138 item_type = self.item_types[_type] 138 item_type = self.item_types[_type]
139 self.items.append(Item((x, y), _type, item_type, self, end_pos=end_pos, 139 self.items.append(Item((x, y), _type, item_type, self, end_pos=end_pos,
140 player=player)) 140 player=player))
141 141
142 142
143 cdef void autocollect(self, Player player) except *: 143 cdef bint autocollect(self, Player player) except True:
144 cdef Item item 144 cdef Item item
145 145
146 for item in self.items: 146 for item in self.items:
147 item.autocollect(player) 147 item.autocollect(player)
148 148
149 149
150 cdef void cancel_bullets(self) except *: 150 cdef bint cancel_bullets(self) except True:
151 cdef Bullet bullet 151 cdef Bullet bullet
152 cdef Laser laser 152 cdef Laser laser
153 153
154 for bullet in self.bullets: 154 for bullet in self.bullets:
155 bullet.cancel() 155 bullet.cancel()
156 for laser in self.lasers: 156 for laser in self.lasers:
157 laser.cancel() 157 laser.cancel()
158 158
159 cdef void cancel_player_lasers(self) except *: 159 cdef bint cancel_player_lasers(self) except True:
160 cdef PlayerLaser laser 160 cdef PlayerLaser laser
161 for laser in self.players_lasers: 161 for laser in self.players_lasers:
162 if laser is not None: 162 if laser is not None:
163 laser.cancel() 163 laser.cancel()
164 164
317 self.cleanup() 317 self.cleanup()
318 318
319 self.frame += 1 319 self.frame += 1
320 320
321 321
322 cdef void update_background(self) except *: 322 cdef bint update_background(self) except True:
323 if self.time_stop: 323 if self.time_stop:
324 return 324 return False
325 if self.spellcard_effect is not None: 325 if self.spellcard_effect is not None:
326 self.spellcard_effect.update() 326 self.spellcard_effect.update()
327 #TODO: update the actual background here? 327 #TODO: update the actual background here?
328 328
329 329
330 cdef void update_enemies(self) except *: 330 cdef bint update_enemies(self) except True:
331 cdef Enemy enemy 331 cdef Enemy enemy
332 332
333 for enemy in self.enemies: 333 for enemy in self.enemies:
334 enemy.update() 334 enemy.update()
335 335
336 336
337 cdef void update_msg(self, long keystate) except *: 337 cdef bint update_msg(self, long keystate) except True:
338 cdef long k 338 cdef long k
339 339
340 for k in (1, 256): 340 for k in (1, 256):
341 if keystate & k and not self.last_keystate & k: 341 if keystate & k and not self.last_keystate & k:
342 self.msg_runner.skip() 342 self.msg_runner.skip()
344 self.msg_runner.skipping = bool(keystate & 256) 344 self.msg_runner.skipping = bool(keystate & 256)
345 self.last_keystate = keystate 345 self.last_keystate = keystate
346 self.msg_runner.run_iteration() 346 self.msg_runner.run_iteration()
347 347
348 348
349 cdef void update_players(self, list keystates) except *: 349 cdef bint update_players(self, list keystates) except True:
350 cdef Bullet bullet 350 cdef Bullet bullet
351 cdef Player player 351 cdef Player player
352 cdef long keystate 352 cdef long keystate
353 353
354 if self.time_stop: 354 if self.time_stop:
355 return 355 return False
356 356
357 for bullet in self.players_bullets: 357 for bullet in self.players_bullets:
358 bullet.update() 358 bullet.update()
359 359
360 for player, keystate in zip(self.players, keystates): 360 for player, keystate in zip(self.players, keystates):
371 player.lives += 1 371 player.lives += 1
372 self.modify_difficulty(+2) 372 self.modify_difficulty(+2)
373 player.play_sound('extend') 373 player.play_sound('extend')
374 374
375 375
376 cdef void update_effects(self) except *: 376 cdef bint update_effects(self) except True:
377 cdef Element effect 377 cdef Element effect
378 378
379 for effect in self.effects: 379 for effect in self.effects:
380 effect.update() 380 effect.update()
381 381
382 382
383 cdef void update_hints(self) except *: 383 cdef bint update_hints(self) except True:
384 for hint in self.hints: 384 for hint in self.hints:
385 if hint['Count'] == self.frame and hint['Base'] == 'start': 385 if hint['Count'] == self.frame and hint['Base'] == 'start':
386 self.new_hint(hint) 386 self.new_hint(hint)
387 387
388 388
389 cdef void update_faces(self) except *: 389 cdef bint update_faces(self) except True:
390 for face in self.faces: 390 for face in self.faces:
391 if face: 391 if face:
392 face.update() 392 face.update()
393 393
394 394
395 cdef void update_bullets(self) except *: 395 cdef bint update_bullets(self) except True:
396 cdef Player player 396 cdef Player player
397 cdef Bullet bullet 397 cdef Bullet bullet
398 cdef Item item 398 cdef Item item
399 cdef PlayerLaser player_laser 399 cdef PlayerLaser player_laser
400 cdef Laser laser 400 cdef Laser laser
401 cdef PlayerLaser plaser 401 cdef PlayerLaser plaser
402 cdef double player_pos[2] 402 cdef double player_pos[2]
403 403
404 if self.time_stop: 404 if self.time_stop:
405 return 405 return False
406 406
407 for bullet in self.cancelled_bullets: 407 for bullet in self.cancelled_bullets:
408 bullet.update() 408 bullet.update()
409 409
410 for bullet in self.bullets: 410 for bullet in self.bullets: