void melee_tick(scene *scene, int paused) { melee_local *local = scene_get_userdata(scene); game_player *player1 = game_state_get_player(scene->gs, 0); game_player *player2 = game_state_get_player(scene->gs, 1); ctrl_event *i = NULL; // Handle extra controller inputs i = player1->ctrl->extra_events; if (i) { do { if(i->type == EVENT_TYPE_ACTION) { handle_action(scene, 1, i->event_data.action); } else if (i->type == EVENT_TYPE_CLOSE) { game_state_set_next(scene->gs, SCENE_MENU); return; } } while((i = i->next)); } i = player2->ctrl->extra_events; if (i) { do { if(i->type == EVENT_TYPE_ACTION) { handle_action(scene, 2, i->event_data.action); } else if (i->type == EVENT_TYPE_CLOSE) { game_state_set_next(scene->gs, SCENE_MENU); return; } } while((i = i->next)); } if(!local->pulsedir) { local->ticks++; } else { local->ticks--; } if(local->ticks > 120) { local->pulsedir = 1; } if(local->ticks == 0) { local->pulsedir = 0; } local->hartick++; if (local->selection == 1) { if(local->hartick > 10) { local->hartick = 0; object_dynamic_tick(&local->har_player1[5*local->row_a + local->column_a]); if (player2->selectable) { object_dynamic_tick(&local->har_player2[5*local->row_b + local->column_b]); } } } }
void melee_tick(scene *scene) { if(!pulsedir) { ticks++; } else { ticks--; } if(ticks > 120) { pulsedir = 1; } if(ticks == 0) { pulsedir = 0; } hartick++; if (selection == 1) { if(hartick > 10) { hartick = 0; animationplayer_run(&harplayer_a); if (scene->player2.selectable) { animationplayer_run(&harplayer_b); } } } ctrl_event *p1 = NULL, *p2 = NULL, *i; if(controller_tick(scene->player1.ctrl, &p1) || controller_tick(scene->player2.ctrl, &p2)) { // one of the controllers bailed /*if(scene->player1.ctrl->type == CTRL_TYPE_NETWORK) {*/ /*net_controller_free(scene->player1.ctrl);*/ /*}*/ /*if(scene->player2.ctrl->type == CTRL_TYPE_NETWORK) {*/ /*net_controller_free(scene->player2.ctrl);*/ /*}*/ scene->next_id = SCENE_MENU; } i = p1; if (i) { do { handle_action(scene, 1, i->action); } while((i = i->next)); DEBUG("done"); } i = p2; if (i) { do { handle_action(scene, 2, i->action); } while((i = i->next)); DEBUG("done"); } }
void melee_input_tick(scene *scene) { melee_local *local = scene_get_userdata(scene); game_player *player1 = game_state_get_player(scene->gs, 0); game_player *player2 = game_state_get_player(scene->gs, 1); ctrl_event *p1=NULL, *p2 = NULL, *i; controller_poll(player1->ctrl, &p1); controller_poll(player2->ctrl, &p2); i = p1; if (i) { do { if(i->type == EVENT_TYPE_ACTION) { if (i->event_data.action == ACT_ESC) { sound_play(20, 0.5f, 0.0f, 2.0f); if (local->selection == 1) { // restore the player selection local->column_a = local->pilot_id_a % 5; local->row_a = local->pilot_id_a / 5; local->column_b = local->pilot_id_b % 5; local->row_b = local->pilot_id_b / 5; local->selection = 0; local->done_a = 0; local->done_b = 0; } else { game_state_set_next(scene->gs, SCENE_MENU); } } else { handle_action(scene, 1, i->event_data.action); } } else if (i->type == EVENT_TYPE_CLOSE) { game_state_set_next(scene->gs, SCENE_MENU); } } while((i = i->next)); } controller_free_chain(p1); i = p2; if (i) { do { if(i->type == EVENT_TYPE_ACTION) { handle_action(scene, 2, i->event_data.action); } else if (i->type == EVENT_TYPE_CLOSE) { game_state_set_next(scene->gs, SCENE_MENU); } } while((i = i->next)); } controller_free_chain(p2); }
static int mgmt_body_print(u_int16_t fc, const struct mgmt_header_t *pmh, const u_char *p, u_int length) { switch (FC_SUBTYPE(fc)) { case ST_ASSOC_REQUEST: printf("Assoc Request"); return handle_assoc_request(p, length); case ST_ASSOC_RESPONSE: printf("Assoc Response"); return handle_assoc_response(p, length); case ST_REASSOC_REQUEST: printf("ReAssoc Request"); return handle_reassoc_request(p, length); case ST_REASSOC_RESPONSE: printf("ReAssoc Response"); return handle_reassoc_response(p, length); case ST_PROBE_REQUEST: printf("Probe Request"); return handle_probe_request(p, length); case ST_PROBE_RESPONSE: printf("Probe Response"); return handle_probe_response(p, length); case ST_BEACON: printf("Beacon"); return handle_beacon(p, length); case ST_ATIM: printf("ATIM"); return handle_atim(); case ST_DISASSOC: printf("Disassociation"); return handle_disassoc(p, length); case ST_AUTH: printf("Authentication"); if (!TTEST2(*p, 3)) return 0; if ((p[0] == 0 ) && (p[1] == 0) && (p[2] == 0)) { printf("Authentication (Shared-Key)-3 "); return wep_print(p); } return handle_auth(p, length); case ST_DEAUTH: printf("DeAuthentication"); return handle_deauth(pmh, p, length); break; case ST_ACTION: printf("Action"); return handle_action(pmh, p, length); break; default: printf("Unhandled Management subtype(%x)", FC_SUBTYPE(fc)); return 1; } }
static void handle_external_mod_update (struct kyu_module *newdef, struct kyu_module *mydef) { sexpr c, a, module, rv = sx_nil, flags = newdef->schedulerflags; c = sx_set_difference (mydef->schedulerflags, newdef->schedulerflags); if (eolp (c)) { return; } while (consp (c) && nilp (rv)) { a = car (c); if (truep (equalp (a, sym_enabling))) { if (falsep (sx_set_memberp (mydef->schedulerflags, sym_enabling))) { rv = handle_enable_request (mydef); if (falsep (rv)) { flags = sx_set_add (mydef->schedulerflags, sym_blocked); } } } else if (truep (equalp (a, sym_disabling))) { if (falsep (sx_set_memberp (mydef->schedulerflags, sym_disabling))) { rv = handle_disable_request (mydef); } } else if (consp (a) && falsep (sx_set_memberp (mydef->schedulerflags, a))) { rv = handle_action (mydef, cdr (a)); } c = cdr (c); } module = kyu_make_module (mydef->name, mydef->description, mydef->provides, mydef->requires, mydef->before, mydef->after, mydef->conflicts, flags, mydef->functions); my_modules = lx_environment_unbind (my_modules, mydef->name); my_modules = lx_environment_bind (my_modules, mydef->name, module); kyu_command (cons (sym_update, cons (native_system, cons (module, sx_end_of_list)))); }
int melee_event(scene *scene, SDL_Event *event) { if(event->type == SDL_KEYDOWN) { if (event->key.keysym.sym == SDLK_ESCAPE) { if (selection == 1) { // restore the player selection column_a = player_id_a % 5; row_a = player_id_a / 5; column_b = player_id_b % 5; row_b = player_id_b / 5; selection = 0; done_a = 0; done_b = 0; } else { scene->next_id = SCENE_MENU; } } else { ctrl_event *p1=NULL, *p2 = NULL, *i; controller_event(scene->player1.ctrl, event, &p1); controller_event(scene->player2.ctrl, event, &p2); i = p1; if (i) { do { handle_action(scene, 1, i->action); } while((i = i->next)); DEBUG("done"); } i = p2; if (i) { do { handle_action(scene, 2, i->action); } while((i = i->next)); DEBUG("done"); } } } return 0; }
int _engine_process_command(engine *p, net_client *p_cli, network_command cmd) { int(* handle_action) ENGINE_HANDLE_FUNC_HEADER; str_scanner scanner; game_room *p_gr; int ret_val; if (cmd.type < 0 || cmd.type > NETWORK_COMMAND_TYPES_COUNT) { network_command_prepare(&p_cli->connection->_out_buffer, NCT_LEAD_DISCONNECT); snprintf(p_cli->connection->_out_buffer.data, NETWORK_COMMAND_DATA_LENGTH, g_loc.server_protection_illegal_cmd_type, cmd.type); engine_send_command(p, p_cli, &p_cli->connection->_out_buffer); return ENGINE_CLOSE_REASON_ACTION_NOT_IMPLEMENTED; } handle_action = p->command_proccess_func[cmd.type]; if (handle_action == NULL) { network_command_prepare(&p_cli->connection->_out_buffer, NCT_LEAD_DISCONNECT); snprintf(p_cli->connection->_out_buffer.data, NETWORK_COMMAND_DATA_LENGTH, g_loc.server_protection_unimplemented_cmd_type, cmd.type); engine_send_command(p, p_cli, &p_cli->connection->_out_buffer); return ENGINE_CLOSE_REASON_ACTION_NOT_IMPLEMENTED; } str_scanner_set(&scanner, cmd.data, cmd.length); p_gr = engine_game_room_by_id(p, p_cli->room_id); ret_val = handle_action(p, p_cli, &scanner, p_gr); if (ret_val) { glog(LOG_FINE, "Processed command of type 0x%2X from client %d which " "resulted in %s", cmd.type, p_cli - p->resources->clients , _engine_cmd_exe_retval_label(ret_val)); netadapter_handle_invallid_command(p->p_netadapter, p_cli, cmd); p->p_netadapter->stats->commands_received_invalid++; if (p_cli->connection->invalid_counter > p->p_netadapter->ALLOWED_INVALLID_MSG_COUNT) { return ENGINE_CLOSE_REASON_TOO_MANY_INVALIDES; } } return 0; }
// TODO: Pass the event object around instead of keeping a global one void Mouse_Pressed() { if(had_text_freeze > 0) { had_text_freeze--; return; } if(overall_mode != MODE_STARTUP) { location mousePos(event.mouseButton.x, event.mouseButton.y); volatile bool doneScrolling = false; if(mousePos.in(text_sbar->getBounds())) { mainPtr.setActive(false); boost::thread updater(std::bind(handleUpdateWhileScrolling, std::ref(doneScrolling), REFRESH_TRANS)); text_sbar->handleClick(mousePos); doneScrolling = true; updater.join(); redraw_screen(REFRESH_TRANS); } else if(mousePos.in(item_sbar->getBounds())) { mainPtr.setActive(false); boost::thread updater(std::bind(handleUpdateWhileScrolling, std::ref(doneScrolling), REFRESH_INVEN)); item_sbar->handleClick(mousePos); doneScrolling = true; updater.join(); redraw_screen(REFRESH_INVEN); } else if(overall_mode == MODE_SHOPPING && mousePos.in(shop_sbar->getBounds())) { mainPtr.setActive(false); boost::thread updater(std::bind(handleUpdateWhileScrolling, std::ref(doneScrolling), REFRESH_DLOG)); shop_sbar->handleClick(mousePos); doneScrolling = true; updater.join(); redraw_screen(REFRESH_DLOG); } else All_Done = handle_action(event); } else All_Done = handle_startup_press({event.mouseButton.x, event.mouseButton.y}); menu_activate(); }
Boolean handle_menu (short item, HMENU) { short choice,i; POINT x = {1001,0},pass_point; Boolean to_return = false; switch (item) { case 1: // File Menu if (in_startup_mode == true) startup_load(); else do_load(); break; case 2: do_save(0); break; case 3: if (in_startup_mode == true) save_file(1); else do_save(1); break; case 4: if (in_startup_mode == false) { choice = FCD(1091,0); if (choice == 1) return false; for (i = 0; i < 6; i++) adven[i].main_status = MAIN_STATUS_ABSENT; party_in_memory = false; reload_startup(); in_startup_mode = true; draw_startup(0); } start_new_game(); draw_startup(0); break; case 6: pick_preferences(); break; case 7: pick_compatibility(); break; case 8: // Quit if (in_startup_mode == true) { to_return = All_Done = true; break; } if (overall_mode > MODE_TOWN) { choice = FCD(1067,0); if (choice == 1) return All_Done; } else { choice = FCD(1066,0); if (choice == 3) break; if (choice == 1) save_file(0); } to_return = All_Done = true; break; // Options menu case 21: choice = char_select_pc(0,0,"New graphic for who?"); if (choice < 6) pick_pc_graphic(choice,1,0); initiate_redraw(); break; case 22: choice = select_pc(0,0); if (choice < 6) pick_pc_name(choice,0); put_pc_screen(); put_item_screen(stat_window,0); break; case 23: if (!(is_town())) { add_string_to_buf("Add PC: Town mode only."); print_buf(); break; } for (i = 0; i < NUM_OF_PCS; i++) if (adven[i].main_status == MAIN_STATUS_ABSENT) i = 20; if (i == INVALID_PC) { ASB("Add PC: You already have 6 PCs."); print_buf(); } if (c_town.town_num == scenario.which_town_start) { give_help(56,0,0); create_pc(6,0); } else { add_string_to_buf("Add PC: You can only make new"); add_string_to_buf(" characters in the town you "); add_string_to_buf(" started in."); } print_buf(); put_pc_screen(); put_item_screen(stat_window,0); break; case 24: if (prime_time() == false) { ASB("Finish what you're doing first."); print_buf(); } else { choice = char_select_pc(0,0,"Delete who?"); if (choice < 6) { if ((i = FCD(1053,0)) == 2) adven[choice].kill(0); } initiate_redraw(); } break; case 27: if (overall_mode == MODE_TALKING) { ASB("Talking notes: Can't read while talking."); print_buf(); return to_return; } talk_notes(); break; case 28: adventure_notes(); break; case 29: if (in_startup_mode == false) print_party_stats(); break; // Help menu case 41: FCD(1079,0); break; case 42: FCD(1080,0); break; case 43: FCD(1081,0); break; case 44: FCD(1072,0); break; // magic barriers case 46: FCD(1084,0); break; case 47: FCD(1088,0); break; // Library case 61: display_spells(0,100,0); break; case 62: display_spells(1,100,0); break; case 63: display_skills(100,0); break; case 64: display_help(0,0); break; case 65: tip_of_day(); break; case 67: FCD(986,0); break; // Actions case 81: if (overall_mode != MODE_TOWN) { ASB("Alchemy: In town mode only."); print_buf(); break; } pass_point.x = 1000; pass_point.y = 405; to_return = handle_action(pass_point,(WPARAM) 0,(LPARAM)-1); break; case 82: to_return = handle_action(x,(WPARAM) 0,(LPARAM)-1); break; case 84: if (prime_time() == false) { ASB("Finish what you're doing first."); print_buf(); } else { give_help(62,0,0); display_map(); } SetCursor(sword_curs); break; // Mage is 399 case 399: give_help(209,0,0); party.help_received[9] = false; break; // Priest is 499 case 499: give_help(209,0,0); party.help_received[9] = false; break; // Monsters is 599 case 599: give_help(212,0,0); break; case 100: // Index WinHelp(mainPtr,"Blades of Exile.hlp",HELP_CONTENTS,0L); break; case 200: // About FCD(1062,0); break; default: if ((item >= 400) && (item < 500)) { // mage spell if (prime_time() == false) { ASB("Finish what you're doing first."); print_buf(); } else handle_menu_spell(item - 400,0); break; } if ((item >= 500) && (item < 600)) { // priest spell if (prime_time() == false) { ASB("Finish what you're doing first."); print_buf(); } else handle_menu_spell(item - 500,1); break; } if ((item >= 600) && (item < 700)) { // monster spell display_monst(item - 600,(creature_data_type *) NULL,1); break; } break; } if (in_startup_mode == true) menu_activate(0); else menu_activate(1); return to_return; }
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps; POINT press; HMENU menu; RECT dlg_rect; RECT wind_rect; short handled = 0; short store_ulx; short store_uly; short sbar_pos; short which_sbar; short old_setting; short smin; short smax; // First, handle window size GetWindowRect(mainPtr,&wind_rect); switch (display_mode) { //case 0 is center case 1: store_ulx = 0; store_uly = 0; break; case 2: store_ulx = wind_rect.right - 550 - 21; store_uly = 0; break; case 3: store_ulx = 0; store_uly = wind_rect.bottom - 422 - 24 - 21; break; case 4: store_ulx = wind_rect.right - 550 - 21; store_uly = wind_rect.bottom - 422 - 24 - 21; break; case 5: store_ulx = 0; store_uly = 0; break; default: store_ulx = ((wind_rect.right - wind_rect.left) - 536) / 2 - 30; store_uly = ((wind_rect.bottom - wind_rect.top) - 478) / 2 + 8; break; } store_ulx -= store_ulx % 8; store_uly -= store_uly % 8; if ((store_ulx != ulx) || (store_uly != uly)) { ulx = store_ulx; uly = store_uly; adjust_window_mode(); } switch (message) { case WM_KEYDOWN: if (hwnd != mainPtr) check_cd_event(hwnd,message,wParam,lParam); else { cursor_go(); All_Done = handle_syskeystroke(wParam,lParam,&handled); check_game_done(); } if (handled == 1) FlushEvents(0); return 0; case WM_CHAR: if (hwnd != mainPtr) check_cd_event(hwnd,message,wParam,lParam); else { cursor_go(); All_Done = handle_keystroke(wParam,lParam); check_game_done(); } return 0; case WM_LBUTTONDOWN: cursor_stay(); if (hwnd != mainPtr) check_cd_event(hwnd,message,wParam,lParam); else { SetFocus(hwnd); press = MAKEPOINT(lParam); if (in_startup_mode == false) All_Done = handle_action(press, wParam,lParam); else All_Done = handle_startup_press(press); change_cursor(press); check_game_done(); } return 0; break; case WM_RBUTTONDOWN: cursor_stay(); if (hwnd != mainPtr) check_cd_event(hwnd,message,wParam,lParam); else { SetFocus(hwnd); press = MAKEPOINT(lParam); if (in_startup_mode == false) All_Done = handle_action(press, wParam,-2); else All_Done = handle_startup_press(press); change_cursor(press); check_game_done(); } return 0; break; case WM_ACTIVATE: if (hwnd == mainPtr) { WORD fActive = LOWORD(wParam); if ((fActive == WA_ACTIVE) ||(fActive == WA_CLICKACTIVE)) { window_in_front = true; GetClientRect(hwnd,&dlg_rect); InvalidateRect(hwnd,&dlg_rect,false); } if (fActive == WA_INACTIVE) { cursor_stay(); anim_onscreen = false; window_in_front = false; } } return 0; case WM_ERASEBKGND: if (hwnd != mainPtr) break; block_erase = false; return 1; case WM_MOUSEMOVE: if (store_mouse != lParam) cursor_stay(); store_mouse = lParam; press = MAKEPOINT(lParam); if (hwnd == mainPtr) { change_cursor(press); if ((overall_mode > MODE_COMBAT) && (overall_mode < MODE_TALKING)) draw_targeting_line(press); } return 0; case WM_PAINT: if ((block_erase == true) && (hwnd == mainPtr)) { block_erase = false; } BeginPaint(hwnd,&ps); EndPaint(hwnd,&ps); if (hwnd != mainPtr) check_cd_event(hwnd,message,wParam,lParam); else { string_added = true; reset_text_bar(); if (in_startup_mode == true) draw_startup(0); else if (first_update == true) { first_update = false; if (overall_mode == MODE_OUTDOORS) redraw_screen(0); if ((overall_mode > MODE_OUTDOORS) & (overall_mode < MODE_COMBAT)) redraw_screen(1); // 1st update never combat } else refresh_screen(overall_mode); } return 0; case WM_TIMER: switch(wParam) { case 1: if ((in_startup_mode == false) && (anim_onscreen == true) && (window_in_front == true) && (give_delays == false)) { if(PSD[SDF_NO_TER_ANIM] != 1) anim_ticks++; initiate_redraw(); } break; case 2: if ((overall_mode > MODE_COMBAT) && (overall_mode < MODE_TALKING)) { GetCursorPos(&press); press.x -= wind_rect.left + 3; press.y -= wind_rect.top + 41; draw_targeting_line(press); } if ((in_startup_mode == true) && (window_in_front == true)) draw_startup_anim(); break; } return 0; case WM_COMMAND: // 1006 is dummy event // creation events 2000 spend xp 2001 pick graphic 2002 finish up if (hwnd == mainPtr) { menu = GetMenu(mainPtr); All_Done = handle_menu((short) LOWORD(wParam), menu); check_game_done(); } else check_cd_event(hwnd,message,wParam,lParam); return 0; case WM_VSCROLL: which_sbar = GetWindowLong((HWND) lParam, GWL_ID); switch (which_sbar) {// 1 text 2 items 3 shop case 1: sbar_pos = GetScrollPos(text_sbar,SB_CTL); switch (wParam ) { case SB_PAGEDOWN: sbar_pos += 11; break; case SB_LINEDOWN: sbar_pos++; break; case SB_PAGEUP: sbar_pos -= 11; break; case SB_LINEUP: sbar_pos--; break; case SB_TOP: sbar_pos = 0; break; case SB_BOTTOM: sbar_pos = 57; break; case SB_THUMBPOSITION: case SB_THUMBTRACK: sbar_pos = LOWORD(lParam); break; } if (sbar_pos < 0) sbar_pos = 0; if (sbar_pos > 58) sbar_pos = 58; { // SetScrollPos(text_sbar,SB_CTL,sbar_pos,true); lpsi.nPos = sbar_pos; lpsi.fMask = SIF_POS; SetScrollInfo(text_sbar,SB_CTL,&lpsi,true); } string_added = true; print_buf(); break; case 2: old_setting = sbar_pos = GetScrollPos(item_sbar,SB_CTL); GetScrollRange(item_sbar,SB_CTL,(int *) &smin,(int *) &smax); switch (wParam ) { case SB_PAGEDOWN: sbar_pos += (stat_window == 7) ? 2 : 8; break; case SB_LINEDOWN: sbar_pos++; break; case SB_PAGEUP: sbar_pos -= (stat_window == 7) ? 2 : 8; break; case SB_LINEUP: sbar_pos--; break; case SB_TOP: sbar_pos = 0; break; case SB_BOTTOM: sbar_pos = smax; break; case SB_THUMBPOSITION: case SB_THUMBTRACK: sbar_pos = LOWORD(lParam); break; } if (sbar_pos < 0) sbar_pos = 0; if (sbar_pos > smax) sbar_pos = smax; { // SetScrollPos(item_sbar,SB_CTL,sbar_pos,true); lpsi.nPos = sbar_pos; lpsi.fMask = SIF_POS; SetScrollInfo(item_sbar,SB_CTL,&lpsi,true); } if (sbar_pos != old_setting) put_item_screen(stat_window,1); break; case 3: old_setting = sbar_pos = GetScrollPos(shop_sbar,SB_CTL); GetScrollRange(shop_sbar,SB_CTL,(int *) &smin,(int *) &smax); switch (wParam ) { case SB_PAGEDOWN: sbar_pos += 8; break; case SB_LINEDOWN: sbar_pos++; break; case SB_PAGEUP: sbar_pos -= 8; break; case SB_LINEUP: sbar_pos--; break; case SB_TOP: sbar_pos = 0; break; case SB_BOTTOM: sbar_pos = smax; break; case SB_THUMBPOSITION: case SB_THUMBTRACK: sbar_pos = LOWORD(lParam); break; } if (sbar_pos < 0) sbar_pos = 0; if (sbar_pos > smax) sbar_pos = smax; { // SetScrollPos(shop_sbar,SB_CTL,sbar_pos,true); lpsi.nPos = sbar_pos; lpsi.fMask = SIF_POS; SetScrollInfo(shop_sbar,SB_CTL,&lpsi,true); } if (sbar_pos != old_setting) draw_shop_graphics(0,shop_sbar_rect); break; } SetFocus(mainPtr); return 0; case WM_DESTROY: case WM_CLOSE: if (hwnd == mainPtr) { lose_graphics(); PostQuitMessage(0); } return 0; case WM_QUIT: if (hwnd == mainPtr) lose_graphics(); break; } return DefWindowProc(hwnd,message,wParam,lParam); }
long CALLBACK WndProc (HWND hwnd, UINT message,WPARAM wParam, LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; //RECT s_rect = {0,0,30,30},d_rect = {0,0,30,30},d2 = {0,0,420,216},s2 = {0,0,420,216}; POINT press; short handled = 0,sbar_pos = 0,old_setting; long which_sbar; int min = 0, max = 0; HMENU menu; POINT p; RECT r; switch (message) { case WM_KEYDOWN: if (hwnd != mainPtr) { check_cd_event(hwnd,message,wParam,lParam); } else { All_Done = handle_syskeystroke(wParam,lParam,&handled); } return 0; break; case WM_CHAR: if (hwnd != mainPtr) check_cd_event(hwnd,message,wParam,lParam); else { All_Done = handle_keystroke(wParam,lParam); } return 0; break; case WM_LBUTTONDOWN: cursor_stay(); if (hwnd != mainPtr) check_cd_event(hwnd,message,wParam,lParam); else { SetFocus(hwnd); press = MAKEPOINT(lParam); All_Done = handle_action(press, wParam,lParam); check_game_done(); } return 0; break; case WM_LBUTTONUP: mouse_button_held = FALSE; break; case WM_RBUTTONDOWN: mouse_button_held = FALSE; cursor_stay(); if (hwnd != mainPtr) check_cd_event(hwnd,message,wParam,lParam); else { SetFocus(hwnd); press = MAKEPOINT(lParam); All_Done = handle_action(press, wParam,-2); check_game_done(); } return 0; break; case WM_TIMER: // first, mouse held? if ((wParam == 1) && (mouse_button_held == TRUE)) { GetCursorPos(&p); ScreenToClient(mainPtr,&p); All_Done = handle_action(p, 0,0); } // second, refresh cursor? if ((wParam == 1) && (overall_mode < 60) && (GetFocus() == mainPtr)) { GetCursorPos(&p); ScreenToClient(mainPtr,&p); GetClientRect(mainPtr,&r); if (PtInRect(&r,p)) restore_cursor(); } if(play_anim == TRUE){ anim_ticks++; if(overall_mode < 60){ draw_terrain(); } if(overall_mode == 62){ if(store_ter.picture >= 2000) csp(813,14,store_ter.picture - 2000, 5); else if (store_ter.picture >= 400 && store_ter.picture < 1000) csp(813,14,store_ter.picture - 100, 0); if(do_choose_anim == TRUE){ put_choice_pics(); } } } break; case WM_PALETTECHANGED: palette_suspect = TRUE; return 0; case WM_ACTIVATE: if (hwnd == mainPtr) { if (((wParam == WA_ACTIVE) ||(wParam == WA_CLICKACTIVE)) && (palette_suspect == TRUE)) { palette_suspect = FALSE; } if ((wParam == WA_ACTIVE) ||(wParam == WA_CLICKACTIVE)) { window_in_front = TRUE; } if (wParam == WA_INACTIVE) { window_in_front = FALSE; } } return 0; case WM_MOUSEMOVE: if ((mouse_button_held == TRUE) && (hwnd == mainPtr)) { press = MAKEPOINT(lParam); All_Done = handle_action(press, wParam,lParam); } restore_cursor(); return 0; case WM_PAINT: hdc = BeginPaint(hwnd,&ps); EndPaint(hwnd,&ps); if (hwnd != mainPtr) check_cd_event(hwnd,message,wParam,lParam); else redraw_screen(); return 0; case WM_VSCROLL: which_sbar = GetWindowLong((HWND) lParam, GWL_ID); switch (which_sbar) { case 1: sbar_pos = GetScrollPos(right_sbar,SB_CTL); old_setting = sbar_pos; GetScrollRange(right_sbar,SB_CTL,&min,&max); switch (LOWORD(wParam)) { case SB_PAGEDOWN: sbar_pos += NRSONPAGE - 1; break; case SB_LINEDOWN: sbar_pos++; break; case SB_PAGEUP: sbar_pos -= NRSONPAGE - 1; break; case SB_LINEUP: sbar_pos--; break; case SB_TOP: sbar_pos = 0; break; case SB_BOTTOM: sbar_pos = max; break; case SB_THUMBPOSITION: case SB_THUMBTRACK: sbar_pos = HIWORD(wParam); break; } if (sbar_pos < 0) sbar_pos = 0; if (sbar_pos > max) sbar_pos = max; lpsi.fMask = SIF_POS; lpsi.nPos = sbar_pos; SetScrollInfo(right_sbar,SB_CTL,&lpsi,TRUE); // SetScrollPos(right_sbar,SB_CTL,sbar_pos,TRUE); if (sbar_pos != old_setting) draw_rb(); break; } SetFocus(mainPtr); return 0; case WM_COMMAND: if (hwnd == mainPtr) { menu = GetMenu(mainPtr); handle_menu((short) wParam, menu); check_game_done(); } else { check_cd_event(hwnd,message,wParam,lParam); } return 0; case WM_DESTROY: case WM_CLOSE: if (hwnd == mainPtr) { discard_graphics(); PostQuitMessage(0); } return 0; case WM_QUIT: if (hwnd == mainPtr) discard_graphics(); break; } return DefWindowProc(hwnd,message,wParam,lParam); }
static sexpr handle_disable_request (struct kyu_module *mod) { return handle_action (mod, sym_stop); }
int CChitemDlg::check_dialog(int check_or_scan) { CString *lines; CString tmp; journal_type journal; int fh; int ret, gret; int linecount; int i,j; trigger trigger; action action; int num_or, strref; int first, last; loc_entry tmploc; bool got_continue; bool warn = (chkflg&WARNINGS)==0; gret=0; if(check_or_scan!=SCANNING) { if(check_or_scan==CHECKING) //no JOURNAL { //checking state headers for(i=0;i<the_dialog.statecount;i++) { switch(check_reference(the_dialog.dlgstates[i].actorstr,1,1,0)) { case 1: log("Actor has invalid text in state #%d",i); gret=TREESTATE|i; break; case 2: case 5: log("Actor has no included text in state #%d",i); gret=TREESTATE|i; } if(chkflg&NOSTRUCT) continue; if(the_dialog.dlgstates[i].trnumber<1) { log("No transitions in state #%d",i); gret=TREESTATE|i; continue; } num_or=the_dialog.dlgstates[i].trnumber+the_dialog.dlgstates[i].trindex; if(num_or<1 || num_or>the_dialog.transcount) { log("Invalid last index of transitions (%d) in state #%d",num_or,i); gret=TREESTATE|i; continue; } got_continue = false; first = the_dialog.dlgstates[i].trindex; last = first + the_dialog.dlgstates[i].trnumber; for (j=first;j<last;j++) { num_or=the_dialog.dlgtrans[j].flags; if(!(num_or&HAS_TEXT)) { if ((j!=first) && got_continue && !(num_or&HAS_TRIGGER) ) { log("Unconditional continue in state #%d (response #%d) overlaps a previous continue!", i, j); //gret=TREESTATE|i; gret=TRANSSTATE|j; } got_continue = true; } } } } //checking transition headers for(i=0;i<the_dialog.transcount;i++) { num_or=the_dialog.dlgtrans[i].flags; if(the_dialog.dlgtrans[i].playerstr<=0) { if(num_or&HAS_TEXT) { log("Transition #%d has no player string set, despite flags.",i); gret=TRANSSTATE|i; } } else { if(!(num_or&HAS_TEXT) ) { log("Transition #%d has player string set, but no flags.",i); gret=TRANSSTATE|i; } } //checking transition trigger reference j=the_dialog.dlgtrans[i].trtrindex; if(j<0 || j>=the_dialog.header.numtrtrigger) { if(num_or&HAS_TRIGGER) { log("Transition #%d has a wrong trigger index (%d).",i,j); gret=TRANSSTATE|i; } } else if(j) { if(!(num_or&HAS_TRIGGER) && warn) { log("Transition #%d has trigger index (%d), but no flags.",i,j); gret=TRANSSTATE|i; } } //checking action reference j=the_dialog.dlgtrans[i].actionindex; if(j<0 || j>=the_dialog.header.numaction) { if((num_or&HAS_ACTION) ) { log("Transition #%d has a wrong action index (%d).",i,j); gret=TRANSSTATE|i; } } else if(j) { if(!(num_or&HAS_ACTION) && warn) { log("Transition #%d has action index (%d), but no flags.",i,j); gret=TRANSSTATE|i; } } //checking journal string ref strref=the_dialog.dlgtrans[i].journalstr; if(strref<=0) { if(num_or&HAS_JOURNAL) { log("Transition #%d has no journal string set, despite flags.",i); gret=TRANSSTATE|i; } } else { if(!(num_or&HAS_JOURNAL) ) { log("Transition #%d has journal string set, but no flags.",i); gret=TRANSSTATE|i; } else { if((check_or_scan==JOURNAL)) { if((num_or&(HAS_QUEST|HAS_SOLVED))==HAS_QUEST) { if(journals.Lookup(strref,journal)) { if(!journal.string.IsEmpty()) { if (journal.string.Find(itemname)<0) { journal.string+=", "+itemname; } journal.type|=HAS_QUEST; journals[strref]=journal; } } else { journal.type=HAS_QUEST; journal.string=itemname; journals[strref]=journal; } } else { journal.type=0; journals.Lookup(strref,journal); journal.type|=num_or&(HAS_QUEST|HAS_SOLVED); journal.string=""; journals[strref]=journal; } continue; } } switch(check_reference(strref,2,10,0) ) { case 1: log("Invalid journal string in transition #%d (reference: %d).",i, strref); gret=TRANSSTATE|i; break; case 2: log("Deleted journal string in transition #%d (reference: %d).",i, strref); gret=TRANSSTATE|i; break; case 3: //if this isn't a quest journal entry, don't complain about missing title if ((num_or&(HAS_QUEST|HAS_SOLVED))!=0) { log("Titleless journal string in transition #%d (reference: %d).",i, strref); gret=TRANSSTATE|i; } break; } } //checking dialog linkage RetrieveResref(tmp,the_dialog.dlgtrans[i].nextdlg); num_or=the_dialog.dlgtrans[i].stateindex; if(the_dialog.dlgtrans[i].flags&LEAF_NODE) { if(!tmp.IsEmpty()) { log("External dialog linkage %s:%d for leaf node (state #%d)",tmp,num_or,i); gret=TRANSSTATE|i; } } else { if(tmp==SELF_REFERENCE) { if(the_dialog.header.numstates<=num_or) { log("Invalid internal link to state %d in transition %d",num_or,i); gret=TRANSSTATE|i; } } else { if(dialogs.Lookup(tmp,tmploc) ) { fh=locate_file(tmploc,0); if(the_dialog.CheckExternalLink(fh,num_or) ) { log("Invalid external link to %s:state %d in transition %d",tmp,num_or,i); gret=TRANSSTATE|i; } close(fh); } else { log("Invalid dialog reference: %s in transition %d",tmp,i); gret=TRANSSTATE|i; } } } } } //syntax checking scripts if(check_or_scan!=JOURNAL) { for(i=0;i<the_dialog.sttriggercount;i++) { lines=explode(the_dialog.sttriggers[i], '\n', linecount); if(linecount==-1) { log("Out of memory"); return -1; } num_or=0; for(j=0;j<linecount;j++) { if(lines[j].IsEmpty()) { ret=-44; //empty top level condition } else { ret=compile_trigger(lines[j], trigger); if(!pst_compatible_var()) { if((trigger.opcode&0x3fff)==TR_OR) { if(num_or) { ret=-42; } num_or=trigger.bytes[0]; if (num_or<2 && check_or_scan!=SCANNING) { ret=-47; } } else if(num_or) num_or--; } } if(ret) { if(check_or_scan!=SCANNING) { log("Invalid top level condition: %s at line #%d in %d. state trigger block (%s)", lines[j],j+1,i, get_compile_error(ret)); gret=STATETR|i; //found errors } } else { ret=check_or_scan_trigger(&trigger, handle_trigger(trigger.opcode), check_or_scan, j); if(ret && (check_or_scan!=SCANNING) ) { log("Top level condition was: %s", lines[j]); gret=STATETR|i; } } } if(num_or) { log("Error: %s",get_compile_error(-42)); gret=STATETR|i; } if(lines) delete[] lines; } for(i=0;i<the_dialog.trtriggercount;i++) { lines=explode(the_dialog.trtriggers[i], '\n', linecount); if(linecount==-1) { log("Out of memory"); return -1; } num_or=0; for(j=0;j<linecount;j++) { ret=compile_trigger(lines[j], trigger); if(!pst_compatible_var()) { if((trigger.opcode&0x3fff)==TR_OR) { if(num_or) ret=-42; num_or=trigger.bytes[0]; if (num_or<2 && check_or_scan!=SCANNING) { ret=-47; } } else if(num_or) num_or--; } if(ret) { if(check_or_scan!=SCANNING) { log("Invalid trigger: %s in line #%d in %d. transition trigger block (%s)",lines[j],j+1,i, get_compile_error(ret)); gret=TRANSTR|i; } } else { ret=check_or_scan_trigger(&trigger, handle_trigger(trigger.opcode), check_or_scan, j); if(ret && (check_or_scan!=SCANNING) ) { tmp = lasterrormsg; log("Transition trigger was: %s", lines[j]); lasterrormsg = tmp + "\n" + lasterrormsg; gret=TRANSTR|i; } } } if(num_or) { log("Invalid trigger: in line #%d in %d. transition trigger block (%s)",j, i, get_compile_error(-42)); gret=TRANSTR|i; } if(lines) delete[] lines; } } //num_or stores the previous action opcode initializing it to non-special num_or=0; for(i=0;i<the_dialog.actioncount;i++) { lines=explode(the_dialog.actions[i], '\n', linecount); if(linecount==-1) { log("Out of memory"); return -1; } for(j=0;j<linecount;j++) { ret=compile_action(lines[j], action, false); if(ret) { if(check_or_scan!=CHECKING) continue; log("Invalid action: %s in line #%d in %d. action block (%s)", lines[j],j+1,i,get_compile_error(ret)); gret=ACTIONBL|i; } else { if(check_or_scan!=JOURNAL) { ret=check_or_scan_action(&action, handle_action(action.opcode), check_or_scan, j); if(check_or_scan!=CHECKING) continue; if(ret) { log("Action was: %s", lines[j]); gret=ACTIONBL|i; continue; } } } if(check_or_scan==JOURNAL) { switch(action.opcode) { case AC_REMOVE_JOURNAL_IWD:case AC_QUESTDONE_IWD: if(has_xpvar()) { journal.type=0; journals.Lookup(action.bytes[0], journal); journal.string=""; journal.type|=HAS_SOLVED; journals[action.bytes[0]]=journal; } break; case AC_REMOVE_JOURNAL_BG: case AC_QUESTDONE_BG: if(!has_xpvar()) { journal.type=0; journals.Lookup(action.bytes[0], journal); journal.string=""; journal.type|=HAS_SOLVED; journals[action.bytes[0]]=journal; } break; case AC_ADD_JOURNAL: if(has_xpvar() || (action.bytes[3]==JT_QUEST)) { if(journals.Lookup(action.bytes[0],journal)) { if(!journal.string.IsEmpty()) { if (journal.string.Find(itemname)<0) { journal.string+=", "+itemname; } } journal.type|=HAS_QUEST; journals[action.bytes[0]]=journal; } else { journal.string=itemname; journal.type=HAS_QUEST; journals[action.bytes[0]]=journal; } } else { if (action.bytes[3]==JT_DONE) { journal.type=0; journals.Lookup(action.bytes[0],journal); journal.string=""; journal.type|=HAS_SOLVED; journals[action.bytes[0]]=journal; } } } continue; } if(chkflg&NOCUT) continue; if(action.opcode==AC_STCUTMD) { if((num_or!=AC_CLRACT) && (num_or!=AC_CLRALLACT)) { log("Invalid action: StartCutSceneMode() without ClearActions() in line #%d in %d. action block", j+1,i); gret=ACTIONBL|i; } else if(action.opcode==AC_STARTCUT) { if(num_or!=AC_STCUTMD) { log("StartCutScene() without StartCutSceneMode() in line #%d in %d. action block", j+1,i); gret=ACTIONBL|i; } } } if((action.opcode==AC_STCUTMD) || (action.opcode==AC_STARTCUT) || (action.opcode==AC_CLRACT) || (action.opcode==AC_CLRALLACT)) num_or=action.opcode; } if(lines) delete[] lines; } return gret; }
int CChitemDlg::check_script(int check_or_scan) //scans for variables { int ret, gret; int bcnt, tcnt, rcnt, acnt; block *bpoi; trigger *tpoi; response *rpoi; action *apoi; int num_or; int checkflags; CString area; journal_type journal; int opcode; int i; gret=0; if(!the_script.blockcount) { gret=-1; log("Empty script!"); } for(bcnt=0;bcnt<the_script.blockcount; bcnt++) { bpoi=&the_script.blocks[bcnt]; if(!bpoi->triggercount && (check_or_scan!=SCANNING) ) { gret=-1; log("No trigger in block #%d",bcnt+1); } //triggers using variables num_or=0; opcode=0; //initialize opcode to non-TR_FALSE if(check_or_scan!=JOURNAL) //triggers don't have journals { for(tcnt=0;tcnt<bpoi->triggercount; tcnt++) { tpoi=&bpoi->triggers[tcnt]; opcode=tpoi->opcode&0x1fff; if(check_or_scan==CHECKING) { if((opcode>MAX_TRIGGER) || !trigger_defs[opcode].GetLength()) { gret=-1; log("Invalid trigger: %d (%04x) in block #%d trigger #%d",tpoi->opcode, tpoi->opcode,bcnt+1,tcnt+1); continue; } if(pst_compatible_var()) continue; if(opcode==TR_OR) { if(num_or) { gret=-1; log("Bad OR count in block #%d trigger #%d",bcnt+1,tcnt+1); } num_or=tpoi->bytes[0]; if (num_or<2 && check_or_scan!=SCANNING) { gret=-1; log("Incorrect or redundant Or() in block #%d trigger #%d", bcnt+1, tcnt+1); } } else if(num_or) num_or--; } checkflags=handle_trigger(tpoi->opcode); // not only death variable but: waypoints, triggers, doors etc if(store_variable(tpoi->trobj.var, CHECK_DEAD2|(checkflags&0xffff0000),0,OBJECT|TRIGGER|check_or_scan,bcnt)) { log(resolve_scriptelement(opcode, TRIGGER, bcnt)); } if((checkflags&0xff00)==0xff00) { if(checkflags&1) area=CString(tpoi->var2)+tpoi->var1; else area=CString(tpoi->var1)+tpoi->var2; ret=store_variable(area, ADD_VAR, tpoi->opcode, TRIGGER|check_or_scan, bcnt); gret|=ret; } else { varname2=tpoi->var2; ret=store_variable(tpoi->var1, checkflags, tpoi->opcode, TRIGGER|check_or_scan, bcnt); gret|=ret; ret=store_variable(tpoi->var2, checkflags>>8, tpoi->opcode, TRIGGER|check_or_scan, bcnt); gret|=ret; } if(check_or_scan==CHECKING) { ret=check_integers(&tpoi->bytes[0], checkflags, tpoi->opcode, TRIGGER|check_or_scan, bcnt); gret|=ret; } } if(check_or_scan==CHECKING) { if(num_or) { gret=-1; log("Bad OR count in block #%d trigger #%d",bcnt+1,tcnt); } if(!bpoi->responsecount ) { log("No response in block #%d",bcnt+1); } } } for(rcnt=0;rcnt<bpoi->responsecount; rcnt++) { rpoi=&bpoi->responses[rcnt]; //if last opcode is False() then we don't care about the empty response if(opcode!=TR_FALSE && !rpoi->actioncount && (check_or_scan==CHECKING) ) { gret=-1; log("No action in block #%d response #%d",bcnt+1,rcnt+1); } //actions using variables num_or=0; for(acnt=0;acnt<rpoi->actioncount; acnt++) { apoi=&rpoi->actions[acnt]; // not only death variable but: waypoints, triggers, doors etc for(i=0;i<3;i++) { if(store_variable(apoi->obj[i].var, CHECK_DEAD2|(0xffff0000&handle_action(apoi->opcode)),i,OBJECT|ACTION|check_or_scan,bcnt)) { log("%s in response #%d",resolve_scriptelement(apoi->opcode, ACTION, acnt), rcnt+1); } } if(check_or_scan==JOURNAL) { switch(apoi->opcode) { //this is a solved journal entry case AC_REMOVE_JOURNAL_IWD:case AC_QUESTDONE_IWD: if(has_xpvar()) { journal.type=0; journals.Lookup(apoi->bytes[0], journal); journal.string=""; journal.type|=HAS_SOLVED; journals[apoi->bytes[0]]=journal; } break; case AC_REMOVE_JOURNAL_BG: case AC_QUESTDONE_BG: if(!has_xpvar()) { journal.type=0; journals.Lookup(apoi->bytes[0], journal); journal.string=""; journal.type|=HAS_SOLVED; journals[apoi->bytes[0]]=journal; } break; case AC_ADD_JOURNAL: //this is an undone quest journal entry if(has_xpvar() || (apoi->bytes[3]==JT_QUEST)) { if(journals.Lookup(apoi->bytes[0],journal)) { if(!journal.string.IsEmpty()) { if (journal.string.Find(itemname)<0) { journal.string+=", "+itemname; } journal.type|=HAS_QUEST; journals[apoi->bytes[0]]=journal; } } else { journal.string=itemname; journal.type=HAS_QUEST; journals[apoi->bytes[0]]=journal; } } else { if (apoi->bytes[3]==JT_DONE) { journal.type=0; journals.Lookup(apoi->bytes[0], journal); journal.string=""; journal.type|=HAS_SOLVED; journals[apoi->bytes[0]]=journal; } } break; } continue; } if((apoi->opcode>MAX_ACTION) || !action_defs[apoi->opcode].GetLength()) { gret=-1; log("Invalid action: %d in block #%d response #%d action #%d",apoi->opcode,bcnt+1, rcnt+1, acnt+1); continue; } checkflags=handle_action(apoi->opcode); if((checkflags&0xff00)==0xff00) { if(checkflags&1) area=CString(apoi->var2)+apoi->var1; else area=CString(apoi->var1)+apoi->var2; ret=store_variable(area, ADD_VAR, apoi->opcode, ACTION|check_or_scan, bcnt); gret|=ret; } else { varname2=apoi->var2; ret=store_variable(apoi->var1, checkflags, apoi->opcode, ACTION|check_or_scan, bcnt); gret|=ret; ret=store_variable(apoi->var2, checkflags>>8, apoi->opcode, ACTION|check_or_scan, bcnt); gret|=ret; } if(check_or_scan==CHECKING) { ret=check_integers(apoi->bytes, checkflags, apoi->opcode, ACTION|check_or_scan, bcnt); gret|=ret; if(chkflg&NOCUT) continue; if(apoi->opcode==AC_STARTCUT) { if(num_or!=AC_STCUTMD) { log("StartCutScene() without StartCutSceneMode() in block #%d response #%d action #%d", bcnt+1,rcnt+1,acnt+1); gret|=1; } } if((apoi->opcode==AC_STCUTMD) || (apoi->opcode==AC_STARTCUT) || (apoi->opcode==AC_CLRACT) || (apoi->opcode==AC_CLRALLACT)) num_or=apoi->opcode; } } } } return gret; }
void g_action_listener::event_received(uint8_t* data, uint32_t length) { g_action_event e; handle_action(e); }
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps; POINT press; HMENU menu; switch (message) { case WM_KEYDOWN: if (hwnd != mainPtr) check_cd_event(hwnd,message,wParam,lParam); return 0; break; case WM_CHAR: if (hwnd != mainPtr) check_cd_event(hwnd,message,wParam,lParam); return 0; break; case WM_LBUTTONDOWN: cursor_stay(); if (hwnd != mainPtr) check_cd_event(hwnd,message,wParam,lParam); else { SetFocus(hwnd); press = MAKEPOINT(lParam); All_Done = handle_action(press, wParam,lParam); check_game_done(); } return 0; break; case WM_RBUTTONDOWN: cursor_stay(); if (hwnd != mainPtr) check_cd_event(hwnd,message,wParam,lParam); return 0; break; case WM_ACTIVATE: if (hwnd == mainPtr) { if ((LOWORD(wParam) == WA_ACTIVE) ||(LOWORD(wParam) == WA_CLICKACTIVE)) { window_in_front = TRUE; } if (LOWORD(wParam) == WA_INACTIVE) { window_in_front = FALSE; } } return 0; case WM_MOUSEMOVE: set_cursor(sword_curs); return 0; case WM_PAINT: BeginPaint(hwnd,&ps); EndPaint(hwnd,&ps); if (hwnd != mainPtr) check_cd_event(hwnd,message,wParam,lParam); else redraw_screen(); return 0; case WM_COMMAND: if (hwnd == mainPtr) { menu = GetMenu(mainPtr); handle_menu((short) LOWORD(wParam), menu); check_game_done(); } else { check_cd_event(hwnd,message,wParam,lParam); } return 0; case WM_DESTROY: case WM_CLOSE: if (hwnd == mainPtr) { lose_graphics(); PostQuitMessage(0); } return 0; case WM_QUIT: if (hwnd == mainPtr){ lose_graphics(); PostQuitMessage(0); } break; } return DefWindowProc(hwnd,message,wParam,lParam); }
/** * ieee802_11_mgmt - process incoming IEEE 802.11 management frames * @hapd: hostapd BSS data structure (the BSS to which the management frame was * sent to) * @buf: management frame data (starting from IEEE 802.11 header) * @len: length of frame data in octets * @fi: meta data about received frame (signal level, etc.) * * Process all incoming IEEE 802.11 management frames. This will be called for * each frame received from the kernel driver through wlan#ap interface. In * addition, it can be called to re-inserted pending frames (e.g., when using * external RADIUS server as an MAC ACL). */ void ieee802_11_mgmt(struct hostapd_data *hapd, const u8 *buf, size_t len, struct hostapd_frame_info *fi) { struct ieee80211_mgmt *mgmt; int broadcast; u16 fc, stype; mgmt = (struct ieee80211_mgmt *) buf; fc = le_to_host16(mgmt->frame_control); stype = WLAN_FC_GET_STYPE(fc); if (stype == WLAN_FC_STYPE_BEACON) { handle_beacon(hapd, mgmt, len, fi); return; } broadcast = mgmt->bssid[0] == 0xff && mgmt->bssid[1] == 0xff && mgmt->bssid[2] == 0xff && mgmt->bssid[3] == 0xff && mgmt->bssid[4] == 0xff && mgmt->bssid[5] == 0xff; if (!broadcast && os_memcmp(mgmt->bssid, hapd->own_addr, ETH_ALEN) != 0) { printf("MGMT: BSSID=" MACSTR " not our address\n", MAC2STR(mgmt->bssid)); return; } if (stype == WLAN_FC_STYPE_PROBE_REQ) { handle_probe_req(hapd, mgmt, len); return; } if (os_memcmp(mgmt->da, hapd->own_addr, ETH_ALEN) != 0) { hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211, HOSTAPD_LEVEL_DEBUG, "MGMT: DA=" MACSTR " not our address", MAC2STR(mgmt->da)); return; } switch (stype) { case WLAN_FC_STYPE_AUTH: wpa_printf(MSG_DEBUG, "mgmt::auth"); handle_auth(hapd, mgmt, len); break; case WLAN_FC_STYPE_ASSOC_REQ: wpa_printf(MSG_DEBUG, "mgmt::assoc_req"); handle_assoc(hapd, mgmt, len, 0); break; case WLAN_FC_STYPE_REASSOC_REQ: wpa_printf(MSG_DEBUG, "mgmt::reassoc_req"); handle_assoc(hapd, mgmt, len, 1); break; case WLAN_FC_STYPE_DISASSOC: wpa_printf(MSG_DEBUG, "mgmt::disassoc"); handle_disassoc(hapd, mgmt, len); break; case WLAN_FC_STYPE_DEAUTH: wpa_printf(MSG_DEBUG, "mgmt::deauth"); handle_deauth(hapd, mgmt, len); break; case WLAN_FC_STYPE_ACTION: wpa_printf(MSG_DEBUG, "mgmt::action"); handle_action(hapd, mgmt, len); break; default: hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211, HOSTAPD_LEVEL_DEBUG, "unknown mgmt frame subtype %d", stype); break; } }