Ejemplo n.º 1
0
void PingAllPlayer(int writesocket)
{
	int i;
	for (i = 1; i <= sv_maxplayers; i++)
	{
		if (player[i].used == 1 && player[i].joinstatus >= 4)
		{
			int stringsize = 5;
			unsigned char *buffer = malloc(stringsize);
			if (buffer == NULL)
				error_exit("Memory error ( SendJoinMessage() )\n");

			int position = 0;

			buffer[position] = 249;
			position++;
			buffer[position] = 0;
			position++;
			buffer[position] = 32;
			position++;
			buffer[position] = 191;
			position++;
			buffer[position] = 0;
			position++;

			player[i].start = mtime();

			SendToPlayer(buffer, stringsize, i, 0, writesocket);

			free(buffer);
		}

	}
}
Ejemplo n.º 2
0
void SendBuyMessage(int id, int wpnid, int writesocket)
{
	int stringsize = 6;
	unsigned char *buffer = malloc(stringsize);
	if (buffer == NULL)
		error_exit("Memory error ( SendBuyMessage() )\n");

	int position = 0;

	buffer[position] = 23;
	position++;
	buffer[position] = id;
	position++;
	buffer[position] = wpnid;
	position++;
	memcpy(buffer + position, &player[id].money, 2);
	position += 2;
	buffer[position] = 0;
	position++;

	SendToPlayer(buffer, stringsize, id, 1, writesocket);

	free(buffer);

	SendWeaponChangeMessage(id, wpnid, writesocket);
}
Ejemplo n.º 3
0
void SendBuyMessage(int id, int wpnid){
	byte buffer[] = {23,id,wpnid, SHORT(player[id].money), 0};
	SendToPlayer(buffer, 6, id, 1);

	if (weapons[wpnid].slot > 0)
		SendWeaponChangeMessage(id, wpnid);
}
Ejemplo n.º 4
0
//FIXME complete SendKillMessage
void SendKillMessage(int id, int victim)
{
	int suicide = 0;
	if (id == 0) {id = victim; suicide = 1;}
	byte sHealth[4];
	byte sArmor[4]; //= player[id].health
	int sHealthLength = sprintf((char*)sHealth, "%i", (int) player[id].health);
	int sArmorLength = sprintf((char*)sArmor, "%i", (int) player[id].armor);
	int sNameLength = u_strlen(player[id].name);
	int length = 4 + sNameLength + sHealthLength + sArmorLength;

	stream* buf = init_stream(NULL);
	byte buffer[] = {19,victim,((suicide == 1) ? 0 : id),
					player[id].actualweapon,
					SHORT(*player[victim].x),SHORT(*player[victim].y),
					240,0,1,SHORT(length),'k',166}; // 166 acts like a string separator, rest of this line is like wtf
	Stream.write(buf, buffer, 15);
	if (suicide == 0) {
		Stream.write(buf, player[id].name, sNameLength);
		Stream.write_byte(buf, 166);
		Stream.write(buf, sHealth, sHealthLength);
		Stream.write_byte(buf, 166);
		Stream.write(buf, sArmor, sArmorLength);
		Stream.write_byte(buf, 166);
	}

	SendToPlayer(buf->mem, buf->size, victim, 1);
	free(buf->mem);
	free(buf);

	byte buffer2[] = {19,victim,id,player[id].actualweapon,SHORT(*player[victim].x),SHORT(*player[victim].y)};
	SendToAllOther(victim, buffer2, 8, 1);
}
Ejemplo n.º 5
0
void SendMessageToPlayer(int id, char *message, int status){
	stream* buf = init_stream(NULL);
	byte buffer[] = {240,0,status};
	Stream.write(buf, buffer,3);
	Stream.write_str2(buf, (byte*)message);
	SendToPlayer(buf->mem, buf->size, id, 1);
	printf("To %s (%s): %s\n", player[id].name, status==1?"Chat":status==2?"Screen":"Console", message);

	free(buf);
}
Ejemplo n.º 6
0
void SendRconPwMessage(int id, const unsigned char* message, int len, unsigned char success)
{
	int stringsize = len + 1;
	unsigned char *buffer = malloc(stringsize * sizeof(char));
	if (buffer == NULL)
		error_exit("Memory error ( SendRconPwMessage() )\n");
	memcpy(buffer, (void*) message, len);
	buffer[stringsize] = success;
	SendToPlayer(buffer, stringsize, id, 1);
	free(buffer);
}
Ejemplo n.º 7
0
void SendMessageToPlayer(int id, char *message, int status, int writesocket)
{
	/*
	 1 - Chat
	 2 - Screen
	 3 - Console
	 4 - Crash
	 */
	int stringsize = 5 + strlen(message);
	unsigned char *buffer = malloc(stringsize);
	if (buffer == NULL)
		error_exit("Memory error ( SendChatMessage() )\n");

	int position = 0;

	buffer[position] = 240;
	position++;
	buffer[position] = 0;
	position++;
	buffer[position] = status;
	position++;
	buffer[position] = strlen(message);
	position++;
	buffer[position] = 0;
	position++;
	memcpy(buffer + position, message, strlen(message));
	position += strlen(message);

	SendToPlayer(buffer, stringsize, id, 1, writesocket);

	switch (status)
	{
	case 1:
		printf("To %s (Chat): %s\n", player[id].name ,message);
		break;
	case 2:
		printf("To %s (Screen): %s\n", player[id].name ,message);
		break;
	case 3:
		printf("To %s (Console): %s\n", player[id].name ,message);
		break;
	default:
		printf("Unknown status (SendMessageToPlayer())!\n");
		break;
	}

	free(buffer);
}
Ejemplo n.º 8
0
void PhasingHandler::UpdateVisibilityIfNeeded(WorldObject* object, bool updateVisibility, bool changed)
{
    if (changed && object->IsInWorld())
    {
        if (Player* player = object->ToPlayer())
            SendToPlayer(player);

        if (updateVisibility)
        {
            if (Player* player = object->ToPlayer())
                player->GetMap()->SendUpdateTransportVisibility(player);

            object->UpdateObjectVisibility();
        }
    }
}
Ejemplo n.º 9
0
void SendBuyFailedMessage(int id, int status, int writesocket)
{
	int stringsize = 6;
	unsigned char *buffer = malloc(stringsize);
	if (buffer == NULL)
		error_exit("Memory error ( SendBuyFailedMessage() )\n");

	int position = 0;
	buffer[position] = 23;
	position++;
	buffer[position] = id;
	position++;
	buffer[position] = status;
	position++;
	buffer[position] = 44;
	position++;
	buffer[position] = 1;
	position++;
	buffer[position] = 0;
	position++;
	//TODO what does the last lines mean?

	/*
	 * 242 nothing
	 * 243 Grenade rebuying is not allowed at this server
	 * 244 it's not allowed to buy that weapon at this server
	 * 245 you can't carry more of this
	 * 246 you can't carry more of this
	 * 247 you can't carry an additional weapon
	 * 248 you can't buy more ammo
	 * 249 you are not allowed to buy anything
	 * 250 buying is not allowed
	 * 251 you have already this or something better
	 * 252 you can't buy this item;
	 * 253 insufficient fund;
	 * 254 buytime passed;
	 * 255 you are not in a buyzone
	 *
	 */

	SendToPlayer(buffer, stringsize, id, 1, writesocket);

	free(buffer);
}
Ejemplo n.º 10
0
void SendBuyFailedMessage(int id, int status){
	//TODO what does the 44,1,0 do?
	byte buffer[] = {23,id,status,44,1,0};
	/* Status ->
	 * 242 nothing
	 * 243 Grenade rebuying is not allowed at this server
	 * 244 it's not allowed to buy that weapon at this server
	 * 245 you can't carry more of this
	 * 246 you can't carry more of this
	 * 247 you can't carry an additional weapon
	 * 248 you can't buy more ammo
	 * 249 you are not allowed to buy anything
	 * 250 buying is not allowed
	 * 251 you have already this or something better
	 * 252 you can't buy this item;
	 * 253 insufficient fund;
	 * 254 buytime passed;
	 * 255 you are not in a buyzone
	 */
	SendToPlayer(buffer, 6, id, 1);
}
Ejemplo n.º 11
0
//FIXME complete SendKillMessage
void SendKillMessage(int id, int victim, int writesocket)
{
	char sHealth[4];
	char sArmor[4]; //= player[id].health
	int sHealthLength = sprintf(sHealth, "%i", (int) player[id].health);
	int sArmorLength = sprintf(sArmor, "%i", (int) player[id].armor);
	int sNameLength = u_strlen(player[id].name);

	int length = 4 + sNameLength + sHealthLength + sArmorLength; // 4 for a6 spaces


	int stringsize = 17 + length;
	unsigned char *buffer = malloc(stringsize);
	if (buffer == NULL)
		error_exit("Memory error ( SendKillMessage() )\n");

	int position = 0;

	buffer[position] = 19;
	position++;
	buffer[position] = victim;
	position++;
	buffer[position] = id;
	position++;
	buffer[position] = player[id].slot[player[id].actualweapon].id;
	position++;
	memcpy(buffer + position, &player[victim].x, 2);
	position += 2;
	memcpy(buffer + position, &player[victim].y, 2);
	position += 2;
	unsigned short unknown1 = 240;
	memcpy(buffer + position, &unknown1, 2);
	position += 2;
	buffer[position] = 1;
	position++;

	memcpy(buffer + position, &length, 2);
	position += 2;

	buffer[position] = 'k';
	position++;
	buffer[position] = 166; //166 acts like string seperator
	position++;
	memcpy(buffer + position, player[id].name, sNameLength);
	position += sNameLength;
	buffer[position] = 166;
	position++;
	memcpy(buffer + position, &sHealth, sHealthLength);
	position += sHealthLength;
	buffer[position] = 166;
	position++;
	memcpy(buffer + position, &sArmor, sArmorLength);
	position += sArmorLength;

	SendToPlayer(buffer, stringsize, victim, 1, writesocket);
	free(buffer);

	stringsize = 8;
	buffer = malloc(stringsize);
	if (buffer == NULL)
		error_exit("Memory error ( SendKillMessage() )\n");

	position = 0;

	buffer[position] = 19;
	position++;
	buffer[position] = victim;
	position++;
	buffer[position] = id;
	position++;
	buffer[position] = player[id].slot[player[id].actualweapon].id;
	position++;
	memcpy(buffer + position, &player[victim].x, 2);
	position += 2;
	memcpy(buffer + position, &player[victim].y, 2);
	position += 2;

	SendToAllOther(victim, buffer, stringsize, 1, writesocket);
	free(buffer);
}
Ejemplo n.º 12
0
void PhasingHandler::SendToPlayer(Player const* player)
{
    SendToPlayer(player, player->GetPhaseShift());
}