Aller au contenu
Thorkildor

Erreur compilation client TeamFE

Messages recommandés

Version des files : Team FE 2.0

Domaine (Base de données, Core, etc.) : Compilation client

Votre niveau (débutant, intermédiaire, avancé) : Intermédiaire

 

Bonjour,

 

J'ai suivi un tutoriel expliquant comment compiler le lanceur, j'ai modifié les liens include et lib par les bons.

 

Lorsque je compile j'ai 13 errreurs :

 

'data':ambigous eterlib symbol | eterlib | JpegFile.cpp | 216

'size':ambigous eterlib symbol | eterlib | JpegFile.cpp | 217

'size':ambigous eterlib symbol | eterlib | JpegFile.cpp | 224

'size':ambigous eterlib symbol | eterlib | JpegFile.cpp | 231

'size':ambigous eterlib symbol | eterlib | JpegFile.cpp | 241

'data':ambigous eterlib symbol | eterlib | JpegFile.cpp | 242

'size':ambigous eterlib symbol | eterlib | JpegFile.cpp | 243

'data':ambigous eterlib symbol | eterlib | JpegFile.cpp | 261

'size':ambigous eterlib symbol | eterlib | JpegFile.cpp | 262

'data':ambigous eterlib symbol | eterlib | JpegFile.cpp | 266

'size':ambigous eterlib symbol | eterlib | JpegFile.cpp | 267

'back_inserter':is not a member of 'std' | UserInterface |MarkManager.cpp | 399

 

'back_inserter' identifier not found | UserInterface | MarkManager.cpp | 399

 

J'ai trouvé un sujet sur un autre forum disant de rajouter

 

#include

#include

#include

 

Aucune erreur ne disparaît.

 

Voici le JpegFile.cpp

#include "StdAfx.h"
#include "JpegFile.h"
#include 
#include 
#include 

#include 
#include 

#define OUTBUFFER_SIZE 0x8000

static FILE*fi;
static JOCTET * buffer;
static unsigned char*dest;
static int len;
static int destlen;
static unsigned char*data;
static int pos;
static int size;

static void file_init_destination(j_compress_ptr cinfo) 
{ 
  struct jpeg_destination_mgr*dmgr = 
      (struct jpeg_destination_mgr*)(cinfo->dest);
  buffer = (JOCTET*)malloc(OUTBUFFER_SIZE);
  if(!buffer) {
      perror("malloc");
      printf("Out of memory!\n");
      exit(1);
  }
  dmgr->next_output_byte = buffer;
  dmgr->free_in_buffer = OUTBUFFER_SIZE;
}

static boolean file_empty_output_buffer(j_compress_ptr cinfo)
{ 
  struct jpeg_destination_mgr*dmgr = 
      (struct jpeg_destination_mgr*)(cinfo->dest);
  if(fi)
    fwrite(buffer, OUTBUFFER_SIZE, 1, fi);
  dmgr->next_output_byte = buffer;
  dmgr->free_in_buffer = OUTBUFFER_SIZE;
  return 1;
}

static void file_term_destination(j_compress_ptr cinfo) 
{ struct jpeg_destination_mgr*dmgr = 
      (struct jpeg_destination_mgr*)(cinfo->dest);
  if(fi)
    fwrite(buffer, OUTBUFFER_SIZE-dmgr->free_in_buffer, 1, fi);
  free(buffer);
  buffer = 0;
  dmgr->free_in_buffer = 0;
}

static void mem_init_destination(j_compress_ptr cinfo) 
{ 
  struct jpeg_destination_mgr*dmgr = 
      (struct jpeg_destination_mgr*)(cinfo->dest);
  dmgr->next_output_byte = dest;
  dmgr->free_in_buffer = destlen;
}

static boolean mem_empty_output_buffer(j_compress_ptr cinfo)
{ 
    printf("jpeg mem overflow!\n");
    exit(1);
}

