UDP 打洞

NAT Punchthrough overview
What is NAT?

NAT is short for network address translation. It is used by routers to map addresses behind the router to a single destination address, using different ports. For example, if you have two computers behind a router, but only one ISP, then both computers will use the same IP address, but with different source ports than what the application actually assigned. The router keeps a lookup table of what mappings it provides, so when a remote computer replies it is routed to the correct local computer behind the NAT.
继续阅读“UDP 打洞”

c# PINVOKE传递bool类型的注意事项

自己c++代码传递的明明是false,到了c#却变成了true。虽然明知错误发生在参数传递的过程中,却是很难找到原因。

c语言中的bool类型是整数(4个字节),c++中是一个字节,pinvoke 中 bool 默认是4个字节。所以c++代码调用c#函数时,传递bool类型就会出现错误。

方法也很简单,在c++中声明函数时,用int来代替bool。c#代码不用修改,代码就能正常运行了。

游戏中的AOI

前言

AOI(area of interest),它是MMO游戏中一个极其重要的概念,主要解决游戏中多人同屏的问题。本文并不打算去讲AOI相关的算法,如九宫格,十字链表,六边形网格之类的具体算法实现,因为此类文章网络上已经有很多了。虽然大多数开发者都接触过AOI,但是我发现其中很多人并没有真正深入领会AOI的本质。因此本文会从设计的角度来阐释什么是AOI,为什么要有AOI,以及如何去设计一个高质量的AOI系统。

继续阅读“游戏中的AOI”

游戏平衡概念-数字关系(2):

本周主题

This week, I’m going to talk about the different kinds of numbers you see in games and how to classify them. This is going to be important later, because you can’t really know how to balance a game or how to choose the right numbers unless you first know what kinds of numbers you’re dealing with. Sometimes, a balance change is as simple as replacing one kind of number with another, so understanding what kinds of numbers there are and getting an intuition for how they work is something we need to cover before anything else.

这个星期,我将谈论你在游戏中看到的不同类型的数字,以及如何对它们进行分类。这在以后会变得很重要,因为你不能真正知道如何平衡一个游戏或者如何选择正确的数字,除非你首先知道你在处理什么类型的数字。有时候,平衡的改变就像用一种数字替换另一种数字一样简单,所以我们需要在其他任何事情之前了解这些数字的种类,并对它们的工作原理有一个直觉。

继续阅读“游戏平衡概念-数字关系(2):”

游戏平衡概念-游戏平衡介绍(1)

What is Game Balance?

什么是游戏平衡?

I would start by asking the question “what is game balance?” but I answered it in the teaser video already. While perhaps an oversimplification, we can say that game balance is mostly about figuring out what numbers to use in a game.

我会先问一个问题“什么是游戏平衡? ”但我已经在预告片里回答过了。也许过于简单化了,我们可以说游戏的平衡主要是弄清楚在游戏中使用什么数字。

继续阅读“游戏平衡概念-游戏平衡介绍(1)”