Sets the players custom texture. If filename=NULL then sets to no texture Returns 1 if filename was successfully loaded, else 0
| 3585 | // Sets the players custom texture. If filename=NULL then sets to no texture |
| 3586 | // Returns 1 if filename was successfully loaded, else 0 |
| 3587 | int PlayerSetCustomTexture(int slot, char *filename) { |
| 3588 | // Free up previous vclip/bitmap if there is one |
| 3589 | texture *texp = &GameTextures[Players[slot].custom_texture_handle]; |
| 3590 | int bm_handle = texp->bm_handle; |
| 3591 | |
| 3592 | if (bm_handle != 0) { |
| 3593 | if (texp->flags & TF_ANIMATED) |
| 3594 | FreeVClip(bm_handle); |
| 3595 | else |
| 3596 | bm_FreeBitmap(bm_handle); |
| 3597 | |
| 3598 | texp->bm_handle = 0; |
| 3599 | } |
| 3600 | |
| 3601 | // Now load the new one |
| 3602 | texp->bm_handle = 0; |
| 3603 | if (filename == NULL) |
| 3604 | return 1; |
| 3605 | |
| 3606 | int anim; |
| 3607 | int new_handle = LoadTextureImage(filename, &anim, SMALL_TEXTURE, 1, 0); |
| 3608 | |
| 3609 | if (new_handle < 0) |
| 3610 | return 0; |
| 3611 | |
| 3612 | texp->bm_handle = new_handle; |
| 3613 | if (anim) |
| 3614 | texp->flags |= TF_ANIMATED; |
| 3615 | else |
| 3616 | texp->flags &= ~TF_ANIMATED; |
| 3617 | |
| 3618 | texp->flags |= TF_TEXTURE_64; |
| 3619 | |
| 3620 | // Set texture speed |
| 3621 | if (texp->flags & TF_ANIMATED) { |
| 3622 | vclip *vc = &GameVClips[texp->bm_handle]; |
| 3623 | texp->speed = vc->num_frames * (1.0 / PLAYER_TEXTURE_FPS); |
| 3624 | } |
| 3625 | |
| 3626 | return 1; |
| 3627 | } |
| 3628 | |
| 3629 | // Sets/Clears a permission for a ship on a given player |
| 3630 | // if pnum is -1 then all players will be set, else player is the player number |
no test coverage detected