static void mem_term_destination(j_compress_ptr cinfo) 
{ 
  struct jpeg_destination_mgr*dmgr = 
      (struct jpeg_destination_mgr*)(cinfo->dest);
  len = destlen - dmgr->free_in_buffer;
  dmgr->free_in_buffer = 0;
}

int jpeg_save(unsigned char*data, int width, int height, int quality, const char*filename)
{
  struct jpeg_destination_mgr mgr;
  struct jpeg_compress_struct cinfo;
  struct jpeg_error_mgr jerr;
  int t;

  if(filename) {
    fi = fopen(filename, "wb");
    if(fi == NULL)
        return 0;
  } else
    fi = NULL;

  memset(&cinfo, 0, sizeof(cinfo));
  memset(&jerr, 0, sizeof(jerr));
  memset(&mgr, 0, sizeof(mgr));
  cinfo.err = jpeg_std_error(&jerr);
  jpeg_create_compress(&cinfo);

  mgr.init_destination = file_init_destination;
  mgr.empty_output_buffer = file_empty_output_buffer;
  mgr.term_destination = file_term_destination;
  cinfo.dest = &mgr;

  // init compression
  
  cinfo.image_width  = width;
  cinfo.image_height = height;
  cinfo.input_components = 3;
  cinfo.in_color_space = JCS_RGB;
  jpeg_set_defaults(&cinfo);
  jpeg_set_quality(&cinfo,quality,TRUE);

  //jpeg_write_tables(&cinfo);
  //jpeg_suppress_tables(&cinfo, TRUE);
  jpeg_start_compress(&cinfo, FALSE);
  
  for(t=0;t    unsigned char*data2 = &data[width*3*t];
    jpeg_write_scanlines(&cinfo, &data2, 1);
  }
  jpeg_finish_compress(&cinfo);

  if(fi)
    fclose(fi);
  jpeg_destroy_compress(&cinfo);
  return 1;
}

int jpeg_save_to_file(unsigned char*data, int width, int height, int quality, FILE*_fi)
{
  struct jpeg_destination_mgr mgr;
  struct jpeg_compress_struct cinfo;
  struct jpeg_error_mgr jerr;
  int t;

  fi = _fi;

  memset(&cinfo, 0, sizeof(cinfo));
  memset(&jerr, 0, sizeof(jerr));
  memset(&mgr, 0, sizeof(mgr));
  cinfo.err = jpeg_std_error(&jerr);
  jpeg_create_compress(&cinfo);

  mgr.init_destination = file_init_destination;
  mgr.empty_output_buffer = file_empty_output_buffer;
  mgr.term_destination = file_term_destination;
  cinfo.dest = &mgr;

  // init compression
  
  cinfo.image_width  = width;
  cinfo.image_height = height;
  cinfo.input_components = 3;
  cinfo.in_color_space = JCS_RGB;
  jpeg_set_defaults(&cinfo);
  cinfo.dct_method = JDCT_IFAST;
  jpeg_set_quality(&cinfo,quality,TRUE);

  //jpeg_write_tables(&cinfo);
  //jpeg_suppress_tables(&cinfo, TRUE);
  jpeg_start_compress(&cinfo, FALSE);
  
  for(t=0;t    unsigned char*data2 = &data[width*3*t];
    jpeg_write_scanlines(&cinfo, &data2, 1);
  }
  jpeg_finish_compress(&cinfo);
  jpeg_destroy_compress(&cinfo);
  return 1;
}

