static gboolean set_nosetup_nodes(const Hex * hex, gpointer closure) { gint idx; Map *copy = closure; for (idx = 0; idx < G_N_ELEMENTS(hex->nodes); ++idx) { const Node *node = hex->nodes[idx]; /* only handle nodes which are owned by the hex, to * prevent doing every node three times */ if (hex->x != node->x || hex->y != node->y) continue; g_assert(map_node(copy, node->x, node->y, node->pos) != NULL); map_node(copy, node->x, node->y, node->pos)->no_setup = node->no_setup; } return FALSE; }
/* * paging_init() continues the virtual memory environment setup which * was begun by the code in arch/head.S. */ void __init paging_init(void) { unsigned long zones_size[MAX_NR_ZONES] = { 0, }; unsigned long min_addr, max_addr; unsigned long addr, size, end; int i; #ifdef DEBUG { extern unsigned long availmem; printk ("start of paging_init (%p, %lx)\n", kernel_pg_dir, availmem); } #endif /* Fix the cache mode in the page descriptors for the 680[46]0. */ if (CPU_IS_040_OR_060) { int i; #ifndef mm_cachebits mm_cachebits = _PAGE_CACHE040; #endif for (i = 0; i < 16; i++) pgprot_val(protection_map[i]) |= _PAGE_CACHE040; } min_addr = m68k_memory[0].addr; max_addr = min_addr + m68k_memory[0].size; for (i = 1; i < m68k_num_memory;) { if (m68k_memory[i].addr < min_addr) { printk("Ignoring memory chunk at 0x%lx:0x%lx before the first chunk\n", m68k_memory[i].addr, m68k_memory[i].size); printk("Fix your bootloader or use a memfile to make use of this area!\n"); m68k_num_memory--; memmove(m68k_memory + i, m68k_memory + i + 1, (m68k_num_memory - i) * sizeof(struct mem_info)); continue; } addr = m68k_memory[i].addr + m68k_memory[i].size; if (addr > max_addr) max_addr = addr; i++; } m68k_memoffset = min_addr - PAGE_OFFSET; m68k_virt_to_node_shift = fls(max_addr - min_addr - 1) - 6; module_fixup(NULL, __start_fixup, __stop_fixup); flush_icache(); high_memory = phys_to_virt(max_addr); min_low_pfn = availmem >> PAGE_SHIFT; max_low_pfn = max_addr >> PAGE_SHIFT; for (i = 0; i < m68k_num_memory; i++) { addr = m68k_memory[i].addr; end = addr + m68k_memory[i].size; m68k_setup_node(i); availmem = PAGE_ALIGN(availmem); availmem += init_bootmem_node(NODE_DATA(i), availmem >> PAGE_SHIFT, addr >> PAGE_SHIFT, end >> PAGE_SHIFT); } /* * Map the physical memory available into the kernel virtual * address space. First initialize the bootmem allocator with * the memory we already mapped, so map_node() has something * to allocate. */ addr = m68k_memory[0].addr; size = m68k_memory[0].size; free_bootmem_node(NODE_DATA(0), availmem, min(INIT_MAPPED_SIZE, size) - (availmem - addr)); map_node(0); if (size > INIT_MAPPED_SIZE) free_bootmem_node(NODE_DATA(0), addr + INIT_MAPPED_SIZE, size - INIT_MAPPED_SIZE); for (i = 1; i < m68k_num_memory; i++) map_node(i); flush_tlb_all(); /* * initialize the bad page table and bad page to point * to a couple of allocated pages */ empty_zero_page = alloc_bootmem_pages(PAGE_SIZE); memset(empty_zero_page, 0, PAGE_SIZE); /* * Set up SFC/DFC registers */ set_fs(KERNEL_DS); #ifdef DEBUG printk ("before free_area_init\n"); #endif for (i = 0; i < m68k_num_memory; i++) { zones_size[ZONE_DMA] = m68k_memory[i].size >> PAGE_SHIFT; free_area_init_node(i, pg_data_map + i, zones_size, m68k_memory[i].addr >> PAGE_SHIFT, NULL); } }
void player_build_remove(gint player_num, BuildType type, gint x, gint y, gint pos) { Edge *edge; Node *node; switch (type) { case BUILD_ROAD: edge = map_edge(callbacks.get_map(), x, y, pos); edge->owner = -1; callbacks.draw_edge(edge); edge->type = BUILD_NONE; log_message(MSG_BUILD, _("%s removed a road.\n"), player_name(player_num, TRUE)); if (player_num == my_player_num()) stock_replace_road(); break; case BUILD_SHIP: edge = map_edge(callbacks.get_map(), x, y, pos); edge->owner = -1; callbacks.draw_edge(edge); edge->type = BUILD_NONE; log_message(MSG_BUILD, _("%s removed a ship.\n"), player_name(player_num, TRUE)); if (player_num == my_player_num()) stock_replace_ship(); break; case BUILD_SETTLEMENT: node = map_node(callbacks.get_map(), x, y, pos); node->type = BUILD_NONE; node->owner = -1; callbacks.draw_node(node); log_message(MSG_BUILD, _("%s removed a settlement.\n"), player_name(player_num, TRUE)); player_modify_statistic(player_num, STAT_SETTLEMENTS, -1); if (player_num == my_player_num()) stock_replace_settlement(); break; case BUILD_CITY: node = map_node(callbacks.get_map(), x, y, pos); node->type = BUILD_SETTLEMENT; node->owner = player_num; callbacks.draw_node(node); log_message(MSG_BUILD, _("%s removed a city.\n"), player_name(player_num, TRUE)); player_modify_statistic(player_num, STAT_SETTLEMENTS, 1); player_modify_statistic(player_num, STAT_CITIES, -1); if (player_num == my_player_num()) { stock_use_settlement(); stock_replace_city(); } break; case BUILD_CITY_WALL: node = map_node(callbacks.get_map(), x, y, pos); node->city_wall = FALSE; node->owner = player_num; callbacks.draw_node(node); log_message(MSG_BUILD, _("%s removed a city wall.\n"), player_name(player_num, TRUE)); player_modify_statistic(player_num, STAT_CITY_WALLS, -1); if (player_num == my_player_num()) stock_replace_city_wall(); break; case BUILD_NONE: log_message(MSG_ERROR, _("" "player_build_remove called with BUILD_NONE for user %s\n"), player_name(player_num, TRUE)); break; case BUILD_BRIDGE: edge = map_edge(callbacks.get_map(), x, y, pos); edge->owner = -1; callbacks.draw_edge(edge); edge->type = BUILD_NONE; log_message(MSG_BUILD, _("%s removed a bridge.\n"), player_name(player_num, TRUE)); if (player_num == my_player_num()) stock_replace_bridge(); break; case BUILD_MOVE_SHIP: /* This clause here to remove a compiler warning. It should not be possible to reach this case. */ g_error("Bug: unreachable code reached"); break; } }