Changeset 7221 in orxonox.OLD for trunk/src/world_entities/weapons
- Timestamp:
- Mar 15, 2006, 3:10:45 PM (19 years ago)
- Location:
- trunk/src/world_entities/weapons
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/weapons/aim.cc
r7193 r7221 147 147 * @param textureFile The texture-file to load onto the crosshair 148 148 */ 149 void Aim::setTexture(const char*textureFile)149 void Aim::setTexture(const std::string& textureFile) 150 150 { 151 151 this->material->setDiffuseMap(textureFile); -
trunk/src/world_entities/weapons/aim.h
r6724 r7221 46 46 47 47 void setSize(float size); 48 void setTexture(const char*textureFile);48 void setTexture(const std::string& textureFile); 49 49 /** @param rotationSpeed the speed at what the crosshair should rotate */ 50 50 inline void setRotationSpeed(float rotationSpeed) { this->rotationSpeed = rotationSpeed; }; -
trunk/src/world_entities/weapons/aiming_turret.cc
r7193 r7221 168 168 glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); 169 169 170 this->getModel()->draw(); 170 if (this->getModel()) 171 this->getModel()->draw(); 171 172 glPopMatrix(); 172 173 } -
trunk/src/world_entities/weapons/crosshair.cc
r7193 r7221 79 79 EventListener::loadParams(root); 80 80 81 LoadParam(root, "texture", this , Crosshair, setTexture)81 LoadParam(root, "texture", this->material, Material, setDiffuseMap) 82 82 .describe("the texture-file to load onto the Crosshair"); 83 83 … … 103 103 * @param textureFile The texture-file to load onto the crosshair 104 104 */ 105 void Crosshair::setTexture(const char*textureFile)105 void Crosshair::setTexture(const std::string& textureFile) 106 106 { 107 107 this->material->setDiffuseMap(textureFile); -
trunk/src/world_entities/weapons/crosshair.h
r6512 r7221 31 31 32 32 void setSize(float size); 33 void setTexture(const char*textureFile);33 void setTexture(const std::string& textureFile); 34 34 /** @param rotationSpeed the speed at what the crosshair should rotate */ 35 35 void setRotationSpeed(float rotationSpeed) { this->rotationSpeed = rotationSpeed; }; -
trunk/src/world_entities/weapons/weapon.cc
r7193 r7221 165 165 * @param projectile the Name of the Projectile. 166 166 */ 167 void Weapon::setProjectileTypeC(const char* projectile) 168 { 169 if (projectile == NULL) 170 return; 167 void Weapon::setProjectileTypeC(const std::string& projectile) 168 { 171 169 FastFactory* tmpFac = FastFactory::searchFastFactory(projectile); 172 170 if (tmpFac != NULL) … … 176 174 else 177 175 { 178 PRINTF(1)("Projectile %s does not exist for weapon %s\n", projectile , this->getName());176 PRINTF(1)("Projectile %s does not exist for weapon %s\n", projectile.c_str(), this->getName()); 179 177 } 180 178 } … … 232 230 * @param soundFile the soundFile's relative position to the data-directory (will be looked for by the ResourceManager) 233 231 */ 234 void Weapon::setActionSound(WeaponAction action, const char*soundFile)232 void Weapon::setActionSound(WeaponAction action, const std::string& soundFile) 235 233 { 236 234 if (action >= WA_ACTION_COUNT) … … 239 237 ResourceManager::getInstance()->unload(this->soundBuffers[action]); 240 238 241 else if ( soundFile != NULL)239 else if (!soundFile.empty()) 242 240 { 243 241 this->soundBuffers[action] = (SoundBuffer*)ResourceManager::getInstance()->load(soundFile, WAV); 244 242 if (this->soundBuffers[action] != NULL) 245 243 { 246 PRINTF(4)("Loaded sound %s to action %s.\n", soundFile , actionToChar(action));244 PRINTF(4)("Loaded sound %s to action %s.\n", soundFile.c_str(), actionToChar(action)); 247 245 } 248 246 else 249 247 { 250 PRINTF(2)("Failed to load sound %s to %s.\n.", soundFile , actionToChar(action));248 PRINTF(2)("Failed to load sound %s to %s.\n.", soundFile.c_str(), actionToChar(action)); 251 249 } 252 250 } … … 613 611 * @return The Action if known, WA_NONE otherwise. 614 612 */ 615 WeaponAction Weapon::charToAction(const char*action)616 { 617 if ( !strcmp(action, "none"))613 WeaponAction Weapon::charToAction(const std::string& action) 614 { 615 if (action == "none") 618 616 return WA_NONE; 619 else if ( !strcmp(action, "shoot"))617 else if (action == "shoot") 620 618 return WA_SHOOT; 621 else if ( !strcmp(action, "charge"))619 else if (action == "charge") 622 620 return WA_CHARGE; 623 else if ( !strcmp(action, "reload"))621 else if (action == "reload") 624 622 return WA_RELOAD; 625 else if ( !strcmp(action, "acitvate"))623 else if (action == "acitvate") 626 624 return WA_ACTIVATE; 627 else if ( !strcmp(action, "deactivate"))625 else if (action == "deactivate") 628 626 return WA_DEACTIVATE; 629 else if ( !strcmp(action, "special1"))627 else if (action == "special1") 630 628 return WA_SPECIAL1; 631 629 else 632 630 { 633 PRINTF(2)("action %s could not be identified.\n", action );631 PRINTF(2)("action %s could not be identified.\n", action.c_str()); 634 632 return WA_NONE; 635 633 } … … 674 672 * @return The State if known, WS_NONE otherwise. 675 673 */ 676 WeaponState Weapon::charToState(const char*state)677 { 678 if ( !strcmp(state, "none"))674 WeaponState Weapon::charToState(const std::string& state) 675 { 676 if (state == "none") 679 677 return WS_NONE; 680 else if ( !strcmp(state, "shooting"))678 else if (state == "shooting") 681 679 return WS_SHOOTING; 682 else if ( !strcmp(state, "charging"))680 else if (state == "charging") 683 681 return WS_CHARGING; 684 else if ( !strcmp(state, "reloading"))682 else if (state == "reloading") 685 683 return WS_RELOADING; 686 else if ( !strcmp(state, "activating"))684 else if (state == "activating") 687 685 return WS_ACTIVATING; 688 else if ( !strcmp(state, "deactivating"))686 else if (state == "deactivating") 689 687 return WS_DEACTIVATING; 690 else if ( !strcmp(state, "inactive"))688 else if (state == "inactive") 691 689 return WS_INACTIVE; 692 else if ( !strcmp(state, "idle"))690 else if (state == "idle") 693 691 return WS_IDLE; 694 692 else 695 693 { 696 PRINTF(2)("state %s could not be identified.\n", state );694 PRINTF(2)("state %s could not be identified.\n", state.c_str()); 697 695 return WS_NONE; 698 696 } -
trunk/src/world_entities/weapons/weapon.h
r7102 r7221 111 111 inline long getCapability() const { return this->capability; }; 112 112 void setProjectileType(ClassID projectile); 113 void setProjectileTypeC(const char*projectile);113 void setProjectileTypeC(const std::string& projectile); 114 114 /** @returns The projectile's classID */ 115 115 inline ClassID getProjectileType() { return this->projectile; }; … … 132 132 // STATE CHANGES // 133 133 /** @param state the State to time @param duration the duration of the State */ 134 inline void setStateDuration(const char*state, float duration) { setStateDuration(charToState(state), duration); };134 inline void setStateDuration(const std::string& state, float duration) { setStateDuration(charToState(state), duration); }; 135 135 /** @param state the State to time @param duration the duration of the State */ 136 136 inline void setStateDuration(WeaponState state, float duration) { /*(state < WS_STATE_COUNT)?*/this->times[state] = duration; }; … … 148 148 inline void setAmmoContainer(const CountPointer<AmmoContainer>& ammoContainer) { this->ammoContainer = ammoContainer;} 149 149 150 void setActionSound(WeaponAction action, const char*soundFile);151 /** @see void setActionSound(WeaponAction action, const char*soundFile); */152 void setActionSound(const char* action, const char*soundFile) { this->setActionSound(charToAction(action), soundFile); };150 void setActionSound(WeaponAction action, const std::string& soundFile); 151 /** @see void setActionSound(WeaponAction action, const std::string& soundFile); */ 152 void setActionSound(const std::string& action, const std::string& soundFile) { this->setActionSound(charToAction(action), soundFile); }; 153 153 154 154 Animation3D* getAnimation(WeaponState state, PNode* node = NULL); … … 176 176 177 177 // utility: 178 static WeaponAction charToAction(const char*action);178 static WeaponAction charToAction(const std::string& action); 179 179 static const char* actionToChar(WeaponAction action); 180 static WeaponState charToState(const char*state);180 static WeaponState charToState(const std::string& state); 181 181 static const char* stateToChar(WeaponState state); 182 182
Note: See TracChangeset
for help on using the changeset viewer.