int jpeg_save_to_mem(unsigned char*data, int width, int height, int quality, unsigned char*_dest, int _destlen)
{
  struct jpeg_destination_mgr mgr;
  struct jpeg_compress_struct cinfo;
  struct jpeg_error_mgr jerr;
  int t;

  memset(&cinfo, 0, sizeof(cinfo));
  memset(&jerr, 0, sizeof(jerr));
  memset(&mgr, 0, sizeof(mgr));
  cinfo.err = jpeg_std_error(&jerr);
  jpeg_create_compress(&cinfo);

  dest = _dest;
  len = 0;
  destlen = _destlen;

  mgr.init_destination = mem_init_destination;
  mgr.empty_output_buffer = mem_empty_output_buffer;
  mgr.term_destination = mem_term_destination;
  cinfo.dest = &mgr;

  // init compression
  
  cinfo.image_width  = width;
  cinfo.image_height = height;
  cinfo.input_components = 3;
  cinfo.in_color_space = JCS_RGB;
  jpeg_set_defaults(&cinfo);
  cinfo.dct_method = JDCT_IFAST;
  jpeg_set_quality(&cinfo,quality,TRUE);

  jpeg_start_compress(&cinfo, FALSE);
  for(t=0;t    unsigned char*data2 = &data[width*3*t];
    jpeg_write_scanlines(&cinfo, &data2, 1);
  }
  jpeg_finish_compress(&cinfo);
  jpeg_destroy_compress(&cinfo);
  return len;
}

void mem_init_source (j_decompress_ptr cinfo)
{
    struct jpeg_source_mgr* mgr = cinfo->src;
    mgr->next_input_byte = data;
    mgr->bytes_in_buffer = size;
    //printf("init %d\n", size - mgr->bytes_in_buffer);
}

boolean mem_fill_input_buffer (j_decompress_ptr cinfo)
{
    struct jpeg_source_mgr* mgr = cinfo->src;
    printf("fill %d\n", size - mgr->bytes_in_buffer);
    return 0;
}

void mem_skip_input_data (j_decompress_ptr cinfo, long num_bytes)
{
    struct jpeg_source_mgr* mgr = cinfo->src;
    printf("skip %d +%d\n", size - mgr->bytes_in_buffer, num_bytes);
    if(num_bytes<=0)
    return;
    mgr->next_input_byte += num_bytes;
    mgr->bytes_in_buffer -= num_bytes;
}

boolean mem_resync_to_restart (j_decompress_ptr cinfo, int desired)
{
    struct jpeg_source_mgr* mgr = cinfo->src;
    printf("resync %d\n", size - mgr->bytes_in_buffer);
    mgr->next_input_byte = data;
    mgr->bytes_in_buffer = size;
    return 1;
}

void mem_term_source (j_decompress_ptr cinfo)
{
    struct jpeg_source_mgr* mgr = cinfo->src;
    //printf("term %d\n", size - mgr->bytes_in_buffer);
}

int jpeg_load_from_mem(unsigned char*_data, int _size, unsigned char*dest, int width, int height)
{
    struct jpeg_decompress_struct cinfo;
    struct jpeg_error_mgr jerr;
    struct jpeg_source_mgr mgr;
    int y;
    //int x;

    data = _data;
    size = _size;

    jpeg_create_decompress(&cinfo); 

    mgr.next_input_byte = data;
    mgr.bytes_in_buffer = size;
    mgr.init_source        =mem_init_source ;
    mgr.fill_input_buffer  =mem_fill_input_buffer ;
    mgr.skip_input_data    =mem_skip_input_data ;
    mgr.resync_to_restart  =mem_resync_to_restart ;
    mgr.term_source        =mem_term_source ;

    cinfo.err = jpeg_std_error(&jerr);
    cinfo.src = &mgr;

    jpeg_read_header(&cinfo, TRUE);
    jpeg_start_decompress(&cinfo);

    for(y=0;y    unsigned char*j = &dest[width*y*3];
    jpeg_read_scanlines(&cinfo,&j,1);
    }

    jpeg_finish_decompress(&cinfo);
    jpeg_destroy_decompress(&cinfo);
    return 1;
}

typedef struct _RGBA {
    unsigned char a,r,g,b;
} RGBA;

typedef unsigned char U8;

