/**************************************************************************** Give technologies to players with EFT_TECH_PARASITE (traditionally from the Great Library). ****************************************************************************/ void do_tech_parasite_effect(struct player *pplayer) { int mod; struct effect_list *plist = effect_list_new(); /* Note that two EFT_TECH_PARASITE effects will combine into a single, * much worse effect. */ if ((mod = get_player_bonus_effects(plist, pplayer, EFT_TECH_PARASITE)) > 0) { char buf[512]; buf[0] = '\0'; effect_list_iterate(plist, peffect) { if (buf[0] != '\0') { sz_strlcat(buf, ", "); } get_effect_req_text(peffect, buf, sizeof(buf)); } effect_list_iterate_end; advance_index_iterate(A_FIRST, i) { if (player_invention_reachable(pplayer, i) && player_invention_state(pplayer, i) != TECH_KNOWN) { int num_players = 0; players_iterate(aplayer) { if (player_invention_state(aplayer, i) == TECH_KNOWN) { num_players++; } } players_iterate_end; if (num_players >= mod) { notify_player(pplayer, NULL, E_TECH_GAIN, FTC_SERVER_INFO, NULL, _("%s acquired from %s!"), advance_name_for_player(pplayer, i), buf); notify_embassies(pplayer, NULL, NULL, E_TECH_GAIN, FTC_SERVER_INFO, NULL, _("The %s have acquired %s from %s."), nation_plural_for_player(pplayer), advance_name_for_player(pplayer, i), buf); do_free_cost(pplayer, i); found_new_tech(pplayer, i, FALSE, TRUE); script_signal_emit("tech_researched", 3, API_TYPE_TECH_TYPE, advance_by_number(i), API_TYPE_PLAYER, pplayer, API_TYPE_STRING, "stolen"); break; } } } advance_index_iterate_end;
/************************************************************************** Mark as TECH_PREREQS_KNOWN each tech which is available, not known and which has all requirements fullfiled. If there is no such a tech mark A_FUTURE as researchable. Recalculate research->num_known_tech_with_flag Should always be called after player_invention_set() **************************************************************************/ void player_research_update(struct player *pplayer) { enum tech_flag_id flag; int researchable = 0; struct player_research *research = player_research_get(pplayer); /* This is set when the game starts, but not everybody finds out * right away. */ player_invention_set(pplayer, A_NONE, TECH_KNOWN); advance_index_iterate(A_FIRST, i) { if (!player_invention_reachable(pplayer, i, FALSE)) { player_invention_set(pplayer, i, TECH_UNKNOWN); } else { if (player_invention_state(pplayer, i) == TECH_PREREQS_KNOWN) { player_invention_set(pplayer, i, TECH_UNKNOWN); } if (player_invention_state(pplayer, i) == TECH_UNKNOWN && player_invention_state(pplayer, advance_required(i, AR_ONE)) == TECH_KNOWN && player_invention_state(pplayer, advance_required(i, AR_TWO)) == TECH_KNOWN) { player_invention_set(pplayer, i, TECH_PREREQS_KNOWN); researchable++; } } build_required_techs(pplayer, i); } advance_index_iterate_end; #ifdef DEBUG_TECH advance_index_iterate(A_FIRST, i) { char buf[advance_count() + 1]; advance_index_iterate(A_NONE, j) { if (BV_ISSET(research->inventions[i].required_techs, j)) { buf[j] = '1'; } else { buf[j] = '0'; } } advance_index_iterate_end; buf[advance_count()] = '\0'; log_debug("%s: [%3d] %-25s => %s", player_name(pplayer), i, advance_rule_name(advance_by_number(i)), tech_state_name(player_invention_state(pplayer, i))); log_debug("%s: [%3d] %s", player_name(pplayer), i, buf); } advance_index_iterate_end;
/************************************************************************** Give pplayer technology ptech. Quietly returns A_NONE (zero) if player already has this tech; otherwise returns the tech granted. Use NULL for ptech to grant a random tech. sends script signal "tech_researched" with the given reason **************************************************************************/ Tech_Type *api_actions_give_technology(Player *pplayer, Tech_Type *ptech, const char *reason) { Tech_type_id id; Tech_Type *result; if (ptech) { id = advance_number(ptech); } else { if (get_player_research(pplayer)->researching == A_UNSET) { choose_random_tech(pplayer); } id = get_player_research(pplayer)->researching; } if (player_invention_state(pplayer, id) != TECH_KNOWN) { do_free_cost(pplayer, id); found_new_tech(pplayer, id, FALSE, TRUE); result = advance_by_number(id); script_signal_emit("tech_researched", 3, API_TYPE_TECH_TYPE, result, API_TYPE_PLAYER, pplayer, API_TYPE_STRING, reason); return result; } else { return advance_by_number(A_NONE); } }
/************************************************************************** Marks all techs which are requirements for goal in pplayer->research->inventions[goal].required_techs. Works recursive. **************************************************************************/ static void build_required_techs_helper(struct player *pplayer, Tech_type_id tech, Tech_type_id goal) { /* The is_tech_a_req_for_goal condition is true if the tech is * already marked */ if (!player_invention_reachable(pplayer, tech, FALSE) || player_invention_state(pplayer, tech) == TECH_KNOWN || is_tech_a_req_for_goal(pplayer, tech, goal)) { return; } /* Mark the tech as required for the goal */ BV_SET(player_research_get(pplayer)->inventions[goal].required_techs, tech); if (advance_required(tech, AR_ONE) == goal || advance_required(tech, AR_TWO) == goal) { log_fatal("tech \"%s\": requires itself", advance_name_by_player(pplayer, goal)); exit(EXIT_FAILURE); } build_required_techs_helper(pplayer, advance_required(tech, AR_ONE), goal); build_required_techs_helper(pplayer, advance_required(tech, AR_TWO), goal); }
/************************************************************************** Returns TRUE iff the given tech is ever reachable by the given player by checking tech tree limitations. If allow_prereqs is TRUE check if the player can ever reach this tech. pplayer may be NULL in which case a simplified result is returned (used by the client). **************************************************************************/ bool player_invention_reachable(const struct player *pplayer, const Tech_type_id tech, bool allow_prereqs) { Tech_type_id root; if (!valid_advance_by_number(tech)) { return FALSE; } root = advance_required(tech, AR_ROOT); if (A_NONE != root) { if (root == tech) { /* This tech requires itself; it can only be reached by special means * (init_techs, lua script, ...). * If you already know it, you can "reach" it; if not, not. (This case * is needed for descendants of this tech.) */ return TECH_KNOWN == player_invention_state(pplayer, tech); } else if (allow_prereqs) { /* Recursive check if the player can ever reach this tech (root tech * and both requirements). */ return (player_invention_reachable(pplayer, root, TRUE) && player_invention_reachable(pplayer, advance_required(tech, AR_ONE), allow_prereqs) && player_invention_reachable(pplayer, advance_required(tech, AR_TWO), allow_prereqs)); } else if (TECH_KNOWN != player_invention_state(pplayer, root) || !player_invention_reachable(pplayer, advance_required(tech, AR_ONE), allow_prereqs) || !player_invention_reachable(pplayer, advance_required(tech, AR_TWO), allow_prereqs)) { /* This tech requires knowledge of another tech (root tech or recursive * a root tech of a requirement) before being available. Prevents * sharing of untransferable techs. */ return FALSE; } } return TRUE; }
PyObject* get_techs(int level) { PyObject* list = PyList_New(0); int num, i; advance_index_iterate(A_FIRST, i) { if (player_invention_reachable(client.conn.playing, i, FALSE) && TECH_KNOWN != player_invention_state(client.conn.playing, i) && (level > (num = num_unknown_techs_for_goal(client.conn.playing, i)) /*|| player_research_get(client.conn.playing) == research->tech_goal*/)) { PyList_Append(list, Py_BuildValue("isi", i, advance_name_translation(advance_by_number(i)), num)); } } advance_index_iterate_end; return list; }
/************************************************************************** ... **************************************************************************/ SDL_Color * get_tech_color(Tech_type_id tech_id) { if (player_invention_reachable(client.conn.playing, tech_id)) { switch (player_invention_state(client.conn.playing, tech_id)) { case TECH_UNKNOWN: return get_game_colorRGB(COLOR_REQTREE_UNKNOWN); case TECH_KNOWN: return get_game_colorRGB(COLOR_REQTREE_KNOWN); case TECH_PREREQS_KNOWN: return get_game_colorRGB(COLOR_REQTREE_PREREQS_KNOWN); default: return get_game_colorRGB(COLOR_REQTREE_BACKGROUND); } } return get_game_colorRGB(COLOR_REQTREE_UNREACHABLE); }
/************************************************************************** Updates required_techs, num_required_techs and bulbs_required in pplayer->research->inventions[goal]. **************************************************************************/ static void build_required_techs(struct player *pplayer, Tech_type_id goal) { int counter; struct player_research *research = player_research_get(pplayer); BV_CLR_ALL(research->inventions[goal].required_techs); if (player_invention_state(pplayer, goal) == TECH_KNOWN) { research->inventions[goal].num_required_techs = 0; research->inventions[goal].bulbs_required = 0; return; } build_required_techs_helper(pplayer, goal, goal); /* Include the goal tech */ research->inventions[goal].bulbs_required = base_total_bulbs_required(pplayer, goal); research->inventions[goal].num_required_techs = 1; counter = 0; advance_index_iterate(A_FIRST, i) { if (!is_tech_a_req_for_goal(pplayer, i, goal)) { continue; } /* * This is needed to get a correct result for the * base_total_bulbs_required call. */ research->techs_researched++; counter++; research->inventions[goal].num_required_techs++; research->inventions[goal].bulbs_required += base_total_bulbs_required(pplayer, i); } advance_index_iterate_end; /* Undo the changes made above */ research->techs_researched -= counter; }
/**************************************************************** ... *****************************************************************/ static int create_advances_list(struct player *pplayer, struct player *pvictim, bool make_modal) { Widget spy_tech_form; Widget close_command; Dimension width1, width2; int j; static const char *advances_can_steal[A_LAST+1]; spy_tech_shell = I_T(XtVaCreatePopupShell("spystealtechpopup", (make_modal ? transientShellWidgetClass : topLevelShellWidgetClass), toplevel, NULL)); spy_tech_form = XtVaCreateManagedWidget("spystealtechform", formWidgetClass, spy_tech_shell, NULL); spy_advances_list_label = I_L(XtVaCreateManagedWidget("spystealtechlistlabel", labelWidgetClass, spy_tech_form, NULL)); spy_advances_list = XtVaCreateManagedWidget("spystealtechlist", listWidgetClass, spy_tech_form, NULL); close_command = I_L(XtVaCreateManagedWidget("spystealtechclosecommand", commandWidgetClass, spy_tech_form, NULL)); spy_steal_command = I_L(XtVaCreateManagedWidget("spystealtechcommand", commandWidgetClass, spy_tech_form, XtNsensitive, False, NULL)); XtAddCallback(spy_advances_list, XtNcallback, spy_select_tech_callback, NULL); XtAddCallback(close_command, XtNcallback, spy_close_tech_callback, NULL); XtAddCallback(spy_steal_command, XtNcallback, spy_steal_callback, NULL); XtRealizeWidget(spy_tech_shell); /* Now populate the list */ j = 0; advances_can_steal[j] = _("NONE"); advance_type[j] = -1; if (pvictim) { /* you don't want to know what lag can do -- Syela */ advance_index_iterate(A_FIRST, i) { if(player_invention_state(pvictim, i)==TECH_KNOWN && (player_invention_state(pplayer, i)==TECH_UNKNOWN || player_invention_state(pplayer, i)==TECH_PREREQS_KNOWN)) { advances_can_steal[j] = advance_name_translation(advance_by_number(i)); advance_type[j++] = i; } } { static struct astring str = ASTRING_INIT; /* TRANS: %s is a unit name, e.g., Spy */ astr_set(&str, _("At %s's Discretion"), unit_name_translation(game_unit_by_number(diplomat_id))); advances_can_steal[j] = astr_str(&str); advance_type[j++] = A_UNSET; } } advance_index_iterate_end; if(j == 0) j++; advances_can_steal[j] = NULL; XtSetSensitive(spy_steal_command, FALSE); XawListChange(spy_advances_list, (char **)advances_can_steal, 0, 0, 1); XtVaGetValues(spy_advances_list, XtNwidth, &width1, NULL); XtVaGetValues(spy_advances_list_label, XtNwidth, &width2, NULL); XtVaSetValues(spy_advances_list, XtNwidth, MAX(width1,width2), NULL); XtVaSetValues(spy_advances_list_label, XtNwidth, MAX(width1,width2), NULL); return j; }
/**************************************************************** Create spy's tech stealing dialog *****************************************************************/ static void create_advances_list(struct player *pplayer, struct player *pvictim) { GtkWidget *sw, *label, *vbox, *view; GtkListStore *store; GtkCellRenderer *rend; GtkTreeViewColumn *col; spy_tech_shell = gtk_dialog_new_with_buttons(_("Steal Technology"), NULL, 0, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, _("_Steal"), GTK_RESPONSE_ACCEPT, NULL); setup_dialog(spy_tech_shell, toplevel); gtk_window_set_position(GTK_WINDOW(spy_tech_shell), GTK_WIN_POS_MOUSE); gtk_dialog_set_default_response(GTK_DIALOG(spy_tech_shell), GTK_RESPONSE_ACCEPT); label = gtk_frame_new(_("Select Advance to Steal")); gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(spy_tech_shell))), label); vbox = gtk_vbox_new(FALSE, 6); gtk_container_add(GTK_CONTAINER(label), vbox); store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT); view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); g_object_unref(store); gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE); rend = gtk_cell_renderer_text_new(); col = gtk_tree_view_column_new_with_attributes(NULL, rend, "text", 0, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(view), col); label = g_object_new(GTK_TYPE_LABEL, "use-underline", TRUE, "mnemonic-widget", view, "label", _("_Advances:"), "xalign", 0.0, "yalign", 0.5, NULL); gtk_container_add(GTK_CONTAINER(vbox), label); sw = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_ETCHED_IN); gtk_container_add(GTK_CONTAINER(sw), view); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); gtk_widget_set_size_request(sw, -1, 200); gtk_container_add(GTK_CONTAINER(vbox), sw); /* Now populate the list */ if (pvictim) { /* you don't want to know what lag can do -- Syela */ GtkTreeIter it; GValue value = { 0, }; advance_index_iterate(A_FIRST, i) { if(player_invention_state(pvictim, i)==TECH_KNOWN && (player_invention_state(pplayer, i)==TECH_UNKNOWN || player_invention_state(pplayer, i)==TECH_PREREQS_KNOWN)) { gtk_list_store_append(store, &it); g_value_init(&value, G_TYPE_STRING); g_value_set_static_string(&value, advance_name_for_player(client.conn.playing, i)); gtk_list_store_set_value(store, &it, 0, &value); g_value_unset(&value); gtk_list_store_set(store, &it, 1, i, -1); } } advance_index_iterate_end; gtk_list_store_append(store, &it); g_value_init(&value, G_TYPE_STRING); { struct astring str = ASTRING_INIT; /* TRANS: %s is a unit name, e.g., Spy */ astr_set(&str, _("At %s's Discretion"), unit_name_translation(game_unit_by_number(diplomat_id))); g_value_set_string(&value, astr_str(&str)); astr_free(&str); } gtk_list_store_set_value(store, &it, 0, &value); g_value_unset(&value); gtk_list_store_set(store, &it, 1, A_UNSET, -1); } gtk_dialog_set_response_sensitive(GTK_DIALOG(spy_tech_shell), GTK_RESPONSE_ACCEPT, FALSE); gtk_widget_show_all(gtk_dialog_get_content_area(GTK_DIALOG(spy_tech_shell))); g_signal_connect(gtk_tree_view_get_selection(GTK_TREE_VIEW(view)), "changed", G_CALLBACK(spy_advances_callback), NULL); g_signal_connect(spy_tech_shell, "response", G_CALLBACK(spy_advances_response), NULL); steal_advance = 0; gtk_tree_view_focus(GTK_TREE_VIEW(view)); }
/************************************************************************** ... **************************************************************************/ static int spy_steal_popup(struct widget *pWidget) { struct city *pVcity = pWidget->data.city; int id = MAX_ID - pWidget->ID; struct player *pVictim = NULL; struct CONTAINER *pCont; struct widget *pBuf = NULL; struct widget *pWindow; SDL_String16 *pStr; SDL_Surface *pSurf; int max_col, max_row, col, i, count = 0; SDL_Rect area; popdown_diplomat_dialog(); if(pVcity) { pVictim = city_owner(pVcity); } if (pDiplomat_Dlg || !pVictim) { return 1; } count = 0; advance_index_iterate(A_FIRST, i) { if (player_invention_reachable(client.conn.playing, i, FALSE) && TECH_KNOWN == player_invention_state(pVictim, i) && (TECH_UNKNOWN == player_invention_state(client.conn.playing, i) || TECH_PREREQS_KNOWN == player_invention_state(client.conn.playing, i))) { count++; } } advance_index_iterate_end; if(!count) { /* if there is no known tech to steal then send steal order at Spy's Discretion */ int target_id = pVcity->id; request_diplomat_action(DIPLOMAT_STEAL, id, target_id, advance_count()); return -1; } pCont = fc_calloc(1, sizeof(struct CONTAINER)); pCont->id0 = pVcity->id; pCont->id1 = id;/* spy id */ pDiplomat_Dlg = fc_calloc(1, sizeof(struct diplomat_dialog)); pDiplomat_Dlg->diplomat_id = id; pDiplomat_Dlg->diplomat_target_id = pVcity->id; pDiplomat_Dlg->pdialog = fc_calloc(1, sizeof(struct ADVANCED_DLG)); pStr = create_str16_from_char(_("Select Advance to Steal"), adj_font(12)); pStr->style |= TTF_STYLE_BOLD; pWindow = create_window_skeleton(NULL, pStr, 0); pWindow->action = spy_steal_dlg_window_callback; set_wstate(pWindow , FC_WS_NORMAL); add_to_gui_list(ID_DIPLOMAT_DLG_WINDOW, pWindow); pDiplomat_Dlg->pdialog->pEndWidgetList = pWindow; area = pWindow->area; area.w = MAX(area.w, adj_size(8)); /* ------------------ */ /* exit button */ pBuf = create_themeicon(pTheme->Small_CANCEL_Icon, pWindow->dst, WF_WIDGET_HAS_INFO_LABEL | WF_RESTORE_BACKGROUND); pBuf->info_label = create_str16_from_char(_("Close Dialog (Esc)"), adj_font(12)); area.w += pBuf->size.w + adj_size(10); pBuf->action = exit_spy_steal_dlg_callback; set_wstate(pBuf, FC_WS_NORMAL); pBuf->key = SDLK_ESCAPE; add_to_gui_list(ID_TERRAIN_ADV_DLG_EXIT_BUTTON, pBuf); /* ------------------------- */ count++; /* count + at Spy's Discretion */ /* max col - 104 is steal tech widget width */ max_col = (Main.screen->w - (pWindow->size.w - pWindow->area.w) - adj_size(2)) / adj_size(104); /* max row - 204 is steal tech widget height */ max_row = (Main.screen->h - (pWindow->size.h - pWindow->area.h)) / adj_size(204); /* make space on screen for scrollbar */ if (max_col * max_row < count) { max_col--; } if (count < max_col + 1) { col = count; } else { if (count < max_col + adj_size(3)) { col = max_col - adj_size(2); } else { if (count < max_col + adj_size(5)) { col = max_col - 1; } else { col = max_col; } } } pStr = create_string16(NULL, 0, adj_font(10)); pStr->style |= (TTF_STYLE_BOLD | SF_CENTER); count = 0; advance_index_iterate(A_FIRST, i) { if (player_invention_reachable(client.conn.playing, i, FALSE) && TECH_KNOWN == player_invention_state(pVictim, i) && (TECH_UNKNOWN == player_invention_state(client.conn.playing, i) || TECH_PREREQS_KNOWN == player_invention_state(client.conn.playing, i))) { count++; copy_chars_to_string16(pStr, advance_name_translation(advance_by_number(i))); pSurf = create_sellect_tech_icon(pStr, i, FULL_MODE); pBuf = create_icon2(pSurf, pWindow->dst, WF_FREE_THEME | WF_RESTORE_BACKGROUND); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = spy_steal_callback; pBuf->data.cont = pCont; add_to_gui_list(MAX_ID - i, pBuf); if (count > (col * max_row)) { set_wflag(pBuf, WF_HIDDEN); } } } advance_index_iterate_end; /* get spy tech */ i = advance_number(unit_type(game_unit_by_number(id))->require_advance); copy_chars_to_string16(pStr, _("At Spy's Discretion")); pSurf = create_sellect_tech_icon(pStr, i, FULL_MODE); pBuf = create_icon2(pSurf, pWindow->dst, (WF_FREE_THEME | WF_RESTORE_BACKGROUND| WF_FREE_DATA)); set_wstate(pBuf, FC_WS_NORMAL); pBuf->action = spy_steal_callback; pBuf->data.cont = pCont; add_to_gui_list(MAX_ID - advance_count(), pBuf); count++; /* --------------------------------------------------------- */ FREESTRING16(pStr); pDiplomat_Dlg->pdialog->pBeginWidgetList = pBuf; pDiplomat_Dlg->pdialog->pBeginActiveWidgetList = pDiplomat_Dlg->pdialog->pBeginWidgetList; pDiplomat_Dlg->pdialog->pEndActiveWidgetList = pDiplomat_Dlg->pdialog->pEndWidgetList->prev->prev; /* -------------------------------------------------------------- */ i = 0; if (count > col) { count = (count + (col - 1)) / col; if (count > max_row) { pDiplomat_Dlg->pdialog->pActiveWidgetList = pDiplomat_Dlg->pdialog->pEndActiveWidgetList; count = max_row; i = create_vertical_scrollbar(pDiplomat_Dlg->pdialog, col, count, TRUE, TRUE); } } else { count = 1; } area.w = MAX(area.w, (col * pBuf->size.w + adj_size(2) + i)); area.h = count * pBuf->size.h + adj_size(2); /* alloca window theme and win background buffer */ pSurf = theme_get_background(theme, BACKGROUND_SPYSTEALDLG); if (resize_window(pWindow, pSurf, NULL, (pWindow->size.w - pWindow->area.w) + area.w, (pWindow->size.h - pWindow->area.h) + area.h)) { FREESURFACE(pSurf); } area = pWindow->area; widget_set_position(pWindow, (Main.screen->w - pWindow->size.w) / 2, (Main.screen->h - pWindow->size.h) / 2); /* exit button */ pBuf = pWindow->prev; pBuf->size.x = area.x + area.w - pBuf->size.w - 1; pBuf->size.y = pWindow->size.y + adj_size(2); setup_vertical_widgets_position(col, area.x + 1, area.y, 0, 0, pDiplomat_Dlg->pdialog->pBeginActiveWidgetList, pDiplomat_Dlg->pdialog->pEndActiveWidgetList); if(pDiplomat_Dlg->pdialog->pScroll) { setup_vertical_scrollbar_area(pDiplomat_Dlg->pdialog->pScroll, area.x + area.w, area.y, area.h, TRUE); } redraw_group(pDiplomat_Dlg->pdialog->pBeginWidgetList, pWindow, FALSE); widget_mark_dirty(pWindow); return -1; }
/************************************************************************** Slot for selecting player/nation **************************************************************************/ void plr_widget::nation_selected(const QItemSelection &sl, const QItemSelection &ds) { QModelIndex index; QVariant qvar; QModelIndexList indexes = sl.indexes(); struct city *pcity; const struct player_diplstate *state; struct player_research *research; char tbuf[256]; QString res; QString sp = " "; QString nl = "<br>"; struct player *pplayer; int a , b; bool added; bool entry_exist = false; struct player *me; Tech_type_id tech_id; other_player = NULL; intel_str.clear(); tech_str.clear(); ally_str.clear(); if (indexes.isEmpty()) { plr->update_report(); return; } index = indexes.at(0); qvar = index.data(Qt::UserRole); pplayer = reinterpret_cast<player *>(qvar.value<void *>()); other_player = pplayer; if (pplayer->is_alive == false) { plr->update_report(); return; } pcity = player_capital(pplayer); research = player_research_get(pplayer); switch (research->researching) { case A_UNKNOWN: res = _("(Unknown)"); break; case A_UNSET: res = _("(none)"); break; default: res = QString(advance_name_researching(pplayer)) + sp + "(" + QString::number(research->bulbs_researched) + "/" + QString::number(total_bulbs_required(pplayer)) + ")"; break; } /** Formatting rich text */ intel_str = QString("<table><tr><td><b>") + _("Nation") + QString("</b></td><td>") + QString(nation_adjective_for_player(pplayer)) + QString("</td><tr><td><b>") + N_("Ruler:") + QString("</b></td><td>") + QString(ruler_title_for_player(pplayer, tbuf, sizeof(tbuf))) + QString("</td></tr><tr><td><b>") + N_("Government:") + QString("</b></td><td>") + QString(government_name_for_player(pplayer)) + QString("</td></tr><tr><td><b>") + N_("Capital:") + QString("</b></td><td>") + QString(((!pcity) ? _("(unknown)") : city_name(pcity))) + QString("</td></tr><tr><td><b>") + N_("Gold:") + QString("</b></td><td>") + QString::number(pplayer->economic.gold) + QString("</td></tr><tr><td><b>") + N_("Tax:") + QString("</b></td><td>") + QString::number(pplayer->economic.tax) + QString("%</td></tr><tr><td><b>") + N_("Science:") + QString("</b></td><td>") + QString::number(pplayer->economic.science) + QString("%</td></tr><tr><td><b>") + N_("Luxury:") + QString("</b></td><td>") + QString::number(pplayer->economic.luxury) + QString("%</td></tr><tr><td><b>") + N_("Researching:") + QString("</b></td><td>") + res + QString("</td></table>"); for (int i = 0; i < static_cast<int>(DS_LAST); i++) { added = false; if (entry_exist) { ally_str += "<br>"; } entry_exist = false; players_iterate_alive(other) { if (other == pplayer) { continue; } state = player_diplstate_get(pplayer, other); if (static_cast<int>(state->type) == i) { if (added == false) { ally_str = ally_str + QString("<b>") + QString(diplstate_type_translated_name( static_cast<diplstate_type>(i))) + ": " + QString("</b>") + nl; added = true; } ally_str = ally_str + nation_plural_for_player(other) + ", "; entry_exist = true; } } players_iterate_alive_end; if (entry_exist) { ally_str.replace(ally_str.lastIndexOf(","), 1, "."); } } me = client_player(); if ((player_has_embassy(me, pplayer) || client_is_global_observer()) && me != pplayer) { a = 0; b = 0; techs_known = QString("<b>") + _("Techs unknown by") + sp + QString(nation_adjective_for_player(pplayer)) + sp + QString(_("nation")) + QString("</b> :"); techs_unknown = QString("<b>") + _("Techs unkown by you") + sp + QString("</b> :"); advance_iterate(A_FIRST, padvance) { tech_id = advance_number(padvance); if (player_invention_state(me, tech_id) == TECH_KNOWN && (player_invention_state(pplayer, tech_id) == TECH_UNKNOWN)) { a++; techs_known = techs_known + QString("<i>") + advance_name_for_player(pplayer, tech_id) + "," + QString("</i>") + sp; } if (player_invention_state(me, tech_id) == TECH_UNKNOWN && (player_invention_state(pplayer, tech_id) == TECH_KNOWN)) { b++; techs_unknown = techs_unknown + QString("<i>") + advance_name_for_player(pplayer, tech_id) + "," + QString("</i>") + sp; } } advance_iterate_end;