Some final fixed related to combined cross platform socket code

This commit is contained in:
Mark Vejvoda
2010-04-13 07:29:48 +00:00
parent 561dd69107
commit 8c438b812d
11 changed files with 108 additions and 1839 deletions

View File

@@ -147,7 +147,7 @@ Pixmap2D* JPGReader::read(ifstream& is, const string& path, Pixmap2D* ret) const
memcpy(pixels+location,row_pointer[0],cinfo.output_width*cinfo.num_components);
} else {
int r,g,b,a,l;
for (int xPic = 0, xFile = 0; xPic < cinfo.output_width*picComponents; xPic+= picComponents, xFile+= cinfo.num_components) {
for (unsigned int xPic = 0, xFile = 0; xPic < cinfo.output_width*picComponents; xPic+= picComponents, xFile+= cinfo.num_components) {
switch(cinfo.num_components) {
case 3:
r = row_pointer[0][xFile];

View File

@@ -0,0 +1,75 @@
// ==============================================================
// This file is part of Glest Shared Library (www.glest.org)
//
// Copyright (C) 2001-2007 Marti<74>o Figueroa
//
// You can redistribute this code and/or modify it under
// the terms of the GNU General Public License as published
// by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version
// ==============================================================
#include "font.h"
#include "leak_dumper.h"
namespace Shared{ namespace Graphics{
// =====================================================
// class FontMetrics
// =====================================================
FontMetrics::FontMetrics(){
widths= new float[Font::charCount];
height= 0;
for(int i=0; i<Font::charCount; ++i){
widths[i]= 0;
}
}
FontMetrics::~FontMetrics(){
delete [] widths;
}
float FontMetrics::getTextWidth(const string &str) const{
float width= 0.f;
for(unsigned int i=0; i<str.size(); ++i){
width+= widths[str[i]];
}
return width;
}
float FontMetrics::getHeight() const{
return height;
}
// ===============================================
// class Font
// ===============================================
const int Font::charCount= 256;
Font::Font(){
inited= false;
type= "Times New Roman";
width= 400;
}
// ===============================================
// class Font2D
// ===============================================
Font2D::Font2D(){
size= 10;
}
// ===============================================
// class Font3D
// ===============================================
Font3D::Font3D(){
depth= 10.f;
}
}}//end namespace

View File

@@ -177,7 +177,7 @@ void Mesh::loadV3(const string &dir, FILE *f, TextureManager *textureManager){
readBytes = fread(vertices, sizeof(Vec3f)*frameCount*vertexCount, 1, f);
readBytes = fread(normals, sizeof(Vec3f)*frameCount*vertexCount, 1, f);
if(textures[mtDiffuse]!=NULL){
for(int i=0; i<meshHeader.texCoordFrameCount; ++i){
for(unsigned int i=0; i<meshHeader.texCoordFrameCount; ++i){
readBytes = fread(texCoords, sizeof(Vec2f)*vertexCount, 1, f);
}
}
@@ -278,11 +278,11 @@ void Mesh::save(const string &dir, FILE *f){
void Mesh::computeTangents(){
delete [] tangents;
tangents= new Vec3f[vertexCount];
for(int i=0; i<vertexCount; ++i){
for(unsigned int i=0; i<vertexCount; ++i){
tangents[i]= Vec3f(0.f);
}
for(int i=0; i<indexCount; i+=3){
for(unsigned int i=0; i<indexCount; i+=3){
for(int j=0; j<3; ++j){
uint32 i0= indices[i+j];
uint32 i1= indices[i+(j+1)%3];
@@ -306,7 +306,7 @@ void Mesh::computeTangents(){
}
}
for(int i=0; i<vertexCount; ++i){
for(unsigned int i=0; i<vertexCount; ++i){
/*Vec3f binormal= normals[i].cross(tangents[i]);
tangents[i]+= binormal.cross(normals[i]);*/
tangents[i].normalize();
@@ -332,19 +332,19 @@ Model::~Model(){
// ==================== data ====================
void Model::buildInterpolationData() const{
for(int i=0; i<meshCount; ++i){
for(unsigned int i=0; i<meshCount; ++i){
meshes[i].buildInterpolationData();
}
}
void Model::updateInterpolationData(float t, bool cycle) const{
for(int i=0; i<meshCount; ++i){
for(unsigned int i=0; i<meshCount; ++i){
meshes[i].updateInterpolationData(t, cycle);
}
}
void Model::updateInterpolationVertices(float t, bool cycle) const{
for(int i=0; i<meshCount; ++i){
for(unsigned int i=0; i<meshCount; ++i){
meshes[i].updateInterpolationVertices(t, cycle);
}
}

View File

@@ -22,7 +22,6 @@
#include <sys/filio.h>
#endif
#include <net/if.h>
#include "conversion.h"
#include "util.h"
@@ -34,7 +33,7 @@
#include <windows.h>
#include <winsock.h>
#include <iphlpapi.h>
//#include <strstream>
#include <strstream>
#else
@@ -43,7 +42,7 @@
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
//#include <net/if.h>
#include <net/if.h>
//#include <sys/ioctl.h>
#endif
@@ -164,7 +163,7 @@ namespace Shared{ namespace Platform{
// must copy the data from this function before you call it again. It
// follows that this function is also not thread-safe.
const char* WSAGetLastErrorMessage(const char* pcMessagePrefix,
int nErrorID /* = 0 */)
int nErrorID = 0 )
{
// Build basic error string
static char acErrorBuffer[256];
@@ -232,12 +231,12 @@ int getLastSocketError() {
#endif
}
char * getLastSocketErrorText(int *errNumber=NULL) {
const char * getLastSocketErrorText(int *errNumber=NULL) {
int errId = (errNumber != NULL ? *errNumber : getLastSocketError());
#ifndef WIN32
return strerror(errId);
#else
return WSAGetLastErrorMessage(errId);
return WSAGetLastErrorMessage("",errId);
#endif
}
@@ -1680,8 +1679,8 @@ void BroadCastSocketThread::execute() {
char myhostname[100]; // hostname of local machine
char subnetmask[MAX_NIC_COUNT][100]; // Subnet mask to broadcast to
struct hostent* myhostent;
char * ptr; // some transient vars
int len,i;
//char * ptr; // some transient vars
//int len,i;
/* get my host name */
gethostname(myhostname,100);

File diff suppressed because it is too large Load Diff