int jpeg_load(const char*filename, unsigned char**dest, int*_width, int*_height)
{
    struct jpeg_decompress_struct cinfo;
    struct jpeg_error_mgr jerr;
    //struct jpeg_source_mgr mgr;

    FILE*fi = fopen(filename, "rb");
    if(!fi) {
        fprintf(stderr, "Couldn't open file %s\n", filename);
    return 0;
    }

    cinfo.err = jpeg_std_error(&jerr);
    jpeg_create_decompress(&cinfo); 
    jpeg_stdio_src(&cinfo, fi);
    jpeg_read_header(&cinfo, TRUE);
    jpeg_start_decompress(&cinfo);
    
    U8*scanline = (U8 *)malloc(4 * cinfo.output_width);

    int width = *_width = cinfo.output_width;
    int height = *_height = cinfo.output_height;
    *dest = (unsigned char*)malloc(width*height*4);

    int y;
    for (y=0;y    int x;
    U8 *js = scanline;
        RGBA*line = &((RGBA*)(*dest))[y*width];

    jpeg_read_scanlines(&cinfo, &js, 1);
    if (cinfo.out_color_space == JCS_GRAYSCALE) {
        for (x = 0; x < width; x++) {
        line[x].a = 255;
        line[x].r = line[x].g = line[x].b = js[x];
        }
    } else if (cinfo.out_color_space == JCS_RGB) {
        for (x = width - 1; x >= 0; x--) {
        line[x].a = 255;
        line[x].r = js[x*3+0];
        line[x].g = js[x*3+1];
        line[x].b = js[x*3+2];
        }
    } else if (cinfo.out_color_space == JCS_YCCK) {
        fprintf(stderr, "Error: Can't convert YCCK to RGB.\n");
        return 0;
    } else if (cinfo.out_color_space == JCS_YCbCr) {
        for (x = 0; x < width; x++) {
        int y = js[x * 3 + 0];
        int u = js[x * 3 + 1];
        int v = js[x * 3 + 1];
        line[x].a = 255;
        line[x].r = y + ((360 * (v - 128)) >> 8);
        line[x].g = y - ((88 * (u - 128) + 183 * (v - 128)) >> 8);
        line[x].b = y + ((455 * (u - 128)) >> 8);
        }
    } else if (cinfo.out_color_space == JCS_CMYK) {
        for (x = 0; x < width; x++) {
        int white = 255 - js[x * 4 + 3];
        line[x].a = 255;
        line[x].r = white - ((js[x * 4] * white) >> 8);
        line[x].g = white - ((js[x * 4 + 1] * white) >> 8);
        line[x].b = white - ((js[x * 4 + 2] * white) >> 8);
        }
    }
    }

    free(scanline);

    jpeg_finish_decompress(&cinfo);
    jpeg_destroy_decompress(&cinfo);
    fclose(fi);
    return 1;
}

 

 

Contenu du MarkManager.cpp avec l'ajout des lignes citées plus haut

#include 
#include 
#include 
#include "stdafx.h"
#include "MarkManager.h"

#if _MSC_VER < 1200
#include "crc32.h"
#else
#define sys_err TraceError
#define sys_log // (n, format, ...) Tracenf(format, __VA_ARGS__)
#define thecore_memcpy memcpy
#define itertype(cont) typeof((cont).begin())
#endif

CGuildMarkImage * CGuildMarkManager::__NewImage()
{
    return new CGuildMarkImage;
}

void CGuildMarkManager::__DeleteImage(CGuildMarkImage * pkImgDel)
{
    delete pkImgDel;
}

CGuildMarkManager::CGuildMarkManager()
{
#if _MSC_VER >= 1200
    mkdir("mark");
#endif
    // 남은 mark id 셋을 만든다. (서버용)
    for (DWORD i = 0; i < MAX_IMAGE_COUNT * CGuildMarkImage::MARK_TOTAL_COUNT; ++i)
        m_setFreeMarkID.insert(i);
}

