Example #1
0
int main (int argc, char **argv)
{
	srand(time(0));

	MAP map;
	setDefaults(&map);

	PLAYER hero;
	startPlayer(&hero);

	getargs(&map, &hero, argc, argv);

	startMap(&map);
	hero.face = map.elements.hero.face;
	hero.pos = putElement(&map, hero.face);

	GHOSTS ghosts;
	ghosts.face = GHOST;
	ghosts.count = 0;

	startGhosts(&map, &ghosts);

	fflush(stdout);
	initscr();
	nodelay(stdscr, TRUE);
	noecho();
	keypad(stdscr, TRUE);

	if (map.props.hascolor)
		startColors();

	struct timespec tim, tim2;
	tim.tv_sec = 0;
	tim.tv_nsec = map.props.speed;

	do {
		nanosleep(&tim, &tim2);
		getCommand(&hero);
		walk(&map, &hero, &ghosts);
		showMap(&map, &hero, &ghosts);
		repopMap(&map);
		upGhosts(&map, &ghosts);
		walkGhosts(&map, &ghosts);

	} while (!isDead(&hero));

	if (!noRecords)
		writeRecords(&hero, &ghosts);
	finalize(&map, &ghosts);
	finalText(&map, &hero, &ghosts);

	exit(0);

}
Example #2
0
void Server::sendPrivateMessage(QString msg, QString prefix){
    QStringRef tempText(&msg, prefix.length(), msg.length() - prefix.length());
    QString tempLength = tempText.at(0);
    int nameLength = tempLength.toInt();
    QString tempString = tempText.toString();
    QStringRef name(&tempString, 1, nameLength);
    QString finalTempString = tempText.toString();
    QStringRef finalText(&finalTempString, nameLength + 1, msg.length() - prefix.length() - nameLength - 1);

    for (int i = 0; i < nickContainer->size(); ++i){
        if (nickContainer->at(i) == name){
            clientContainer->at(i)->write(finalText.toLatin1());
        }
    }
}