Esempio n. 1
0
int main(int argc, char** argv){
	
	msgid = msgget(997,IPC_CREAT | 0666);
	if(msgid == -1) perror("Tworzenie kolejki komunikatow");
	
	patientCount = getPatientCount();
	loadPatient(); 
	loadDoctors();
	doctorCount = getDoctorCount();
	printDoctors();
	printPatients();
			printf("begin\n");

	while(1){
		if(msgrcv(msgid,&addPatientMessage,sizeof(addPatientMessage),1,IPC_NOWAIT) != -1){
			addPatientX();
		}
		else if(msgrcv(msgid,&loginMessage,sizeof(loginMessage),2,IPC_NOWAIT) != -1){
			loginUser();
		}
		else if(msgrcv(msgid,&informationMessage,sizeof(informationMessage),3,IPC_NOWAIT) != -1){
			sendDoctorsInDate();
		}
	
		else if(msgrcv(msgid,&informationMessage,sizeof(informationMessage),6,IPC_NOWAIT) != -1){
			sendVisitInfo();
		}
		else if(msgrcv(msgid,&informationMessage,sizeof(informationMessage),5,IPC_NOWAIT) != -1){
			cancelVisit();
		}
		else if(msgrcv(msgid,&informationMessage,sizeof(informationMessage),4,IPC_NOWAIT) != -1){
			addVisit();
		}
		else if(msgrcv(msgid,&informationMessage,sizeof(informationMessage),7,IPC_NOWAIT) != -1){
			showVisitDay();
		}
		
		else if(msgrcv(msgid,&doctorMessage,sizeof(doctorMessage),10,IPC_NOWAIT) != -1){
			giveVacation();
		}



		//printPatients();
		sleep(1);
	}
	return 0;
}
Esempio n. 2
0
void SoundEvent::visitRoom(Room *room, double strength) {

    strength *= room->eventMultiplier(GameEventType::Sound);

    if (strength >= 0.1) {
        for (const GameObjectPtr &characterPtr : room->characters()) {
            if (excludedCharacters().contains(characterPtr)) {
                continue;
            }

            Character *character = characterPtr.cast<Character *>();
            QString message = descriptionForStrengthAndCharacterInRoom(strength, character, room);
            if (character->isPlayer()) {
                character->send(message);
            } else {
                character->invokeTrigger("onsound", message);
            }

            addAffectedCharacter(characterPtr);
        }

        for (const GameObjectPtr &portalPtr : room->portals()) {
            Portal *portal = portalPtr.cast<Portal *>();
            Room *room1 = portal->room().unsafeCast<Room *>();
            Room *room2 = portal->room2().unsafeCast<Room *>();
            Room *oppositeRoom = (room == room1 ? room2 : room1);
            if (hasBeenVisited(oppositeRoom) || !portal->canHearThrough()) {
                continue;
            }

            double propagatedStrength = strength * portal->eventMultiplier(GameEventType::Sound);
            if (propagatedStrength >= 0.1) {
                addVisit(oppositeRoom, propagatedStrength);
            }
        }
    }
}