CGuildMarkManager::~CGuildMarkManager()
{
    for (std::map::iterator it = m_mapIdx_Image.begin(); it != m_mapIdx_Image.end(); ++it)
        __DeleteImage(it->second);

    m_mapIdx_Image.clear();
}

bool CGuildMarkManager::GetMarkImageFilename(DWORD imgIdx, std::string & path) const
{
    if (imgIdx >= MAX_IMAGE_COUNT)
        return false;

    char buf[64];
    snprintf(buf, sizeof(buf), "mark/%s_%lu.tga", m_pathPrefix.c_str(), imgIdx);
    path = buf;
    return true;
}

void CGuildMarkManager::SetMarkPathPrefix(const char * prefix)
{
    m_pathPrefix = prefix;
}

// 마크 인덱스 불러오기 (서버에서만 사용)
bool CGuildMarkManager::LoadMarkIndex()
{
    char buf[64];
    snprintf(buf, sizeof(buf), "mark/%s_index", m_pathPrefix.c_str());
    FILE * fp = fopen(buf, "r");

    if (!fp)
        return false;

    DWORD guildID;
    DWORD markID;

    char line[256];

    while (fgets(line, sizeof(line)-1, fp))
    {
        sscanf(line, "%lu %lu", &guildID, &markID);
        line[0] = '\0';
        AddMarkIDByGuildID(guildID, markID);
    }

    LoadMarkImages();

    fclose(fp);
    return true;
}

bool CGuildMarkManager::SaveMarkIndex()
{
    char buf[64];
    snprintf(buf, sizeof(buf), "mark/%s_index", m_pathPrefix.c_str());
    FILE * fp = fopen(buf, "w");

    if (!fp)
    {
        sys_err("MarkManager::SaveMarkData: cannot open index file.");
        return false;
    }

    for (std::map::iterator it = m_mapGID_MarkID.begin(); it != m_mapGID_MarkID.end(); ++it)
        fprintf(fp, "%d %d\n", it->first, it->second);

    fclose(fp);
    sys_log(0, "MarkManager::SaveMarkData: index count %d", m_mapGID_MarkID.size());
    return true;
}

void CGuildMarkManager::LoadMarkImages()
{
    bool isMarkExists[MAX_IMAGE_COUNT];
    memset(isMarkExists, 0, sizeof(isMarkExists));

    for (std::map::iterator it = m_mapGID_MarkID.begin(); it != m_mapGID_MarkID.end(); ++it)
    {
        DWORD markID = it->second;

        if (markID < MAX_IMAGE_COUNT * CGuildMarkImage::MARK_TOTAL_COUNT)
            isMarkExists[markID / CGuildMarkImage::MARK_TOTAL_COUNT] = true;
    }

    for (DWORD i = 0; i < MAX_IMAGE_COUNT; ++i)
        if (isMarkExists[i])
            __GetImage(i);
}

void CGuildMarkManager::SaveMarkImage(DWORD imgIdx)
{
    std::string path;

    if (GetMarkImageFilename(imgIdx, path))
        if (!__GetImage(imgIdx)->Save(path.c_str()))
            sys_err("%s Save failed\n", path.c_str());
}

CGuildMarkImage * CGuildMarkManager::__GetImage(DWORD imgIdx)
{
    std::map::iterator it = m_mapIdx_Image.find(imgIdx);

    if (it == m_mapIdx_Image.end())
    {
        std::string imagePath;

        if (GetMarkImageFilename(imgIdx, imagePath))
        {
            CGuildMarkImage * pkImage = __NewImage();
            m_mapIdx_Image.insert(std::map::value_type(imgIdx, pkImage));
            pkImage->Load(imagePath.c_str());
            return pkImage;
        }
        else
            return NULL;
    }
    else
        return it->second;
}

