/*----------------------------------------------------------------------------- Name : allianceFormWith Description : sends a request to form an alliance with a player. Inputs : Outputs : Return : void ----------------------------------------------------------------------------*/ void allianceFormWith(udword playerindex) { char temp[256]; // Just request to ally with the person you requested. sprintf(temp, "%s %s", strGetString(strAllianceRequest), playerNames[playerindex]); // alliancePrintNamesNice(temp, (uword)PLAYER_MASK(playerindex)); gcProcessGameTextMessage(temp,allianceMessageColor); sendAllianceRequest(PLAYER_MASK(playerindex),(uword)sigsPlayerIndex,ALLIANCE_PACKET, 0); bitSet(universe.players[sigsPlayerIndex].AllianceProposals, PLAYER_MASK(playerindex)); universe.players[sigsPlayerIndex].AllianceProposalsTimeout = universe.univUpdateCounter + UNIVERSE_UPDATE_RATE * 90; /* // are we in an alliance now ?? if ((universe.players[sigsPlayerIndex].Allies&ALL_PLAYER_MASK)==0) { // no we are not in an alliance // straigtforward request to ally sprintf(temp, "%s ", strGetString(strAllianceRequest)); alliancePrintNamesNice(temp, (uword)PLAYER_MASK(playerindex)); gcProcessGameTextMessage(temp,allianceMessageColor); sendAllianceRequest(PLAYER_MASK(playerindex),(uword)sigsPlayerIndex,ALLIANCE_PACKET, 0); universe.players[sigsPlayerIndex].AllianceProposals=PLAYER_MASK(playerindex); } // do i accept the proposed new ally in our alliance else if (playerindex == universe.players[sigsPlayerIndex].AllianceRequestToConfirm) { // yes i accept him into our allience // send a message to the request initiator telling him of my acceptance. sprintf(temp, "%s ", strGetString(strAllianceConfirm)); alliancePrintNamesNice(temp, (uword)PLAYER_MASK(playerindex)); gcProcessGameTextMessage(temp,allianceMessageColor); sendAllianceRequest(PLAYER_MASK(universe.players[sigsPlayerIndex].AllianceRequestInitiator),(uword)sigsPlayerIndex,ALLIANCE_GRANTED, 0); universe.players[sigsPlayerIndex].AllianceRequestToConfirm = -1; } else { // otherwise i want a new person to join our allience // must ask all of my allies if he can join or not. sprintf(temp, "%s ", strGetString(strAskForPermision)); alliancePrintNamesNice(temp, (uword)PLAYER_MASK(playerindex)); gcProcessGameTextMessage(temp,allianceMessageColor); sendAllianceRequest(universe.players[sigsPlayerIndex].Allies, (uword)sigsPlayerIndex, ALLIANCE_NEWJOIN, (ubyte)playerindex); // save all of the people that must confirm this alliance request. universe.players[sigsPlayerIndex].AllianceConfirms = universe.players[sigsPlayerIndex].Allies; universe.players[sigsPlayerIndex].AllianceRequestToConfirm = (ubyte)playerindex; }*/ }
void WorldInputCmdProcessor::evalLeftMButtonEvents( MouseEvent &event ) { iXY world_pos; unsigned char click_status; if ( (manual_control_state == true) || KeyboardInterface::getKeyState( SDLK_LCTRL ) || KeyboardInterface::getKeyState( SDLK_RCTRL ) ) { if (event.event == MouseEvent::EVENT_DOWN ) //if (event.event == _event_mbutton_click ) { WorldViewInterface::clientXYtoWorldXY( world_win, event.down_pos, &world_pos ); sendManualFireCommand( world_pos ); } } else { if ( event.event == MouseEvent::EVENT_DOWN ) { WorldViewInterface::clientXYtoWorldXY( world_win, event.down_pos, &world_pos ); Objective *objective; PlayerID player_id; player_id = PlayerInterface::getLocalPlayerID(); click_status = ObjectiveInterface::quearyObjectiveLocationStatus( world_pos, player_id, &objective ); if ( (click_status == _player_occupied_objective_found) ) { box_press = world_pos; box_release = world_pos; if ( outpost_goal_selection == -1){ outpost_goal_selection = objective->objective_state.ID; output_pos_press = objective->objective_state.location; } }else{ if ( selection_box_active == false) { WorldViewInterface::clientXYtoWorldXY( world_win, event.down_pos, &world_pos ); box_press = world_pos; box_release = world_pos; }else{ } } } // ** _event_mbutton_down if ( event.event == MouseEvent::EVENT_UP ) { if (outpost_goal_selection != -1 ){ iXY temp; MouseInterface::getMousePosition( &temp.x, &temp.y ); WorldViewInterface::clientXYtoWorldXY( world_win, temp, &world_pos ); Objective *objective; PlayerID player_id = PlayerInterface::getLocalPlayerID(); int cs = ObjectiveInterface::quearyObjectiveLocationStatus( world_pos, player_id, &objective ); if ( (cs == _player_occupied_objective_found) && outpost_goal_selection == objective->objective_state.ID ) { // we've let go of the mouse on the building so we're // not changing the spawn point selected_objective_id = CURRENT_SELECTED_OUTPOST_ID = objective->objective_state.ID; activateVehicleSelectionView( selected_objective_id ); } else { TerminalOutpostOutputLocRequest term_mesg; term_mesg.output_loc_request.set( outpost_goal_selection, world_pos); CLIENT->sendMessage( &term_mesg, sizeof(TerminalOutpostOutputLocRequest), 0 ); if ( NetworkState::status == _network_state_client ) { ObjectiveInterface::sendMessage( &(term_mesg.output_loc_request) ); } } outpost_goal_selection = -1; } } if ( (event.event == MouseEvent::EVENT_CLICK) && (left_button_hold_action_complete == false) ) { WorldViewInterface::clientXYtoWorldXY( world_win, event.down_pos, &world_pos ); click_status = getCursorStatus( world_pos ); switch ( click_status ) { case _cursor_player_unit : { if( (KeyboardInterface::getKeyState( SDLK_LSHIFT ) == true) || (KeyboardInterface::getKeyState( SDLK_RSHIFT ) == true) ) { working_list.addUnit( world_pos ); } else { working_list.selectUnit( world_pos ); } current_selection_list_bits=0; current_selection_list_index = 0xFFFF; if (working_list.unit_list.size() > 0) { UnitBase *unit = UnitInterface::getUnit(working_list.unit_list[0]); unit->soundSelected(); } } break; case _cursor_move: case _cursor_blocked: { if(outpost_goal_selection == -1){ sendMoveCommand( world_pos ); } } break; case _cursor_enemy_unit : { sendAttackCommand( world_pos ); } break; case _cursor_make_allie : { sendAllianceRequest( world_pos, true ); } break; case _cursor_break_allie : { sendAllianceRequest( world_pos, false ); } break; } // ** switch } // ** if _event_mbutton_click } // ** else manual_control_state == false; } // ** evalLeftMButtonEvents
void WorldInputCmdProcessor::evalLeftMButtonEvents(const MouseEvent &event) { iXY world_pos; unsigned char click_status; WorldViewInterface::clientXYtoWorldXY(world_win, event.pos, &world_pos); if ( (manual_control_state == true) || KeyboardInterface::getKeyState( SDLK_LCTRL ) || KeyboardInterface::getKeyState( SDLK_RCTRL ) ) { if (event.event == MouseEvent::EVENT_DOWN ) { sendManualFireCommand( world_pos ); } } else if (event.event == MouseEvent::EVENT_DOWN) { Objective *objective = 0; click_status = ObjectiveInterface::quearyObjectiveLocationStatus( world_pos, PlayerInterface::getLocalPlayerIndex(), &objective); if ( click_status == _player_occupied_objective_found ) { selection_box_active = false; outpost_goal_selection = objective->objective_state.ID; output_pos_press = objective->objective_state.location; } else { box_press = world_pos; box_release = world_pos; selection_box_active = true; } } else if(event.event == MouseEvent::EVENT_UP) { if (selection_box_active) { selection_box_active = false; box_release = world_pos; if(abs(box_release.x - box_press.x) > 3 && abs(box_release.y - box_press.y) > 3) { return; } } if (outpost_goal_selection != OBJECTIVE_NONE ) { Objective *objective = 0; int cs = ObjectiveInterface::quearyObjectiveLocationStatus( world_pos, PlayerInterface::getLocalPlayerIndex(), &objective); if ( (cs == _player_occupied_objective_found) && outpost_goal_selection == objective->objective_state.ID ) { // we've let go of the mouse on the building so we're // not changing the spawn point selected_objective_id = objective->objective_state.ID; activateVehicleSelectionView( selected_objective_id ); } else { TerminalOutpostOutputLocRequest term_mesg; term_mesg.output_loc_request.set( outpost_goal_selection, world_pos); CLIENT->sendMessage(&term_mesg, sizeof(TerminalOutpostOutputLocRequest)); if ( NetworkState::status == _network_state_client ) { ObjectiveInterface::sendMessage( &(term_mesg.output_loc_request) ); } } outpost_goal_selection = OBJECTIVE_NONE; return; } click_status = getCursorStatus(world_pos); switch(click_status) { case _cursor_player_unit: { static NTimer dclick_timer(200); static int click_times = 0; bool addunits = false; if( (KeyboardInterface::getKeyState(SDLK_LSHIFT) == true) || (KeyboardInterface::getKeyState(SDLK_RSHIFT) == true)) { addunits = true; } if ( ! dclick_timer.isTimeOut() ) { if ( click_times ) { iRect wr; WorldViewInterface::getViewWindow(&wr); working_list.selectBounded(wr, addunits); click_times=0; } else { working_list.selectSameTypeVisible(world_pos,addunits); dclick_timer.reset(); click_times++; } break; } else if (addunits) { working_list.addUnit(world_pos); } else { working_list.selectUnit(world_pos ); } current_selection_list_bits=0; current_selection_list_index = 0xFFFF; if (working_list.unit_list.size() > 0) { UnitBase *unit = UnitInterface::getUnit( working_list.unit_list[0]); if(unit) unit->soundSelected(); } dclick_timer.reset(); click_times=0; break; } case _cursor_move: case _cursor_blocked: if(outpost_goal_selection == OBJECTIVE_NONE) sendMoveCommand(world_pos); break; case _cursor_enemy_unit: sendAttackCommand(world_pos); break; case _cursor_make_allie: sendAllianceRequest(world_pos, true); break; case _cursor_break_allie: sendAllianceRequest(world_pos, false); break; } } }