摘要: Today one of my colleague tried to load some text from a file and parse it. It's quit a usual task, but the usual task is unusual today. Let's see the code first.char *data = NULL;FILE *fp;long size;fp = fopen("data.txt", "rt");if (fp){ fseek(fp, 0, SEEK_END); size = ftel 阅读全文
posted @ 2014-03-26 20:55 wane 阅读(249) 评论(0) 推荐(0)
摘要: Today one of my fellow encountered a bug. He was working on a server/client app, the server and client use zlib to compress telegram before sending and after receiving. The programs work fine in debug build, however they failed to send and receive in release build.As a few minutes' investigation 阅读全文
posted @ 2013-12-06 00:04 wane 阅读(205) 评论(0) 推荐(0)
摘要: C++'s header provides many templates to process numeric operations. For example, you can use the templates to easily accumulating items in a vector without using good old for loop. However, if you don't craft your code careful enough, you may end with very hard to debug issues.Consider the f 阅读全文
posted @ 2013-11-15 23:26 wane 阅读(132) 评论(0) 推荐(0)
摘要: Recently, I'm reading a book named 'More Joel On Software', and I'd like to recommend this book. This book is quite interesting, its content covers being a programmer, recurting programmers and even running your own company. The author discussed many things he learned from his experi 阅读全文
posted @ 2013-10-30 21:36 wane 阅读(236) 评论(0) 推荐(0)
摘要: Hit-testing an unregular area is important when you're creating some game UI. Here is a cheap way.When I say cheap, it's extremely fast, and has very tiny memory foot print.Here is the idea:1. Write a program to process the image which represents the unregular area, and produce some binary d 阅读全文
posted @ 2013-10-21 22:26 wane 阅读(229) 评论(0) 推荐(0)
摘要: If you've read my last post about the working unzip code in zlib, you might have already tried that. These days, I am working on some code to pack game assets to a big file. The code worked like a charm on PC. However when I deployed it on iPhone, it's too slow.Our game has more than 3000 as 阅读全文
posted @ 2013-10-20 21:21 wane 阅读(945) 评论(0) 推荐(0)
摘要: Sometimes you may need to access files within a zip archive, like writing an installation program, or packing game contents. You may want to dig into zip file's format (http://www.pkware.com/documents/casestudies/APPNOTE.TXT), and write your own code. However, writing a zip reader from scratch i 阅读全文
posted @ 2013-10-17 22:13 wane 阅读(230) 评论(0) 推荐(0)
摘要: I got a mysterious 'RuntimeLibrary' link error today.We have a main executable project, and a few static library projects. The executable project links against to the static libraries. All the projects' runtime library setting were set to Multi-Thread (/MT). Everything goes well until we 阅读全文
posted @ 2013-10-16 22:18 wane 阅读(329) 评论(0) 推荐(0)
摘要: There're many computer magics. One of my favorite is data compression. When I first meet a compression tool, I found I loved it too much. I tried every settings to compress different files for fun. Nowadays, many open source compression libraries are available. So why not add some compression to 阅读全文
posted @ 2013-10-15 20:57 wane 阅读(162) 评论(0) 推荐(0)
摘要: If you've ever worked as a dev team lead, you may already been bothered by a Project Manager or a Producer. They may come to your desk at the end of some day and ask you for a build. You have to stop what you're doing, and waste hours to prepare the build. You may have many problems, and the 阅读全文
posted @ 2013-10-14 22:31 wane 阅读(179) 评论(0) 推荐(0)