bool CGuildMarkManager::AddMarkIDByGuildID(DWORD guildID, DWORD markID)
{
    if (markID >= MAX_IMAGE_COUNT * CGuildMarkImage::MARK_TOTAL_COUNT)
        return false;

    //sys_log(0, "MarkManager: guild_id=%d mark_id=%d", guildID, markID);
    m_mapGID_MarkID.insert(std::map::value_type(guildID, markID));
    m_setFreeMarkID.erase(markID);
    return true;
}

DWORD CGuildMarkManager::GetMarkID(DWORD guildID)
{
    std::map::iterator it = m_mapGID_MarkID.find(guildID);

    if (it == m_mapGID_MarkID.end())
        return INVALID_MARK_ID;

    return it->second;
}

DWORD CGuildMarkManager::__AllocMarkID(DWORD guildID)
{
    std::set::iterator it = m_setFreeMarkID.lower_bound(0);

    if (it == m_setFreeMarkID.end())
        return INVALID_MARK_ID;

    DWORD markID = *it;
    
    DWORD imgIdx = markID / CGuildMarkImage::MARK_TOTAL_COUNT;
    CGuildMarkImage * pkImage = __GetImage(imgIdx); // 이미지가 없다면 만들기 위해 

    if (pkImage && AddMarkIDByGuildID(guildID, markID))
        return markID;

    return INVALID_MARK_ID;
}

DWORD CGuildMarkManager::GetMarkImageCount() const
{
    return m_mapIdx_Image.size();
}

DWORD CGuildMarkManager::GetMarkCount() const
{
    return m_mapGID_MarkID.size();
}

// SERVER
void CGuildMarkManager::CopyMarkIdx(char * pcBuf) const
{
    WORD * pwBuf = (WORD *) pcBuf;

    for (std::map::const_iterator it = m_mapGID_MarkID.begin(); it != m_mapGID_MarkID.end(); ++it)
    {
        *(pwBuf++) = it->first; // guild id
        *(pwBuf++) = it->second; // mark id
    }
}

// SERVER
DWORD CGuildMarkManager::SaveMark(DWORD guildID, BYTE * pbMarkImage)
{
    DWORD idMark;

    if ((idMark = GetMarkID(guildID)) == INVALID_MARK_ID)
    {
        if ((idMark = __AllocMarkID(guildID)) == INVALID_MARK_ID)
        {
            sys_err("CGuildMarkManager: cannot alloc mark id %u", guildID);
            return false;
        }
        else
            sys_log(0, "SaveMark: mark id alloc %u", idMark);
    }
    else
        sys_log(0, "SaveMark: mark id found %u", idMark);

    DWORD imgIdx = (idMark / CGuildMarkImage::MARK_TOTAL_COUNT);
    CGuildMarkImage * pkImage = __GetImage(imgIdx);

    if (pkImage)
    {
        printf("imgidx %u ", imgIdx);

        std::string pathImage;
        GetMarkImageFilename(imgIdx, pathImage);
        pkImage->Save(pathImage.c_str());

        SaveMarkIndex();
    }

    return idMark;
}

// SERVER
void CGuildMarkManager::DeleteMark(DWORD guildID)
{
    std::map::iterator it = m_mapGID_MarkID.find(guildID);

    if (it == m_mapGID_MarkID.end())
        return;

    CGuildMarkImage * pkImage;

    if ((pkImage = __GetImage(it->second / CGuildMarkImage::MARK_TOTAL_COUNT)) != NULL)
        pkImage->DeleteMark(it->second % CGuildMarkImage::MARK_TOTAL_COUNT);

    m_mapGID_MarkID.erase(it);
    m_setFreeMarkID.insert(it->second);

    SaveMarkIndex();
}

