Monday, 28 June 2010

Tips for living well in Shanghai

I've written up the highlights of another forum thread, this time related to tips for living well in Shanghai. As before, the thread covers a period of around five years, so some may be less relevant than they were when posted (assuming they were relevant then).

Forums: Shanghai Expat.
Sub-forum: Lifestyle Recommendations.
Topic: Tips for living well in Shanghai.

Priority Requirements

- Getting a temporary residence slip from the nearest PSB within 48 hours. [1]

Travel

- The maglev to the airport is cheaper if you can produce a ticket for travel on that day. [1]

Markets

- Approaches to bartering. [1]
- Determining the fair price for something before leaving home. [1]

Stores

- Goods are not weighed at the counter, but rather by assistants at scales. [1]
- Places you can buy foreigner food. [1]

Home

- People performing a service in your home should be informed not to smoke. [1]
- If getting internet installed, speed check it before the technician leaves, making sure he fixes it. [1]

Convenience

- You can get your visa/passport delivered to your home for a small fee. [1]
- Buying pre-paid SIMs from tobacco stands. [1]
- The last week of the month (after payday) is not the best time to go to the bank. [1]
- Carry cash and small notes as not everyone can give change. [1]
- The best public restrooms are McDonalds and KFC and you do not need to be a customer. [1]
- Have a english / mandarin speaker on speed dial, so you can call them to translate in an emergency. [1]
- Pay bills at selected convenience stores. [1]
- Get some decent maps. [1]
- Get familiar with different forms of transport so you have more options. [1]

Restaurants

- Declining the tissues you do not want, but have to pay for. [1]

Avoiding being ripped off

- Always ask for a receipt after you finish a taxi ride. [1] [2]
- Beware the maroon taxis. [1] [2] [3] [4] [5]
- Spotting counterfeit money.  Where to buy ultraviolet pens that help. [1] [2] [3]
- Spotting a fake fa piao. [1] [2]

Safety

- Cycling and unsafe taxi drivers. [1]

Being prepared

- Carry toilet paper as toilets may lack it. [1] [2] [3]
- Carry antibacterial cleaning gels as toilets may lack soap. [1] [2]

Etiquette

- Pushing and shoving in crowded spaces is normal. [1] [2] [3]
- Bowls of liquid might not be for drinking, but for washing hands. [1]
- Smiling and staying calm in all circumstances to help save face and resolve a situation. [1] [2]
- Always arrive on time, better to be early than late. [1]
- Friendly general phrases which help. [1] [2]
- Don't criticise how China works. [1]

Getting help

- A phone number that converts between english and chinese. [1]

Saturday, 26 June 2010

Soulfu camera bug

The current project that I spend time on when I feel like games programming is Soulfu. The code as released by its author was written to demonstrate his ability to implement all parts of a game engine. The community took it, cleaned it up and eventually lost the time and energy to continue. Because of this, while the code is now cleaner, it has bugs which were not present in the original game and the source code for it.

I've been fixing up the bugs as I get the time and interest. The one I was looking into today was to do with camera direction on room transitions.

Leaving the village to the castle foyer:


Entering the castle foyer from the village:


Leaving the castle foyer to the dining hall:


Entering the dining hall from the castle foyer:


There are two room transitions here. The first is from the village to the castle foyer, where the movement is generally aligned with the Y axis and camera. The second is from the castle foyer to the dining hall, where the movement is generally aligned with the X axis and is perpendicular to the camera.

What the screenshots show is that the first transition (and any that have the same camera/movement alignment) gives a reversed camera direction. This means that if the player were to keep the movement key depressed, the movement direction will also be reversed and the character will move back out of the door they just entered. This is awkward, wrong and does not match the correct behaviour that is exhibited on the second transition.

The camera direction is calculated within the custom scripting language that Soulfu's author created.

SystemGet(SYS_CAMERASPIN, 0, 0) - new_spin + (old_spin+32768)
After checking a lot of other things, I gave up and ignoring this equation wrote my own.
SystemGet(SYS_CAMERASPIN, 0, 0) + (old_spin - new_spin) + 32768
Now the camera works correctly. Mathematical equations and that programming languages work in the same way, implies that the two equations should be equivalent. The script where this calculation is made has not changed, so the cause of the bug must have been the community cleanup and their changes to the custom scripting system's compiler.

Ideally I'd like to tear out the custom scripting system and replace it with anything else that is popular enough to be stable and able to be treated like a black box. While the game is still riddled with enough bugs that exactly what and how many are present is unknown, they would get in the way of the process. So I'll most likely fix all the bugs, verify the game is restored to its original stable state and then reconsider. Surprisingly, it is easier to debug this scripting language from C and the code running within it, than it is to debug Python when using it in the same way.

Monday, 21 June 2010

Interpolation 2

For some reason I found myself extending my interpolation experiment from allowing dragging of points on the curve, to scrolling the curve depending on various inputs.


There's a bug where the scroll speed starts off faster than the various parameters should allow it to be that I have not tracked down.

Source code: pycurves.