Bonne idée.
This commit is contained in:
		| @@ -40,6 +40,7 @@ public: | |||||||
| 	int getScore() const; | 	int getScore() const; | ||||||
| 	void addPoint(); | 	void addPoint(); | ||||||
| 	uint64_t Killer = 0; | 	uint64_t Killer = 0; | ||||||
|  | 	std::string m_username; | ||||||
|  |  | ||||||
| private: | private: | ||||||
| 	uint64_t getId() const; | 	uint64_t getId() const; | ||||||
| @@ -49,7 +50,6 @@ protected: | |||||||
| 	Vector3f m_velocity; | 	Vector3f m_velocity; | ||||||
| 	Vector3f m_direction; | 	Vector3f m_direction; | ||||||
|  |  | ||||||
| 	std::string m_username; |  | ||||||
| 	uint64_t id = 0; | 	uint64_t id = 0; | ||||||
| 	int m_score = 0; | 	int m_score = 0; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -118,6 +118,11 @@ Timestamp Connection::Run(World* world) { | |||||||
| 	if (m_input_manifest.size() < 2) | 	if (m_input_manifest.size() < 2) | ||||||
| 		return tstamp; | 		return tstamp; | ||||||
|  |  | ||||||
|  | 	if (player->AmIDead()) { | ||||||
|  | 		m_input_manifest.clear(); | ||||||
|  | 		return tstamp; | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	while (m_last_in < m_input_vector.size() - 1) { | 	while (m_last_in < m_input_vector.size() - 1) { | ||||||
| 		in = m_input_vector.at(m_last_in + 1); | 		in = m_input_vector.at(m_last_in + 1); | ||||||
| 		last = m_input_vector.at(m_last_in); | 		last = m_input_vector.at(m_last_in); | ||||||
|   | |||||||
| @@ -203,6 +203,7 @@ void Server::Run() { | |||||||
| 		int x = 0,// (rand() % (CHUNK_SIZE_X * WORLD_SIZE_X - 1)),// -(CHUNK_SIZE_X * WORLD_SIZE_X / 2), | 		int x = 0,// (rand() % (CHUNK_SIZE_X * WORLD_SIZE_X - 1)),// -(CHUNK_SIZE_X * WORLD_SIZE_X / 2), | ||||||
| 			y = 0;// (rand() % (CHUNK_SIZE_Y * WORLD_SIZE_Y - 1));// -(CHUNK_SIZE_Y * WORLD_SIZE_Y / 2); | 			y = 0;// (rand() % (CHUNK_SIZE_Y * WORLD_SIZE_Y - 1));// -(CHUNK_SIZE_Y * WORLD_SIZE_Y / 2); | ||||||
| 		conn->player = new Player(Vector3f(x + .5f, CHUNK_SIZE_Y + 1.8f, y + .5f)); | 		conn->player = new Player(Vector3f(x + .5f, CHUNK_SIZE_Y + 1.8f, y + .5f)); | ||||||
|  | 		conn->player->m_username = conn->GetName(); | ||||||
| 		m_players[key] = conn->player; | 		m_players[key] = conn->player; | ||||||
| 		Sync sync; | 		Sync sync; | ||||||
| 		sync.position = conn->player->GetPositionAbs(); | 		sync.position = conn->player->GetPositionAbs(); | ||||||
| @@ -230,7 +231,8 @@ void Server::Run() { | |||||||
| 			last = tstamp; | 			last = tstamp; | ||||||
| 		sync_acc += tstamp - last; | 		sync_acc += tstamp - last; | ||||||
| 		if (sync_acc >= 1000) { | 		if (sync_acc >= 1000) { | ||||||
| 			sync_acc -= 1000; | 			while (sync_acc >= 1000) | ||||||
|  | 				sync_acc -= 1000; | ||||||
| 			--timer; | 			--timer; | ||||||
| 			std::string str = "Timer: "; | 			std::string str = "Timer: "; | ||||||
| 			Log(str.append(std::to_string(timer).append(" SyncAcc: ").append(std::to_string(sync_acc))), false, false); | 			Log(str.append(std::to_string(timer).append(" SyncAcc: ").append(std::to_string(sync_acc))), false, false); | ||||||
| @@ -269,7 +271,7 @@ void Server::Run() { | |||||||
| 			if (conn->m_nsync) { | 			if (conn->m_nsync) { | ||||||
| 				Timestamp tstamp = conn->Run(m_world); | 				Timestamp tstamp = conn->Run(m_world); | ||||||
|  |  | ||||||
| 				if (conn->player->AmIDead()) { | 				if (conn->player->AmIDead() && tstamp) { | ||||||
| 					Chat chat; | 					Chat chat; | ||||||
| 					chat.dest_id = chat.dest_team_id =  chat.src_id = 0; | 					chat.dest_id = chat.dest_team_id =  chat.src_id = 0; | ||||||
|  |  | ||||||
| @@ -277,10 +279,10 @@ void Server::Run() { | |||||||
| 					 | 					 | ||||||
| 					std::string mess = getDeathMessage(conn->player->GetUsername(), killer); | 					std::string mess = getDeathMessage(conn->player->GetUsername(), killer); | ||||||
| 					 | 					 | ||||||
| 					strcpy(chat.mess, mess.c_str()); | 					strcpy(chat.mess, 140, mess.c_str()); | ||||||
|  | 					Log("You is dead", false, false); | ||||||
|  |  | ||||||
| 					m_chatlog[tstamp] = chat; | 					m_chatlog[tstamp] = chat; | ||||||
|  |  | ||||||
| 					++deadplayers; | 					++deadplayers; | ||||||
| 					conn->m_nsync == false; | 					conn->m_nsync == false; | ||||||
| 				} | 				} | ||||||
| @@ -434,13 +436,19 @@ std::string Server::getDeathMessage(std::string username, std::string killer) co | |||||||
| 	std::string temp = DEATHMESSAGES.at(rand() % DEATHMESSAGES.size()); | 	std::string temp = DEATHMESSAGES.at(rand() % DEATHMESSAGES.size()); | ||||||
| 	size_t ind = temp.find('@'); | 	size_t ind = temp.find('@'); | ||||||
| 	size_t indk = temp.find('$'); | 	size_t indk = temp.find('$'); | ||||||
|  | 	bool bypass = false; | ||||||
|  |  | ||||||
| 	if (ind < indk) { | 	if (indk == std::string::npos) | ||||||
|  | 		bypass = true; | ||||||
|  |  | ||||||
|  | 	if (ind < indk || bypass) { | ||||||
| 		mess.append(temp.substr(0, ind)); | 		mess.append(temp.substr(0, ind)); | ||||||
| 		mess.append(username); | 		mess.append(username); | ||||||
| 		mess.append(temp.substr(ind + 1, indk)); | 		if (!bypass) { | ||||||
| 		mess.append(killer); | 			mess.append(temp.substr(ind + 1, indk)); | ||||||
| 		mess.append(temp.substr(indk + 1)); | 			mess.append(killer); | ||||||
|  | 			mess.append(temp.substr(indk + 1)); | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
| 	else { | 	else { | ||||||
| 		mess.append(temp.substr(0, indk)); | 		mess.append(temp.substr(0, indk)); | ||||||
|   | |||||||
| @@ -431,6 +431,8 @@ void Engine::DisplayHud(int timer) { | |||||||
|  |  | ||||||
| 	// HP Bar | 	// HP Bar | ||||||
| 	float playerHp = m_player.GetHP(); | 	float playerHp = m_player.GetHP(); | ||||||
|  | 	if (playerHp < 0.) | ||||||
|  | 		playerHp == 0; | ||||||
| 	float facteurOmbrage = m_displayInfo ? 0.5f : 1.0f; | 	float facteurOmbrage = m_displayInfo ? 0.5f : 1.0f; | ||||||
|  |  | ||||||
| 	float hpBarWidthProportion = 0.25f; | 	float hpBarWidthProportion = 0.25f; | ||||||
| @@ -720,11 +722,11 @@ void Engine::DisplayInfo(float elapsedTime, BlockType bloc) { | |||||||
| 	ss.str(""); | 	ss.str(""); | ||||||
| 	fPosY -= charSize; | 	fPosY -= charSize; | ||||||
|  |  | ||||||
| 	ss << " Block  : "; | 	//ss << " Block  : "; | ||||||
| 	if (bloc == BTYPE_LAST) | 	//if (bloc == BTYPE_LAST) | ||||||
| 		ss << "Weapon"; | 	//	ss << "Weapon"; | ||||||
| 	else | 	//else | ||||||
| 		ss << (int)bloc; | 	//	ss << (int)bloc; | ||||||
| 	PrintText(fPosX, fPosYJump, ss.str()); | 	PrintText(fPosX, fPosYJump, ss.str()); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -1341,10 +1343,6 @@ void Engine::Render(float elapsedTime) { | |||||||
| 			m_audio.Create3DAudioObj(m_scream, AUDIO_PATH "scream.wav", m_player.GetPOV(), m_player.GetVelocity(), false, 1.f); | 			m_audio.Create3DAudioObj(m_scream, AUDIO_PATH "scream.wav", m_player.GetPOV(), m_player.GetVelocity(), false, 1.f); | ||||||
| 			fell = true; | 			fell = true; | ||||||
| 		} | 		} | ||||||
| 		else if (m_player.GetPosition().y < -20.f) { |  | ||||||
| 			m_player = Player(Vector3f(.5f, CHUNK_SIZE_Y + 1.8f, .5f)); // Respawn si le bonho- joueur tombe en bas du monde. |  | ||||||
| 			fell = false; |  | ||||||
| 		} |  | ||||||
|  |  | ||||||
| 		if (m_networkgame) { // Pour se gerer le paquet. | 		if (m_networkgame) { // Pour se gerer le paquet. | ||||||
| 			static bool has_synced = false; | 			static bool has_synced = false; | ||||||
| @@ -1381,7 +1379,8 @@ void Engine::Render(float elapsedTime) { | |||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			if (cmod_acc >= 1000) { | 			if (cmod_acc >= 1000) { | ||||||
| 				cmod_acc -= 1000; | 				while (cmod_acc >= 1000) | ||||||
|  | 					cmod_acc -= 1000; | ||||||
| 				if (!m_chunkmod_manifest.empty()) { | 				if (!m_chunkmod_manifest.empty()) { | ||||||
| 					ChunkMod* cmod = m_chunkmod_manifest.front(); | 					ChunkMod* cmod = m_chunkmod_manifest.front(); | ||||||
| 					m_chunkmod_manifest.pop_front(); | 					m_chunkmod_manifest.pop_front(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user