// SERVER
void CGuildMarkManager::GetDiffBlocks(DWORD imgIdx, const DWORD * crcList, std::map & mapDiffBlocks)
{
    mapDiffBlocks.clear();

    // 클라이언트에서 서버에 없는 이미지를 요청할 수는 없다.
    if (m_mapIdx_Image.end() == m_mapIdx_Image.find(imgIdx))
    {
        sys_err("invalid idx %u", imgIdx);
        return;
    }

    CGuildMarkImage * p = __GetImage(imgIdx);

    if (p)
        p->GetDiffBlocks(crcList, mapDiffBlocks);
}

// CLIENT
bool CGuildMarkManager::SaveBlockFromCompressedData(DWORD imgIdx, DWORD posBlock, const BYTE * pbBlock, DWORD dwSize)
{
    CGuildMarkImage * pkImage = __GetImage(imgIdx);

    if (pkImage)
        pkImage->SaveBlockFromCompressedData(posBlock, pbBlock, dwSize);

    return false;
}

// CLIENT
bool CGuildMarkManager::GetBlockCRCList(DWORD imgIdx, DWORD * crcList)
{
    // 클라이언트에서 서버에 없는 이미지를 요청할 수는 없다.
    if (m_mapIdx_Image.end() == m_mapIdx_Image.find(imgIdx))
    {
        sys_err("invalid idx %u", imgIdx);
        return false;
    }

    CGuildMarkImage * p = __GetImage(imgIdx);
    
    if (p)
        p->GetBlockCRCList(crcList);

    return true;
}

///////////////////////////////////////////////////////////////////////////////////////
// Symbol
///////////////////////////////////////////////////////////////////////////////////////
const CGuildMarkManager::TGuildSymbol * CGuildMarkManager::GetGuildSymbol(DWORD guildID)
{
    std::map::iterator it = m_mapSymbol.find(guildID);

    if (it == m_mapSymbol.end())
        return NULL;

    return &it->second;
}

bool CGuildMarkManager::LoadSymbol(const char* filename)
{
    FILE* fp = fopen(filename, "rb");

    if (!fp)
        return true;
    else
    {
        DWORD symbolCount;
        fread(&symbolCount, 4, 1, fp);

        for(DWORD i = 0; i < symbolCount; i++)
        {
            DWORD guildID;
            DWORD dwSize;
            fread(&guildID, 4, 1, fp);
            fread(&dwSize, 4, 1, fp);

            TGuildSymbol gs;
            gs.raw.resize(dwSize);
            fread(&gs.raw[0], 1, dwSize, fp);
            gs.crc = GetCRC32(reinterpret_cast(&gs.raw[0]), dwSize);
            m_mapSymbol.insert(std::make_pair(guildID, gs));
        }
    }

    fclose(fp);
    return true;
}

void CGuildMarkManager::SaveSymbol(const char* filename)
{
    FILE* fp = fopen(filename, "wb");
    if (!fp)
    {
        sys_err("Cannot open Symbol file (name: %s)", filename);
        return;
    }

    DWORD symbolCount = m_mapSymbol.size();
    fwrite(&symbolCount, 4, 1, fp);

    for (std::map::iterator it = m_mapSymbol.begin(); it != m_mapSymbol.end(); ++it)
    {
        DWORD guildID = it->first;
        DWORD dwSize = it->second.raw.size();
        fwrite(&guildID, 4, 1, fp);
        fwrite(&dwSize, 4, 1, fp);
        fwrite(&it->second.raw[0], 1, dwSize, fp);
    }

    fclose(fp);
}

void CGuildMarkManager::UploadSymbol(DWORD guildID, int iSize, const BYTE* pbyData)
{
    sys_log(0, "GuildSymbolUpload guildID %lu Size %d", guildID, iSize);
    
    if (m_mapSymbol.find(guildID) == m_mapSymbol.end())
        m_mapSymbol.insert(std::make_pair(guildID, TGuildSymbol()));

    TGuildSymbol& rSymbol = m_mapSymbol[guildID];
    rSymbol.raw.clear();

    if (iSize > 0)
    {
        rSymbol.raw.reserve(iSize);
        std::copy(pbyData, (pbyData + iSize), std::back_inserter(rSymbol.raw));
        rSymbol.crc = GetCRC32(reinterpret_cast(pbyData), iSize);
    }
}

