(svn r26057) -Fix: a number of possibly uninitialised variables

pull/155/head
rubidium 11 years ago
parent bebf2291db
commit 73474728e3

@ -35,6 +35,9 @@ DEFINE_POOL_METHOD(inline)::Pool(const char *name) :
first_free(0),
first_unused(0),
items(0),
#ifdef OTTD_ASSERT
checked(0),
#endif /* OTTD_ASSERT */
cleaning(false),
data(NULL),
alloc_cache(NULL)

@ -41,7 +41,8 @@ struct LoadCheckData {
struct LoggedAction *gamelog_action; ///< Gamelog actions
uint gamelog_actions; ///< Number of gamelog actions
LoadCheckData() : error_data(NULL), grfconfig(NULL), gamelog_action(NULL)
LoadCheckData() : error_data(NULL), grfconfig(NULL),
grf_compatibility(GLC_NOT_FOUND), gamelog_action(NULL), gamelog_actions(0)
{
this->Clear();
}

@ -46,9 +46,11 @@ static void ReadHeightmapPNGImageData(byte *map, png_structp png_ptr, png_infop
uint x, y;
byte gray_palette[256];
png_bytep *row_pointers = NULL;
bool has_palette = png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE;
uint channels = png_get_channels(png_ptr, info_ptr);
/* Get palette and convert it to grayscale */
if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE) {
if (has_palette) {
int i;
int palette_size;
png_color *palette;
@ -79,11 +81,11 @@ static void ReadHeightmapPNGImageData(byte *map, png_structp png_ptr, png_infop
for (x = 0; x < png_get_image_width(png_ptr, info_ptr); x++) {
for (y = 0; y < png_get_image_height(png_ptr, info_ptr); y++) {
byte *pixel = &map[y * png_get_image_width(png_ptr, info_ptr) + x];
uint x_offset = x * png_get_channels(png_ptr, info_ptr);
uint x_offset = x * channels;
if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE) {
if (has_palette) {
*pixel = gray_palette[row_pointers[y][x_offset]];
} else if (png_get_channels(png_ptr, info_ptr) == 3) {
} else if (channels == 3) {
*pixel = RGBToGrayscale(row_pointers[y][x_offset + 0],
row_pointers[y][x_offset + 1], row_pointers[y][x_offset + 2]);
} else {

@ -26,7 +26,7 @@
* Create a new socket for the game connection.
* @param s The socket to connect with.
*/
NetworkGameSocketHandler::NetworkGameSocketHandler(SOCKET s) : info(NULL),
NetworkGameSocketHandler::NetworkGameSocketHandler(SOCKET s) : info(NULL), client_id(INVALID_CLIENT_ID),
last_frame(_frame_counter), last_frame_server(_frame_counter), last_packet(_realtime_tick)
{
this->sock = s;

@ -155,9 +155,9 @@ bool IsNetworkCompatibleVersion(const char *version);
*/
struct CommandPacket : CommandContainer {
/** Make sure the pointer is NULL. */
CommandPacket() : next(NULL) {}
CommandPacket() : next(NULL), company(INVALID_COMPANY), frame(0), my_cmd(false) {}
CommandPacket *next; ///< the next command packet (if in queue)
CompanyByte company; ///< company that is executing the command
CompanyID company; ///< company that is executing the command
uint32 frame; ///< the frame in which this packet is executed
bool my_cmd; ///< did the command originate from "me"
};

@ -226,7 +226,8 @@ GRFParameterInfo::GRFParameterInfo(uint nr) :
def_value(0),
param_nr(nr),
first_bit(0),
num_bit(32)
num_bit(32),
complete_labels(false)
{}
/**

@ -882,7 +882,7 @@ struct TextRefStack {
byte position;
bool used;
TextRefStack() : used(false) {}
TextRefStack() : position(0), used(false) {}
TextRefStack(const TextRefStack &stack) :
position(stack.position),

@ -349,8 +349,10 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
{
Order order;
order.next = NULL;
/* Hack-ish; unpack order 0, so everything gets initialised with either zero
* or a suitable default value for the variable. Then also override the index
* as it is not coming from a pool, so would be initialised. */
Order order(0);
order.index = 0;
/* check depot first */

@ -241,7 +241,7 @@ std::list<CargoPacket *> _packets;
uint32 _num_dests;
struct FlowSaveLoad {
FlowSaveLoad() : via(0), share(0) {}
FlowSaveLoad() : source(0), via(0), share(0), restricted(false) {}
StationID source;
StationID via;
uint32 share;

@ -32,6 +32,7 @@ static const int MAX_GET_SETTING_OPS = 100000;
class ScriptInfo : public SimpleCountedObject {
public:
ScriptInfo() :
engine(NULL),
SQ_instance(NULL),
main_script(NULL),
tar_file(NULL),

@ -49,6 +49,7 @@ static void PrintFunc(bool error_msg, const SQChar *message)
ScriptInstance::ScriptInstance(const char *APIName) :
engine(NULL),
versionAPI(NULL),
controller(NULL),
storage(NULL),
instance(NULL),

@ -76,6 +76,9 @@ public:
new_vehicle_id (0),
new_sign_id (0),
new_group_id (0),
new_goal_id (0),
new_story_page_id (0),
new_story_page_element_id(0),
/* calback_value (can't be set) */
road_type (INVALID_ROADTYPE),
rail_type (INVALID_RAILTYPE),

@ -206,6 +206,7 @@ struct GoodsEntry {
rating(INITIAL_STATION_RATING),
last_speed(0),
last_age(255),
amount_fract(0),
link_graph(INVALID_LINK_GRAPH),
node(INVALID_NODE),
max_waiting_cargo(0)

Loading…
Cancel
Save