#ifdef __UNITTEST__
#include "lzo_manager.h"

Guild::CGuildMarkManager * mgr;

void heartbeat(LPHEART ht, int pulse)
{
    return;
}

void SaveMark(DWORD guildID, const char * filename)
{
    ILuint m_uImg;

    ilGenImages(1, &m_uImg);
    ilBindImage(m_uImg);
    ilEnable(IL_ORIGIN_SET);
    ilOriginFunc(IL_ORIGIN_UPPER_LEFT);

    if (ilLoad(IL_TYPE_UNKNOWN, (const ILstring) filename))
    {
        ILuint width = ilGetInteger(IL_IMAGE_WIDTH);
        ILuint height = ilGetInteger(IL_IMAGE_HEIGHT);

        ilConvertImage(IL_BGRA, IL_UNSIGNED_BYTE);

        BYTE * data = (BYTE *) malloc(sizeof(DWORD) * width * height);
        ilCopyPixels(0, 0, 0, width, height, 1, IL_BGRA, IL_UNSIGNED_BYTE, data);
        ilDeleteImages(1, &m_uImg);

        printf("%s w%u h%u ", filename, width, height);
        mgr->SaveMark(guildID, data);
    }
    else
        printf("%s cannot open file.\n", filename);
}

int main(int argc, char **argv)
{
    LZOManager lzo;
    char f[64];

    srandom(time(0));

    ilInit(); // DevIL Initialize
    thecore_init(25, heartbeat);

    std::vector vec_guild_id;

    for (int i = 1; i < 1281; ++i)
        vec_guild_id.push_back(i);

    mgr = new CGuildMarkManager;
    mgr->LoadMarkData(vec_guild_id);
    /*
    for (int i = 1401; i < 1500; ++i)
    {
        snprintf(f, sizeof(f), "%lu.jpg", (random() % 5) + 1);
        //SaveMark(i, f);
        mgr->DeleteMark(i);
    }
    */
    //snprintf(f, sizeof(f), "%lu.jpg", (random() % 5) + 1);
    //SaveMark(1, f);
    DWORD idx_client[CGuildMarkImage::BLOCK_TOTAL_COUNT];
    DWORD idx_server[CGuildMarkImage::BLOCK_TOTAL_COUNT];

    mgr->GetBlockCRCList(0, idx_client);
    mgr->GetBlockCRCList(1, idx_server);

    std::map mapDiff;
    mgr->GetDiffBlocks(1, idx_client, mapDiff);

    printf("#1 Diff %u\n", mapDiff.size());

    for (itertype(mapDiff) it = mapDiff.begin(); it != mapDiff.end(); ++it)
    {
        printf("Put Block pos %u crc %u\n", it->first, it->second->m_crc);
        mgr->SaveBlockFromCompressedData(0, it->first, it->second->m_abCompBuf, it->second->m_sizeCompBuf);
    }

    mgr->GetBlockCRCList(0, idx_client);
    mgr->GetDiffBlocks(1, idx_client, mapDiff);
    printf("#2 Diff %u\n", mapDiff.size());
    delete mgr;
    return 1;
}
#endif

 

 

 

 

En postant ma demande d'aide, j'affirme avoir lu et accepté le règlement des demandes d'aides.

Partager ce message


Lien à poster
Partager sur d’autres sites
Invité
Ce sujet ne peut plus recevoir de nouvelles réponses.

A propos de nous

Funky-Emulation

© Funky Emulation est un forum d'entraide à l'émulation de différents jeux vidéo comme Metin 2, Dofus, World of Warcraft.

Rejoignez une communauté soudée et sympathique.

Réseaux Sociaux

Partenaires

Top Paradise

×

Information importante

By using this site, you agree to our Conditions d’utilisation.